X-Git-Url: http://j8takagi.net/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Fcerr.c;h=121b68030bc726439205fbe1406a0218dc8e7f2a;hb=ccc3acda4256e10a822e41e84f6c9991271c2f61;hp=f7971f68ca4c0e1de9bf8b3e204ed3538d96956f;hpb=2f889a87ef4e11467f71ea3c03676a8d88cccd7b;p=YACASL2.git diff --git a/src/cerr.c b/src/cerr.c index f7971f6..121b680 100644 --- a/src/cerr.c +++ b/src/cerr.c @@ -7,6 +7,8 @@ char *cerrmsg; /* エラー番号とエラーメッセージを設定する */ void setcerr(int num, const char *val) { + assert(&cerr != NULL && num > 0); + cerrno = num; cerrmsg = malloc(MSGSIZE + 1); if(val != NULL) { @@ -21,9 +23,10 @@ void setcerr(int num, const char *val) /* エラー番号からメッセージを返す */ char *getcerrmsg(int num) { - assert(num > 0); + assert(&cerr != NULL && num > 0); int i = 0; CERRARRAY *ptr; + do { if((ptr = &cerr[i++])->num == num) { return ptr->msg;