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
/
cerr.c
diff --git
a/src/cerr.c
b/src/cerr.c
index
36b33a4
..
24f620d
100644
(file)
--- a/
src/cerr.c
+++ b/
src/cerr.c
@@
-25,7
+25,7
@@
CERR *cerr;
CERRLIST *cerrlist;
/**
CERRLIST *cerrlist;
/**
- * ã
\82
¨ã
\83
©ã
\83
¼ã
\83
ªã
\82
¹ã
\83
\88
ã
\82
\92
ä½
\9c
æ
\88
\90
ã
\83
»
追加する
+ * ã
\82
¨ã
\83
©ã
\83
¼ã
\83
ªã
\82
¹ã
\83
\88
ã
\82
\92
ä½
\9c
æ
\88
\90
ã
\81
¾ã
\81
\9f
ã
\81
¯
追加する
*/
bool addcerrlist(int newerrc, CERR newerrv[])
{
*/
bool addcerrlist(int newerrc, CERR newerrv[])
{
@@
-42,15
+42,30
@@
bool addcerrlist(int newerrc, CERR newerrv[])
p = q->next = malloc_chk(sizeof(CERRLIST), "cerrlist.next");
}
for(i = 0; i < newerrc; i++) {
p = q->next = malloc_chk(sizeof(CERRLIST), "cerrlist.next");
}
for(i = 0; i < newerrc; i++) {
- p->cerr = &(newerrv[i]);
- p->next = malloc_chk(sizeof(CERRLIST), "cerrlist.next");
+ p->cerr = &newerrv[i];
q = p;
q = p;
- p = p->next;
+ p = p->next
= malloc_chk(sizeof(CERRLIST), "cerrlist.next")
;
}
q->next = NULL;
return true;
}
}
q->next = NULL;
return true;
}
+/**
+ * エラーリストを表示する
+ */
+void printcerrlist()
+{
+ CERRLIST *p;
+
+ if(cerrlist == NULL) {
+ puts("error list is null.");
+ } else {
+ for(p = cerrlist; p != NULL; p = p->next) {
+ printf("%d: %s\n", p->cerr->num, p->cerr->msg);
+ }
+ }
+}
+
/**
* 現在のエラーを設定する
*/
/**
* 現在のエラーを設定する
*/
@@
-73,13
+88,15
@@
void setcerr(int num, const char *str)
char *getcerrmsg(int num)
{
CERRLIST *p;
char *getcerrmsg(int num)
{
CERRLIST *p;
+ char *msg = "unknown error";
for(p = cerrlist; p != NULL; p = p->next) {
if(num == p->cerr->num) {
for(p = cerrlist; p != NULL; p = p->next) {
if(num == p->cerr->num) {
- return p->cerr->msg;
+ msg = p->cerr->msg;
+ break;
}
}
}
}
- return
"unknown error"
;
+ return
msg
;
}
/**
}
/**
@@
-89,14
+106,13
@@
void freecerr()
{
CERRLIST *p = cerrlist, *q;
{
CERRLIST *p = cerrlist, *q;
- /* エラーリストを解放 */
- while(p != NULL) {
- q = p->next;
- free_chk(p, "freecerr.p");
- p = q;
- }
/* 現在のエラーメッセージを解放 */
free_chk(cerr->msg, "cerr.msg");
/* 現在のエラーを解放 */
free_chk(cerr, "cerr");
/* 現在のエラーメッセージを解放 */
free_chk(cerr->msg, "cerr.msg");
/* 現在のエラーを解放 */
free_chk(cerr, "cerr");
+ /* エラーリストを解放 */
+ for(p = cerrlist; p != NULL; p = q) {
+ q = p->next;
+ free_chk(p, "freecerr.p");
+ }
}
}