X-Git-Url: http://j8takagi.net/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fcerr.c;h=1aeb8c42c29ba3ab3b0813ebec91ae4f5f6c1f8f;hb=62a189b4cdc7045922b132d5ff3371da948f2dbe;hp=121b68030bc726439205fbe1406a0218dc8e7f2a;hpb=ccc3acda4256e10a822e41e84f6c9991271c2f61;p=YACASL2.git diff --git a/src/cerr.c b/src/cerr.c index 121b680..1aeb8c4 100644 --- a/src/cerr.c +++ b/src/cerr.c @@ -5,16 +5,14 @@ int cerrno = 0; char *cerrmsg; /* エラー番号とエラーメッセージを設定する */ -void setcerr(int num, const char *val) +void setcerr(int num, const char *str) { - assert(&cerr != NULL && num > 0); + assert(cerr != NULL && num > 0); cerrno = num; - cerrmsg = malloc(MSGSIZE + 1); - if(val != NULL) { - strcpy(cerrmsg, val); - strcat(cerrmsg, ": "); - strcat(cerrmsg, getcerrmsg(cerrno)); + cerrmsg = malloc(CERRMSGSIZE + 1); + if(str != NULL && strlen(str) < 10) { + sprintf(cerrmsg, "%s: %s", str, getcerrmsg(cerrno)); } else { strcpy(cerrmsg, getcerrmsg(cerrno)); } @@ -23,7 +21,7 @@ void setcerr(int num, const char *val) /* エラー番号からメッセージを返す */ char *getcerrmsg(int num) { - assert(&cerr != NULL && num > 0); + assert(cerr != NULL && num > 0); int i = 0; CERRARRAY *ptr;