{ 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" },
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;
if(quoting == true) {
/* 閉じ「'」がないまま文字列が終了した場合 */
if(*q == '\0') {
- setcerr(123, str); /* illegal string */
+ setcerr(123, str); /* unclosed quote */
break;
}
q++;
sepp = q + strcspn(q, ", ");
sepc = *sepp;
*sepp = '\0';
- if(strlen(p) == 0) {
+ if(*p == '\0') {
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);