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
294c4d4
..
9371758
100644
(file)
--- a/
src/word.c
+++ b/
src/word.c
@@
-1,9
+1,22
@@
#include "word.h"
#include "word.h"
+/* wordのエラー定義 */
+CERR cerr_word[] = {
+ { 114, "not integer" },
+ { 115, "not hex" },
+ { 116, "out of hex range" },
+};
+
+bool addcerrlist_word()
+{
+ return addcerrlist(ARRAYSIZE(cerr_word), cerr_word);
+}
+
/* 10進数の文字列をWORD値に変換 */
WORD n2word(const char *str)
{
assert(isdigit(*str) || *str == '-');
/* 10進数の文字列をWORD値に変換 */
WORD n2word(const char *str)
{
assert(isdigit(*str) || *str == '-');
+
char *check;
int n;
/* WORD値に変換 */
char *check;
int n;
/* WORD値に変換 */
@@
-23,6
+36,7
@@
WORD n2word(const char *str)
WORD h2word(const char *str)
{
assert(*str == '#');
WORD h2word(const char *str)
{
assert(*str == '#');
+
WORD word = 0x0;
char *check;
str++;
WORD word = 0x0;
char *check;
str++;
@@
-42,6
+56,7
@@
WORD h2word(const char *str)
/* 10進数または16進数の文字列をWORD値に変換 */
WORD nh2word(const char *str)
{
/* 10進数または16進数の文字列をWORD値に変換 */
WORD nh2word(const char *str)
{
+ addcerrlist_word();
WORD word;
if(!isdigit(*str) && *str != '-' && *str != '#') {
setcerr(114, str); /* not integer */
WORD word;
if(!isdigit(*str) && *str != '-' && *str != '#') {
setcerr(114, str); /* not integer */
@@
-58,7
+73,7
@@
WORD nh2word(const char *str)
/* WORD値を10進数の文字列に変換 */
char *word2n(WORD word)
{
/* WORD値を10進数の文字列に変換 */
char *word2n(WORD word)
{
- char *p = malloc
(6), *q = malloc(6
);
+ char *p = malloc
_chk(6, "word2n.p"), *q = malloc_chk(6, "word2n.q"
);
int i = 0, j;
do{
*(p + i++) = word % 10 + '0';
int i = 0, j;
do{
*(p + i++) = word % 10 + '0';
@@
-74,7
+89,7
@@
char *word2n(WORD word)
char *word2bit(const WORD word)
{
WORD mask = 0x8000;
char *word2bit(const WORD word)
{
WORD mask = 0x8000;
- char *bit = malloc
(16 + 1
), *p;
+ char *bit = malloc
_chk(16 + 1, "word2bit.bit"
), *p;
p = bit;
do {
*p++ = (word & mask) ? '1' : '0';
p = bit;
do {
*p++ = (word & mask) ? '1' : '0';