[asterisk-commits] trunk r23780 - /trunk/pbx/ael/ael.flex

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sun Apr 30 16:04:59 MST 2006


Author: rizzo
Date: Sun Apr 30 18:04:58 2006
New Revision: 23780

URL: http://svn.digium.com/view/asterisk?rev=23780&view=rev
Log:
another small set of simplifications


Modified:
    trunk/pbx/ael/ael.flex

Modified: trunk/pbx/ael/ael.flex
URL: http://svn.digium.com/view/asterisk/trunk/pbx/ael/ael.flex?rev=23780&r1=23779&r2=23780&view=diff
==============================================================================
--- trunk/pbx/ael/ael.flex (original)
+++ trunk/pbx/ael/ael.flex Sun Apr 30 18:04:58 2006
@@ -239,10 +239,11 @@
 		} else {
 			STORE_LOC;
 			yylval->str = strdup(yytext);
-			yylval->str[strlen(yylval->str)-1] = '\0'; /* trim trailing ')' */
+			yylval->str[yyleng - 1] = '\0'; /* trim trailing ')' */
 			unput(')');
-			BEGIN(0);
-			return word;
+			/* XXX should do my_col-- as we do in other cases ? */
+			BEGIN(0);
+			return word;	/* note it can be an empty string */
 		}
 	}
 
@@ -289,7 +290,10 @@
 			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 @@
 			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 @@
 <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;



More information about the asterisk-commits mailing list