another small set of simplifications

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@23780 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Luigi Rizzo
2006-04-30 23:04:58 +00:00
parent b992d92742
commit 44f43f9eb1

View File

@@ -239,10 +239,11 @@ includes { STORE_POS; return KW_INCLUDES;}
} else { } else {
STORE_LOC; STORE_LOC;
yylval->str = strdup(yytext); yylval->str = strdup(yytext);
yylval->str[strlen(yylval->str)-1] = '\0'; /* trim trailing ')' */ yylval->str[yyleng - 1] = '\0'; /* trim trailing ')' */
unput(')'); unput(')');
/* XXX should do my_col-- as we do in other cases ? */
BEGIN(0); BEGIN(0);
return word; return word; /* note it can be an empty string */
} }
} }
@@ -289,7 +290,10 @@ includes { STORE_POS; return KW_INCLUDES;}
yymore(); yymore();
} else { } else {
STORE_LOC; 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, ")") ) if ( !strcmp(yytext, ")") )
return RP; return RP;
yylval->str = strdup(yytext); yylval->str = strdup(yytext);
@@ -306,14 +310,17 @@ includes { STORE_POS; return KW_INCLUDES;}
yymore(); yymore();
} else { } else {
STORE_LOC; 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, "," ) ) if (!strcmp(yytext, "," ) )
return COMMA; return COMMA;
yylval->str = strdup(yytext);
/* otherwise return the string first, then the comma. */ /* otherwise return the string first, then the comma. */
yylval->str = strdup(yytext);
yylval->str[yyleng-1] = '\0'; /* trim the comma off the string */
unput(','); unput(',');
my_col--; /* XXX not entirely correct, should go 'back' by 1 char */ 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; return word;
} }
} }
@@ -353,8 +360,7 @@ includes { STORE_POS; return KW_INCLUDES;}
<semic>{NOSEMIC}; { <semic>{NOSEMIC}; {
STORE_LOC; STORE_LOC;
yylval->str = strdup(yytext); yylval->str = strdup(yytext);
if(yyleng > 1) yylval->str[yyleng-1] = '\0';
*(yylval->str+yyleng-1)=0;
unput(';'); unput(';');
BEGIN(0); BEGIN(0);
return word; return word;