projects
/
YACASL2.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
f958640
)
文字定数の長さを取得するときに「''」を1文字とするよう修正
author
j8takagi
<j8takagi@nifty.com>
Tue, 9 Feb 2010 00:00:58 +0000
(09:00 +0900)
committer
j8takagi
<j8takagi@nifty.com>
Tue, 9 Feb 2010 12:13:03 +0000
(21:13 +0900)
src/casl2.c
patch
|
blob
|
history
src/token.c
patch
|
blob
|
history
diff --git
a/src/casl2.c
b/src/casl2.c
index
8e0b94a
..
8ae3495
100644
(file)
--- a/
src/casl2.c
+++ b/
src/casl2.c
@@
-52,7
+52,7
@@
CERRARRAY cerr[] = {
{ 120, "GR0 in operand x" },
{ 121, "cannot get operand token" },
{ 122, "cannot create hash table" },
{ 120, "GR0 in operand x" },
{ 121, "cannot get operand token" },
{ 122, "cannot create hash table" },
- { 123, "
illegal string
" },
+ { 123, "
unclosed quote
" },
{ 124, "more than one character in literal" },
{ 125, "not GR in operand x" },
{ 201, "execute - out of COMET II memory" },
{ 124, "more than one character in literal" },
{ 125, "not GR in operand x" },
{ 201, "execute - out of COMET II memory" },
diff --git
a/src/token.c
b/src/token.c
index
96ddcaa
..
68ed3a7
100644
(file)
--- a/
src/token.c
+++ b/
src/token.c
@@
-5,8
+5,8
@@
OPD *opdtok(const char *str)
{
OPD *opd = malloc(sizeof(OPD));
OPD *opdtok(const char *str)
{
OPD *opd = malloc(sizeof(OPD));
- char *p, *q, *sepp;
- int sepc = ',';
+ char *p, *q, *
r, *
sepp;
+ int sepc = ','
, len
;
bool quoting = false;
opd->opdc = 0;
bool quoting = false;
opd->opdc = 0;
@@
-31,7
+31,7
@@
OPD *opdtok(const char *str)
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,12
+39,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 */
+ len = strlen(r = p);
+ while(*r != '\0' && (r = strstr(r, "''")) != NULL) {
+ len--;
+ r += 2;
+ };
+ if(len > OPDSIZE + 2) { /* OPDSIZE + 「'」2文字分 */
+ setcerr(118, NULL); /* operand length is too long */
break;
}
opd->opdv[(++opd->opdc)-1] = strdup(p);
break;
}
opd->opdv[(++opd->opdc)-1] = strdup(p);