simplify logic (runtest passed).

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@23758 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Luigi Rizzo
2006-04-30 22:56:41 +00:00
parent f3eaae4593
commit c22ef69d1f

View File

@@ -74,7 +74,6 @@ static void pbcpush(char x);
static int pbcpop(char x); static int pbcpop(char x);
static int parencount = 0; static int parencount = 0;
static int commaout = 0;
/* /*
* current line, column and filename, updated as we read the input. * current line, column and filename, updated as we read the input.
@@ -290,45 +289,32 @@ 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 */
if ( !strcmp(yytext, ")") )
return RP;
yylval->str = strdup(yytext); yylval->str = strdup(yytext);
if(yyleng > 1 )
yylval->str[yyleng-1] = '\0'; /* trim trailing ')' */ yylval->str[yyleng-1] = '\0'; /* trim trailing ')' */
BEGIN(0); BEGIN(0);
if ( !strcmp(yylval->str,")") ) {
free(yylval->str);
yylval->str = 0;
my_col++; /* XXX why ? */
return RP;
} else {
unput(')'); unput(')');
my_col--; /* XXX not entirely correct, should go 'back' by 1 char */
return word; return word;
} }
} }
}
<argg>{NOARGG}\, { <argg>{NOARGG}\, {
if( parencount != 0) { /* printf("Folding in a comma!\n"); */ if( parencount != 0) { /* printf("Folding in a comma!\n"); */
yymore(); yymore();
} else { } else {
STORE_LOC; STORE_LOC;
if( !commaout ) { /* we have at least 1 char. If it is a single comma, just return it */
if( !strcmp(yytext,"," ) ) { if (!strcmp(yytext, "," ) )
commaout = 0;
my_col+=1;
return COMMA; return COMMA;
}
yylval->str = strdup(yytext); yylval->str = strdup(yytext);
/* printf("Got argg2 word %s\n", yylval->str); */ /* otherwise return the string first, then the comma. */
unput(','); unput(',');
commaout = 1; my_col--; /* XXX not entirely correct, should go 'back' by 1 char */
if (yyleng > 1 ) yylval->str[yyleng-1] = '\0'; /* trim the comma off the string */
*(yylval->str+yyleng-1)=0;
return word; return word;
} else {
commaout = 0;
my_col+=1;
return COMMA;
}
} }
} }
@@ -530,7 +516,6 @@ void reset_argcount(yyscan_t yyscanner )
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
parencount = 0; parencount = 0;
pbcpos = 0; pbcpos = 0;
commaout = 0;
pbcpush('('); pbcpush('(');
c_prevword(); c_prevword();
BEGIN(argg); BEGIN(argg);