diff options
Diffstat (limited to 'pbx/ael/ael.flex')
-rw-r--r-- | pbx/ael/ael.flex | 71 |
1 files changed, 42 insertions, 29 deletions
diff --git a/pbx/ael/ael.flex b/pbx/ael/ael.flex index 6c9bf1827..f1c23d17b 100644 --- a/pbx/ael/ael.flex +++ b/pbx/ael/ael.flex @@ -302,8 +302,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); prev_word = yylval->str; @@ -314,8 +315,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--; @@ -342,8 +344,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(); @@ -355,8 +358,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--; @@ -383,8 +387,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(); @@ -403,8 +408,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; } @@ -413,8 +419,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; @@ -436,9 +443,10 @@ 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); - return word; + yylval->str = malloc(yyleng+1); + strncpy(yylval->str, yytext, yyleng); + yylval->str[yyleng] = 0; + return word; } yymore(); } @@ -465,8 +473,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; } @@ -478,8 +487,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; @@ -493,8 +502,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; } @@ -506,8 +516,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(); @@ -530,8 +541,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(); @@ -539,8 +551,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; |