Merged revisions 162136 via svnmerge from
authorSteve Murphy <murf@digium.com>
Tue, 9 Dec 2008 18:35:35 +0000 (18:35 +0000)
committerSteve Murphy <murf@digium.com>
Tue, 9 Dec 2008 18:35:35 +0000 (18:35 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r162136 | murf | 2008-12-09 11:13:39 -0700 (Tue, 09 Dec 2008) | 1 line

Previous fix used ast_malloc and ast_copy_string and messed up the standalone stuff. Fixed.
........

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@162140 65c4cc65-6c06-0410-ace0-fbb531ad65f3

res/ael/ael.flex
res/ael/ael_lex.c

index 8713550..b44b31e 100644 (file)
@@ -308,8 +308,9 @@ includes    { STORE_POS; return KW_INCLUDES;}
                /* a non-word constituent char, like a space, tab, curly, paren, etc */
                char c = yytext[yyleng-1];
                STORE_POS;
-               yylval->str = ast_malloc(yyleng);
-               ast_copy_string(yylval->str, yytext, yyleng);
+               yylval->str = malloc(yyleng);
+               strncpy(yylval->str, yytext, yyleng);
+               yylval->str[yyleng-1] = 0;
                unput(c);  /* put this ending char back in the stream */
                BEGIN(0);
                return word;
@@ -321,8 +322,9 @@ includes    { STORE_POS; return KW_INCLUDES;}
                        STORE_LOC;
                        ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Mismatched ')' in expression: %s !\n", my_file, my_lineno, my_col, yytext);
                        BEGIN(0);
-                       yylval->str = ast_malloc(yyleng+1);
-                       ast_copy_string(yylval->str, yytext, yyleng+1);
+                       yylval->str = malloc(yyleng+1);
+                       strncpy(yylval->str, yytext, yyleng);
+                       yylval->str[yyleng] = 0;
                        return word;
                }
                parencount2--;
@@ -349,8 +351,9 @@ includes    { STORE_POS; return KW_INCLUDES;}
                        ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Mismatched '%c' in expression!\n",
                                my_file, my_lineno, my_col, c);
                        BEGIN(0);
-                       yylval->str = ast_malloc(yyleng+1);
-                       ast_copy_string(yylval->str, yytext, yyleng+1);
+                       yylval->str = malloc(yyleng+1);
+                       strncpy(yylval->str, yytext, yyleng);
+                       yylval->str[yyleng] = 0;
                        return word;
                }
                yymore();
@@ -362,8 +365,9 @@ includes    { STORE_POS; return KW_INCLUDES;}
                        STORE_LOC;
                        ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Mismatched ')' in expression: %s !\n", my_file, my_lineno, my_col, yytext);
                        BEGIN(0);
-                       yylval->str = ast_malloc(yyleng+1);
-                       ast_copy_string(yylval->str, yytext, yyleng+1);
+                       yylval->str = malloc(yyleng+1);
+                       strncpy(yylval->str, yytext, yyleng);
+                       yylval->str[yyleng] = 0;
                        return word;
                }
                parencount3--;
@@ -390,8 +394,9 @@ includes    { STORE_POS; return KW_INCLUDES;}
                        ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Mismatched '%c' in expression!\n",
                                my_file, my_lineno, my_col, c);
                        BEGIN(0);
-                       yylval->str = ast_malloc(yyleng+1);
-                       ast_copy_string(yylval->str, yytext, yyleng+1);
+                       yylval->str = malloc(yyleng+1);
+                       strncpy(yylval->str, yytext, yyleng);
+                       yylval->str[yyleng] = 0;
                        return word;
                }
                yymore();
@@ -410,8 +415,9 @@ includes    { STORE_POS; return KW_INCLUDES;}
                        STORE_LOC;
                        ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Mismatched ')' in expression: %s !\n", my_file, my_lineno, my_col, yytext);
                        BEGIN(0);
-                       yylval->str = ast_malloc(yyleng+1);
-                       ast_copy_string(yylval->str, yytext, yyleng+1);
+                       yylval->str = malloc(yyleng+1);
+                       strncpy(yylval->str, yytext, yyleng);
+                       yylval->str[yyleng] = 0;
                        prev_word = 0;
                        return word;
                }
@@ -420,8 +426,9 @@ includes    { STORE_POS; return KW_INCLUDES;}
                        yymore();
                } else {
                        STORE_LOC;
-                       yylval->str = ast_malloc(yyleng);
-                       ast_copy_string(yylval->str, yytext, yyleng);
+                       yylval->str = malloc(yyleng);
+                       strncpy(yylval->str, yytext, yyleng);
+                       yylval->str[yyleng-1] = 0;
                        unput(')');
                        BEGIN(0);
                        return word;
@@ -443,8 +450,9 @@ includes    { STORE_POS; return KW_INCLUDES;}
                        ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Mismatched '%c' in expression!\n",
                                my_file, my_lineno, my_col, c);
                        BEGIN(0);
-                       yylval->str = ast_malloc(yyleng+1);
-                       ast_copy_string(yylval->str, yytext, yyleng+1);
+                       yylval->str = malloc(yyleng+1);
+                       strncpy(yylval->str, yytext, yyleng);
+                       yylval->str[yyleng] = 0;
                        return word;
                }
                yymore();
@@ -472,8 +480,9 @@ includes    { STORE_POS; return KW_INCLUDES;}
                        STORE_LOC;
                        ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Mismatched ')' in expression!\n", my_file, my_lineno, my_col);
                        BEGIN(0);
-                       yylval->str = ast_malloc(yyleng+1);
-                       ast_copy_string(yylval->str, yytext, yyleng+1);
+                       yylval->str = malloc(yyleng+1);
+                       strncpy(yylval->str, yytext, yyleng);
+                       yylval->str[yyleng] = 0;
                        return word;
                }
 
@@ -485,8 +494,8 @@ includes    { STORE_POS; return KW_INCLUDES;}
                        BEGIN(0);
                        if ( !strcmp(yytext, ")") )
                                return RP;
-                       yylval->str = ast_malloc(yyleng);
-                       ast_copy_string(yylval->str, yytext, yyleng);
+                       yylval->str = malloc(yyleng);
+                       strncpy(yylval->str, yytext, yyleng);
                        yylval->str[yyleng-1] = '\0'; /* trim trailing ')' */
                        unput(')');
                        return word;
@@ -500,8 +509,9 @@ includes    { STORE_POS; return KW_INCLUDES;}
                        STORE_LOC;
                        if( !strcmp(yytext,"," ) )
                                return COMMA;
-                       yylval->str = ast_malloc(yyleng);
-                       ast_copy_string(yylval->str, yytext, yyleng);
+                       yylval->str = malloc(yyleng);
+                       strncpy(yylval->str, yytext, yyleng);
+                       yylval->str[yyleng-1] = '\0'; /* trim trailing ',' */
                        unput(',');
                        return word;
                }
@@ -513,8 +523,9 @@ includes    { STORE_POS; return KW_INCLUDES;}
                        STORE_LOC;
                        ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Mismatched '%c' in expression!\n", my_file, my_lineno, my_col, c);
                        BEGIN(0);
-                       yylval->str = ast_malloc(yyleng+1);
-                       ast_copy_string(yylval->str, yytext, yyleng+1);
+                       yylval->str = malloc(yyleng+1);
+                       strncpy(yylval->str, yytext, yyleng);
+                       yylval->str[yyleng] = '\0';
                        return word;
                }
                yymore();
@@ -537,8 +548,9 @@ includes    { STORE_POS; return KW_INCLUDES;}
                        STORE_LOC;
                        ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Mismatched '%c' in expression!\n", my_file, my_lineno, my_col, c);
                        BEGIN(0);
-                       yylval->str = ast_malloc(yyleng+1);
-                       ast_copy_string(yylval->str, yytext, yyleng+1);
+                       yylval->str = malloc(yyleng+1);
+                       strncpy(yylval->str, yytext, yyleng);
+                       yylval->str[yyleng] = '\0';
                        return word;
                }
                yymore();
@@ -546,8 +558,9 @@ includes    { STORE_POS; return KW_INCLUDES;}
 
 <semic>{NOSEMIC};      {
                STORE_LOC;
-               yylval->str = ast_malloc(yyleng);
-               ast_copy_string(yylval->str, yytext, yyleng);
+               yylval->str = malloc(yyleng);
+               strncpy(yylval->str, yytext, yyleng);
+               yylval->str[yyleng-1] = '\0'; /* trim trailing ';' */
                unput(';');
                BEGIN(0);
                return word;
index 25d614e..2491baf 100644 (file)
@@ -1613,8 +1613,9 @@ YY_RULE_SETUP
                /* a non-word constituent char, like a space, tab, curly, paren, etc */
                char c = yytext[yyleng-1];
                STORE_POS;
-               yylval->str = ast_malloc(yyleng);
-               ast_copy_string(yylval->str, yytext, yyleng);
+               yylval->str = malloc(yyleng);
+               strncpy(yylval->str, yytext, yyleng);
+               yylval->str[yyleng-1] = 0;
                unput(c);  /* put this ending char back in the stream */
                BEGIN(0);
                return word;
@@ -1623,14 +1624,15 @@ YY_RULE_SETUP
 case 58:
 /* rule 58 can match eol */
 YY_RULE_SETUP
-#line 319 "ael.flex"
+#line 320 "ael.flex"
 {
                if ( pbcpop2('}') ) {   /* error */
                        STORE_LOC;
                        ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Mismatched ')' in expression: %s !\n", my_file, my_lineno, my_col, yytext);
                        BEGIN(0);
-                       yylval->str = ast_malloc(yyleng+1);
-                       ast_copy_string(yylval->str, yytext, yyleng+1);
+                       yylval->str = malloc(yyleng+1);
+                       strncpy(yylval->str, yytext, yyleng);
+                       yylval->str[yyleng] = 0;
                        return word;
                }
                parencount2--;
@@ -1645,7 +1647,7 @@ YY_RULE_SETUP
 case 59:
 /* rule 59 can match eol */
 YY_RULE_SETUP
-#line 337 "ael.flex"
+#line 339 "ael.flex"
 { 
                char c = yytext[yyleng-1];
                if (c == '{')
@@ -1657,7 +1659,7 @@ YY_RULE_SETUP
 case 60:
 /* rule 60 can match eol */
 YY_RULE_SETUP
-#line 345 "ael.flex"
+#line 347 "ael.flex"
 { 
                char c = yytext[yyleng-1];
                if ( pbcpop2(c))  { /* error */
@@ -1665,8 +1667,9 @@ YY_RULE_SETUP
                        ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Mismatched '%c' in expression!\n",
                                my_file, my_lineno, my_col, c);
                        BEGIN(0);
-                       yylval->str = ast_malloc(yyleng+1);
-                       ast_copy_string(yylval->str, yytext, yyleng+1);
+                       yylval->str = malloc(yyleng+1);
+                       strncpy(yylval->str, yytext, yyleng);
+                       yylval->str[yyleng] = 0;
                        return word;
                }
                yymore();
@@ -1675,14 +1678,15 @@ YY_RULE_SETUP
 case 61:
 /* rule 61 can match eol */
 YY_RULE_SETUP
-#line 360 "ael.flex"
+#line 363 "ael.flex"
 {
                if ( pbcpop3(']') ) {   /* error */
                        STORE_LOC;
                        ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Mismatched ')' in expression: %s !\n", my_file, my_lineno, my_col, yytext);
                        BEGIN(0);
-                       yylval->str = ast_malloc(yyleng+1);
-                       ast_copy_string(yylval->str, yytext, yyleng+1);
+                       yylval->str = malloc(yyleng+1);
+                       strncpy(yylval->str, yytext, yyleng);
+                       yylval->str[yyleng] = 0;
                        return word;
                }
                parencount3--;
@@ -1697,7 +1701,7 @@ YY_RULE_SETUP
 case 62:
 /* rule 62 can match eol */
 YY_RULE_SETUP
-#line 378 "ael.flex"
+#line 382 "ael.flex"
 { 
                char c = yytext[yyleng-1];
                if (c == '[')
@@ -1709,7 +1713,7 @@ YY_RULE_SETUP
 case 63:
 /* rule 63 can match eol */
 YY_RULE_SETUP
-#line 386 "ael.flex"
+#line 390 "ael.flex"
 { 
                char c = yytext[yyleng-1];
                if ( pbcpop3(c))  { /* error */
@@ -1717,8 +1721,9 @@ YY_RULE_SETUP
                        ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Mismatched '%c' in expression!\n",
                                my_file, my_lineno, my_col, c);
                        BEGIN(0);
-                       yylval->str = ast_malloc(yyleng+1);
-                       ast_copy_string(yylval->str, yytext, yyleng+1);
+                       yylval->str = malloc(yyleng+1);
+                       strncpy(yylval->str, yytext, yyleng);
+                       yylval->str[yyleng] = 0;
                        return word;
                }
                yymore();
@@ -1734,14 +1739,15 @@ YY_RULE_SETUP
 case 64:
 /* rule 64 can match eol */
 YY_RULE_SETUP
-#line 408 "ael.flex"
+#line 413 "ael.flex"
 {
                if ( pbcpop(')') ) {    /* error */
                        STORE_LOC;
                        ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Mismatched ')' in expression: %s !\n", my_file, my_lineno, my_col, yytext);
                        BEGIN(0);
-                       yylval->str = ast_malloc(yyleng+1);
-                       ast_copy_string(yylval->str, yytext, yyleng+1);
+                       yylval->str = malloc(yyleng+1);
+                       strncpy(yylval->str, yytext, yyleng);
+                       yylval->str[yyleng] = 0;
                        prev_word = 0;
                        return word;
                }
@@ -1750,8 +1756,9 @@ YY_RULE_SETUP
                        yymore();
                } else {
                        STORE_LOC;
-                       yylval->str = ast_malloc(yyleng);
-                       ast_copy_string(yylval->str, yytext, yyleng);
+                       yylval->str = malloc(yyleng);
+                       strncpy(yylval->str, yytext, yyleng);
+                       yylval->str[yyleng-1] = 0;
                        unput(')');
                        BEGIN(0);
                        return word;
@@ -1761,7 +1768,7 @@ YY_RULE_SETUP
 case 65:
 /* rule 65 can match eol */
 YY_RULE_SETUP
-#line 431 "ael.flex"
+#line 438 "ael.flex"
 {
                char c = yytext[yyleng-1];
                if (c == '(')
@@ -1773,7 +1780,7 @@ YY_RULE_SETUP
 case 66:
 /* rule 66 can match eol */
 YY_RULE_SETUP
-#line 439 "ael.flex"
+#line 446 "ael.flex"
 {
                char c = yytext[yyleng-1];
                if ( pbcpop(c))  { /* error */
@@ -1781,8 +1788,9 @@ YY_RULE_SETUP
                        ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Mismatched '%c' in expression!\n",
                                my_file, my_lineno, my_col, c);
                        BEGIN(0);
-                       yylval->str = ast_malloc(yyleng+1);
-                       ast_copy_string(yylval->str, yytext, yyleng+1);
+                       yylval->str = malloc(yyleng+1);
+                       strncpy(yylval->str, yytext, yyleng);
+                       yylval->str[yyleng] = 0;
                        return word;
                }
                yymore();
@@ -1799,7 +1807,7 @@ YY_RULE_SETUP
 case 67:
 /* rule 67 can match eol */
 YY_RULE_SETUP
-#line 462 "ael.flex"
+#line 470 "ael.flex"
 {
                char c = yytext[yyleng-1];
                if (c == '(')
@@ -1811,14 +1819,15 @@ YY_RULE_SETUP
 case 68:
 /* rule 68 can match eol */
 YY_RULE_SETUP
-#line 470 "ael.flex"
+#line 478 "ael.flex"
 {
                if ( pbcpop(')') ) { /* error */
                        STORE_LOC;
                        ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Mismatched ')' in expression!\n", my_file, my_lineno, my_col);
                        BEGIN(0);
-                       yylval->str = ast_malloc(yyleng+1);
-                       ast_copy_string(yylval->str, yytext, yyleng+1);
+                       yylval->str = malloc(yyleng+1);
+                       strncpy(yylval->str, yytext, yyleng);
+                       yylval->str[yyleng] = 0;
                        return word;
                }
 
@@ -1830,8 +1839,8 @@ YY_RULE_SETUP
                        BEGIN(0);
                        if ( !strcmp(yytext, ")") )
                                return RP;
-                       yylval->str = ast_malloc(yyleng);
-                       ast_copy_string(yylval->str, yytext, yyleng);
+                       yylval->str = malloc(yyleng);
+                       strncpy(yylval->str, yytext, yyleng);
                        yylval->str[yyleng-1] = '\0'; /* trim trailing ')' */
                        unput(')');
                        return word;
@@ -1841,7 +1850,7 @@ YY_RULE_SETUP
 case 69:
 /* rule 69 can match eol */
 YY_RULE_SETUP
-#line 496 "ael.flex"
+#line 505 "ael.flex"
 {
                if( parencount != 0) { /* ast_log(LOG_NOTICE,"Folding in a comma!\n"); */
                        yymore();
@@ -1849,8 +1858,9 @@ YY_RULE_SETUP
                        STORE_LOC;
                        if( !strcmp(yytext,"," ) )
                                return COMMA;
-                       yylval->str = ast_malloc(yyleng);
-                       ast_copy_string(yylval->str, yytext, yyleng);
+                       yylval->str = malloc(yyleng);
+                       strncpy(yylval->str, yytext, yyleng);
+                       yylval->str[yyleng-1] = '\0'; /* trim trailing ',' */
                        unput(',');
                        return word;
                }
@@ -1859,15 +1869,16 @@ YY_RULE_SETUP
 case 70:
 /* rule 70 can match eol */
 YY_RULE_SETUP
-#line 510 "ael.flex"
+#line 520 "ael.flex"
 {
                char c = yytext[yyleng-1];
                if ( pbcpop(c) ) { /* error */
                        STORE_LOC;
                        ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Mismatched '%c' in expression!\n", my_file, my_lineno, my_col, c);
                        BEGIN(0);
-                       yylval->str = ast_malloc(yyleng+1);
-                       ast_copy_string(yylval->str, yytext, yyleng+1);
+                       yylval->str = malloc(yyleng+1);
+                       strncpy(yylval->str, yytext, yyleng);
+                       yylval->str[yyleng] = '\0';
                        return word;
                }
                yymore();
@@ -1881,7 +1892,7 @@ YY_RULE_SETUP
 case 71:
 /* rule 71 can match eol */
 YY_RULE_SETUP
-#line 528 "ael.flex"
+#line 539 "ael.flex"
 {
                char c = yytext[yyleng-1];
                yymore();
@@ -1891,15 +1902,16 @@ YY_RULE_SETUP
 case 72:
 /* rule 72 can match eol */
 YY_RULE_SETUP
-#line 534 "ael.flex"
+#line 545 "ael.flex"
 {
                char c = yytext[yyleng-1];
                if ( pbcpop(c) ) { /* error */
                        STORE_LOC;
                        ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Mismatched '%c' in expression!\n", my_file, my_lineno, my_col, c);
                        BEGIN(0);
-                       yylval->str = ast_malloc(yyleng+1);
-                       ast_copy_string(yylval->str, yytext, yyleng+1);
+                       yylval->str = malloc(yyleng+1);
+                       strncpy(yylval->str, yytext, yyleng);
+                       yylval->str[yyleng] = '\0';
                        return word;
                }
                yymore();
@@ -1908,11 +1920,12 @@ YY_RULE_SETUP
 case 73:
 /* rule 73 can match eol */
 YY_RULE_SETUP
-#line 547 "ael.flex"
+#line 559 "ael.flex"
 {
                STORE_LOC;
-               yylval->str = ast_malloc(yyleng);
-               ast_copy_string(yylval->str, yytext, yyleng);
+               yylval->str = malloc(yyleng);
+               strncpy(yylval->str, yytext, yyleng);
+               yylval->str[yyleng-1] = '\0'; /* trim trailing ';' */
                unput(';');
                BEGIN(0);
                return word;
@@ -1921,7 +1934,7 @@ YY_RULE_SETUP
 case 74:
 /* rule 74 can match eol */
 YY_RULE_SETUP
-#line 556 "ael.flex"
+#line 569 "ael.flex"
 {
                char fnamebuf[1024],*p1,*p2;
                int glob_ret;
@@ -1974,7 +1987,7 @@ case YY_STATE_EOF(comment):
 case YY_STATE_EOF(curlystate):
 case YY_STATE_EOF(wordstate):
 case YY_STATE_EOF(brackstate):
-#line 601 "ael.flex"
+#line 614 "ael.flex"
 {
                char fnamebuf[2048];
                if (include_stack_index > 0 && include_stack[include_stack_index-1].globbuf_pos < include_stack[include_stack_index-1].globbuf.gl_pathc-1) {
@@ -2009,10 +2022,10 @@ case YY_STATE_EOF(brackstate):
        YY_BREAK
 case 75:
 YY_RULE_SETUP
-#line 633 "ael.flex"
+#line 646 "ael.flex"
 ECHO;
        YY_BREAK
-#line 2015 "ael_lex.c"
+#line 2028 "ael_lex.c"
 
        case YY_END_OF_BUFFER:
                {
@@ -3185,7 +3198,7 @@ void *ael_yyrealloc  (void * ptr, yy_size_t  size , yyscan_t yyscanner)
 
 #define YYTABLES_NAME "yytables"
 
-#line 633 "ael.flex"
+#line 646 "ael.flex"