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
/
token.c
diff --git
a/src/token.c
b/src/token.c
index
96ddcaa
..
ec86ac5
100644
(file)
--- a/
src/token.c
+++ b/
src/token.c
@@
-6,7
+6,7
@@
OPD *opdtok(const char *str)
{
OPD *opd = malloc(sizeof(OPD));
char *p, *q, *sepp;
{
OPD *opd = malloc(sizeof(OPD));
char *p, *q, *sepp;
- int sepc = ',';
+ int sepc = ','
, qcnt = 0
;
bool quoting = false;
opd->opdc = 0;
bool quoting = false;
opd->opdc = 0;
@@
-17,21
+17,28
@@
OPD *opdtok(const char *str)
do {
/* オペランド数が多すぎる場合はエラー */
if(opd->opdc >= OPDSIZE) {
do {
/* オペランド数が多すぎる場合はエラー */
if(opd->opdc >= OPDSIZE) {
- setcerr(117,
str
); /* operand is too many */
+ setcerr(117,
NULL
); /* operand is too many */
break;
}
/* 先頭が「=」の場合の処理 */
if(*q == '=') {
q++;
}
break;
}
/* 先頭が「=」の場合の処理 */
if(*q == '=') {
q++;
}
- /* 「'」で囲まれた文字列の処理。「''」は無視 */
- if(*q == '\'' && *(q+1) != '\'' && !(p < q && *(q-1) == '\'')) {
- quoting = !quoting;
+ /* 「'」の場合 */
+ if(*q == '\'') {
+ /* 「''」以外の場合はquote値を反転 */
+ if(*(q+1) != '\'' && !(p < q && *(q-1) == '\'')) {
+ quoting = !quoting;
+ }
+ /* 「'」の分、文字列の長さを小さくする */
+ if(*(q+1) != '\'') {
+ qcnt++;
+ }
}
if(quoting == true) {
/* 閉じ「'」がないまま文字列が終了した場合 */
if(*q == '\0') {
}
if(quoting == true) {
/* 閉じ「'」がないまま文字列が終了した場合 */
if(*q == '\0') {
- setcerr(123, str); /*
illegal string
*/
+ setcerr(123, str); /*
unclosed quote
*/
break;
}
q++;
break;
}
q++;
@@
-39,16
+46,17
@@
OPD *opdtok(const char *str)
sepp = q + strcspn(q, ", ");
sepc = *sepp;
*sepp = '\0';
sepp = q + strcspn(q, ", ");
sepc = *sepp;
*sepp = '\0';
- if(
strlen(p) == 0
) {
+ if(
*p == '\0'
) {
setcerr(121, NULL); /* cannot get operand token */
break;
}
setcerr(121, NULL); /* cannot get operand token */
break;
}
- if(strlen(p)
> OPDSIZE + 2) { /* OPDSIZE + 「'」2文字分 */
- setcerr(118,
p
); /* operand length is too long */
+ if(strlen(p)
- qcnt > OPDSIZE) {
+ setcerr(118,
NULL
); /* operand length is too long */
break;
}
opd->opdv[(++opd->opdc)-1] = strdup(p);
p = q = sepp + 1;
break;
}
opd->opdv[(++opd->opdc)-1] = strdup(p);
p = q = sepp + 1;
+ qcnt = 0;
}
} while(sepc == ',');
return opd;
}
} while(sepc == ',');
return opd;