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

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sun Apr 30 16:21:50 MST 2006


Author: rizzo
Date: Sun Apr 30 18:21:49 2006
New Revision: 23781

URL: http://svn.digium.com/view/asterisk?rev=23781&view=rev
Log:
revert ael.flex to the last correct version.
For some reason the makefile did not regenerate the
ael_lex.c file correctly so i was not testing the changes.


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=23781&r1=23780&r2=23781&view=diff
==============================================================================
--- trunk/pbx/ael/ael.flex (original)
+++ trunk/pbx/ael/ael.flex Sun Apr 30 18:21:49 2006
@@ -74,6 +74,7 @@
 static int pbcpop(char x);
 
 static int parencount = 0;
+static int commaout = 0;
 
 /*
  * current line, column and filename, updated as we read the input.
@@ -239,11 +240,10 @@
 		} else {
 			STORE_LOC;
 			yylval->str = strdup(yytext);
-			yylval->str[yyleng - 1] = '\0'; /* trim trailing ')' */
+			yylval->str[strlen(yylval->str)-1] = '\0'; /* trim trailing ')' */
 			unput(')');
-			/* XXX should do my_col-- as we do in other cases ? */
-			BEGIN(0);
-			return word;	/* note it can be an empty string */
+			BEGIN(0);
+			return word;
 		}
 	}
 
@@ -290,18 +290,19 @@
 			yymore();
 		} else {
 			STORE_LOC;
-			/* 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, ")") )
+			yylval->str = strdup(yytext);
+			if(yyleng > 1 )
+				yylval->str[yyleng-1] = '\0'; /* trim trailing ')' */
+			BEGIN(0);
+			if ( !strcmp(yylval->str,")") ) {
+				free(yylval->str);
+				yylval->str = 0;
+				my_col++; /* XXX why ? */
 				return RP;
-			yylval->str = strdup(yytext);
-			yylval->str[yyleng-1] = '\0'; /* trim trailing ')' */
-			BEGIN(0);
-			unput(')');
-			my_col--;	/* XXX not entirely correct, should go 'back' by 1 char */
-			return word;
+			} else {
+				unput(')');
+				return word;
+			}
 		}
 	}
 
@@ -310,18 +311,24 @@
 			yymore();
 		} else  {
 			STORE_LOC;
-			/* 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( !commaout ) {
+				if( !strcmp(yytext,"," ) ) {
+					commaout = 0;
+					my_col+=1;
+					return COMMA;
+				}
+				yylval->str = strdup(yytext);
+				/* printf("Got argg2 word %s\n", yylval->str); */
+				unput(',');
+				commaout = 1;
+				if (yyleng > 1 )
+					*(yylval->str+yyleng-1)=0;
+				return word;
+			} else {
+				commaout = 0;
+				my_col+=1;
 				return 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(',');
-			my_col--;	/* XXX not entirely correct, should go 'back' by 1 char */
-			return word;
+			}
 		}
 	}
 
@@ -360,7 +367,8 @@
 <semic>{NOSEMIC};	{
 		STORE_LOC;
 		yylval->str = strdup(yytext);
-		yylval->str[yyleng-1] = '\0';
+		if(yyleng > 1)
+			*(yylval->str+yyleng-1)=0;
 		unput(';');
 		BEGIN(0);
 		return word;
@@ -522,6 +530,7 @@
 	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 	parencount = 0;
 	pbcpos = 0;
+	commaout = 0;
 	pbcpush('(');
 	c_prevword();
 	BEGIN(argg);



More information about the asterisk-commits mailing list