projects
/
YACASL2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
実行時、バイナリからCOMET II以外の値を読み込んだ場合はエラーが発生するよう変更
[YACASL2.git]
/
src
/
word.c
diff --git
a/src/word.c
b/src/word.c
index
3e9d305
..
1bbffdb
100644
(file)
--- a/
src/word.c
+++ b/
src/word.c
@@
-7,15
+7,27
@@
#include "word.h"
#include "cerr.h"
#include "word.h"
#include "cerr.h"
-/* wordのエラー定義 */
+/**
+ * wordのエラー定義
+ */
static CERR cerr_word[] = {
{ 114, "not integer" },
{ 115, "not hex" },
{ 116, "out of hex range" },
};
static CERR cerr_word[] = {
{ 114, "not integer" },
{ 115, "not hex" },
{ 116, "out of hex range" },
};
-/* 10進数の文字列をWORD値に変換 */
-static WORD n2word(const char *str)
+/**
+ * wordのエラーをエラーリストに追加
+ */
+bool addcerrlist_word()
+{
+ return addcerrlist(ARRAYSIZE(cerr_word), cerr_word);
+}
+
+/**
+ * 10進数の文字列をWORD値に変換
+ */
+WORD n2word(const char *str)
{
assert(isdigit(*str) || *str == '-');
{
assert(isdigit(*str) || *str == '-');
@@
-34,8
+46,10
@@
static WORD n2word(const char *str)
return (WORD)n;
}
return (WORD)n;
}
-/* 16進数の文字列をWORD値に変換 */
-static WORD h2word(const char *str)
+/**
+ * 16進数の文字列をWORD値に変換
+ */
+WORD h2word(const char *str)
{
assert(*str == '#');
{
assert(*str == '#');
@@
-55,11
+69,12
@@
static WORD h2word(const char *str)
return word;
}
return word;
}
-/* 10進数または16進数の文字列をWORD値に変換 */
+/**
+ * 10進数または16進数の文字列をWORD値に変換
+ */
WORD nh2word(const char *str)
{
assert(sizeof(WORD)*8 == 16); /* WORD型のサイズが16ビットであることを確認 */
WORD nh2word(const char *str)
{
assert(sizeof(WORD)*8 == 16); /* WORD型のサイズが16ビットであることを確認 */
- addcerrlist(ARRAYSIZE(cerr_word), cerr_word); /* エラーの設定 */
WORD word;
WORD word;
@@
-75,7
+90,9
@@
WORD nh2word(const char *str)
return word;
}
return word;
}
-/* WORD値を10進数の文字列に変換 */
+/**
+ * WORD値を10進数の文字列に変換
+ */
char *word2n(WORD word)
{
enum {
char *word2n(WORD word)
{
enum {
@@
-95,7
+112,9
@@
char *word2n(WORD word)
return digit;
}
return digit;
}
-/* WORD値を2進数の文字列に変換 */
+/**
+ * WORD値を2進数の文字列に変換
+ */
char *word2bit(const WORD word)
{
enum {
char *word2bit(const WORD word)
{
enum {
@@
-112,7
+131,9
@@
char *word2bit(const WORD word)
return bit;
}
return bit;
}
-/* WORD値を解析して表示 */
+/**
+ * WORD値を解析して表示
+ */
void print_dumpword(WORD word, bool logicalmode)
{
if(logicalmode == true) {
void print_dumpword(WORD word, bool logicalmode)
{
if(logicalmode == true) {