]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
another small set of simplifications
authorLuigi Rizzo <rizzo@icir.org>
Sun, 30 Apr 2006 23:04:58 +0000 (23:04 +0000)
committerLuigi Rizzo <rizzo@icir.org>
Sun, 30 Apr 2006 23:04:58 +0000 (23:04 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@23780 65c4cc65-6c06-0410-ace0-fbb531ad65f3

pbx/ael/ael.flex

index 5d360141e0bfbfe1f5bd0bc117587d87f8da26cc..24a621acfed886c53a2ce101cbceefed6f5f0c5e 100644 (file)
@@ -239,10 +239,11 @@ includes  { STORE_POS; return KW_INCLUDES;}
                } 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 */
                }
        }
 
@@ -289,7 +290,10 @@ includes   { STORE_POS; return KW_INCLUDES;}
                        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);
@@ -306,14 +310,17 @@ includes  { STORE_POS; return KW_INCLUDES;}
                        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;
                }
        }
@@ -353,8 +360,7 @@ includes    { STORE_POS; return KW_INCLUDES;}
 <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;