} else {
STORE_LOC;
yylval->str = strdup(yytext);
- yylval->str[strlen(yylval->str)-1] = '\0'; /* trim trailing ')' */
+ yylval->str[yyleng - 1] = '\0'; /* trim trailing ')' */
unput(')');
+ /* XXX should do my_col-- as we do in other cases ? */
BEGIN(0);
- return word;
+ return word; /* note it can be an empty string */
}
}
yymore();
} else {
STORE_LOC;
- /* we have at least 1 char. If it is a single ')', just return it */
+ /* we have at least 1 char.
+ * If it is a single ')', just return it.
+ * XXX this means we never return an empty 'word' in this context
+ */
if ( !strcmp(yytext, ")") )
return RP;
yylval->str = strdup(yytext);
yymore();
} else {
STORE_LOC;
- /* we have at least 1 char. If it is a single comma, just return it */
+ /* we have at least 1 char.
+ * If it is a single ',', just return it.
+ * XXX this means we never return an empty 'word' in this context
+ */
if (!strcmp(yytext, "," ) )
return COMMA;
- yylval->str = strdup(yytext);
/* otherwise return the string first, then the comma. */
+ yylval->str = strdup(yytext);
+ yylval->str[yyleng-1] = '\0'; /* trim the comma off the string */
unput(',');
my_col--; /* XXX not entirely correct, should go 'back' by 1 char */
- yylval->str[yyleng-1] = '\0'; /* trim the comma off the string */
return word;
}
}
<semic>{NOSEMIC}; {
STORE_LOC;
yylval->str = strdup(yytext);
- if(yyleng > 1)
- *(yylval->str+yyleng-1)=0;
+ yylval->str[yyleng-1] = '\0';
unput(';');
BEGIN(0);
return word;