projects
/
YACASL2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
マニュアルのサンプルソースを更新
[YACASL2.git]
/
src
/
word.c
diff --git
a/src/word.c
b/src/word.c
index
bb564cf
..
3ad9a2b
100644
(file)
--- a/
src/word.c
+++ b/
src/word.c
@@
-73,22
+73,7
@@
static CERR cerr_word[] = {
{ 116, "out of hex range" },
};
{ 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で定義された関数群 */
/* word.hで定義された関数群 */
-void addcerrlist_load()
-{
- addcerrlist(ARRAYSIZE(cerr_load), cerr_load);
-}
-
void addcerrlist_word()
{
addcerrlist(ARRAYSIZE(cerr_word), cerr_word);
void addcerrlist_word()
{
addcerrlist(ARRAYSIZE(cerr_word), cerr_word);
@@
-117,21
+102,19
@@
WORD nh2word(const char *str)
char *word2n(WORD word)
{
enum {
char *word2n(WORD word)
{
enum {
- MAXLEN = 5, /* WORD値を10進数で表したときの最大
桁
数 */
+ MAXLEN = 5, /* WORD値を10進数で表したときの最大
けた
数 */
};
};
- char *n = malloc_chk(MAXLEN + 1, "word2n.n"), tmp;
- int i = 0, j;
+ char *s = malloc_chk(MAXLEN + 1, "word2n.n");
+ char *t = NULL;
+ int d = 0; /* けた数 */
do{
do{
-
n[i
++] = word % 10 + '0';
+
s[d
++] = word % 10 + '0';
} while((word /= 10) > 0);
} while((word /= 10) > 0);
- for(j = 0; j < i; j++) {
- tmp = n[j];
- n[j] = n[(i-1)-j];
- n[(i-1)-j] = tmp;
- }
- n[j] = '\0';
- return n;
+ s[d] = '\0';
+ t = strrev(s);
+ FREE(s);
+ return t;
}
char *word2bit(const WORD word)
}
char *word2bit(const WORD word)
@@
-153,14
+136,14
@@
char *word2bit(const WORD word)
void print_dumpword(WORD word, bool logicalmode)
{
void print_dumpword(WORD word, bool logicalmode)
{
- char *bit =
NULL
;
+ char *bit =
word2bit(word)
;
if(logicalmode == true) {
if(logicalmode == true) {
- fprintf(stdout, "%6
d
", word);
+ fprintf(stdout, "%6
u
", word);
} else {
fprintf(stdout, "%6d", (signed short)word);
}
} else {
fprintf(stdout, "%6d", (signed short)word);
}
- fprintf(stdout, " = #%04X = %s", word,
(bit = word2bit(word))
);
+ fprintf(stdout, " = #%04X = %s", word,
bit
);
/* 「文字の組」の符号表に記載された文字と、改行(CR)/タブを表示 */
if(word >= 0x20 && word <= 0x7E) {
fprintf(stdout, " = \'%c\'", word);
/* 「文字の組」の符号表に記載された文字と、改行(CR)/タブを表示 */
if(word >= 0x20 && word <= 0x7E) {
fprintf(stdout, " = \'%c\'", word);