diff options
Diffstat (limited to 'res/ael/ael.flex')
-rw-r--r-- | res/ael/ael.flex | 69 |
1 files changed, 41 insertions, 28 deletions
diff --git a/res/ael/ael.flex b/res/ael/ael.flex index 8713550db..b44b31e75 100644 --- a/res/ael/ael.flex +++ b/res/ael/ael.flex @@ -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; |