X-Git-Url: http://j8takagi.net/cgi-bin/gitweb.cgi?p=YACASL2.git;a=blobdiff_plain;f=src%2Fword.c;h=e11b73017a7858a4718ecdf63181e795c33234cc;hp=df953c5060b0dd8bd728fb8a07a5b81c6a7a2878;hb=8808be96beb5502d13c0cd957b9fc3cec72ac6e3;hpb=bbd97e8f26bfbb3d4b4688bea469062d82aaa764 diff --git a/src/word.c b/src/word.c index df953c5..e11b730 100644 --- a/src/word.c +++ b/src/word.c @@ -25,15 +25,6 @@ WORD n2word(const char *str); */ WORD h2word(const char *str); -/** - * @brief wordのエラー定義 - */ -static CERR cerr_word[] = { - { 114, "not integer" }, - { 115, "not hex" }, - { 116, "out of hex range" }, -}; - WORD n2word(const char *str) { assert(isdigit(str[0]) || str[0] == '-'); @@ -73,7 +64,31 @@ WORD h2word(const char *str) return w; } +/** + * @brief wordのエラー定義 + */ +static CERR cerr_word[] = { + { 114, "not integer" }, + { 115, "not hex" }, + { 116, "out of hex range" }, +}; + +/** + * @brief ファイル読み込みのエラー定義 + */ +static CERR cerr_load[] = { + { 210, "load - memory overflow" }, + { 211, "object file not specified" }, + { 212, "invalid option" }, + { 213, "invalid argument" }, +}; + /* word.hで定義された関数群 */ +void addcerrlist_load() +{ + addcerrlist(ARRAYSIZE(cerr_load), cerr_load); +} + void addcerrlist_word() { addcerrlist(ARRAYSIZE(cerr_word), cerr_word); @@ -137,14 +152,14 @@ char *word2bit(const WORD word) void print_dumpword(WORD word, bool logicalmode) { - const char *bit = word2bit(word); + char *bit = NULL; if(logicalmode == true) { fprintf(stdout, "%6d", word); } else { fprintf(stdout, "%6d", (signed short)word); } - fprintf(stdout, " = #%04X = %s", word, bit); + fprintf(stdout, " = #%04X = %s", word, (bit = word2bit(word))); /* 「文字の組」の符号表に記載された文字と、改行(CR)/タブを表示 */ if(word >= 0x20 && word <= 0x7E) { fprintf(stdout, " = \'%c\'", word); @@ -153,4 +168,5 @@ void print_dumpword(WORD word, bool logicalmode) } else if(word == '\t') { fprintf(stdout, " = \'\\t\'"); } + FREE(bit); }