mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-20 08:40:16 +00:00
Code previously added to ast_expr2f.c warranted a change in the source file ast_expr2.fl.
Also, made a Makefile change to ensure that the expression parser C source files get regenerated correctly, when we need that to happen. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@239797 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -17,7 +17,8 @@ all: asterisk
|
|||||||
|
|
||||||
include $(ASTTOPDIR)/Makefile.moddir_rules
|
include $(ASTTOPDIR)/Makefile.moddir_rules
|
||||||
|
|
||||||
SRC=$(wildcard *.c)
|
# Must include the extra ast_expr2.c, ast_expr2f.c, in case they need to be regenerated (because to force regeneration, we delete them)
|
||||||
|
SRC=$(wildcard *.c) ast_expr2.c ast_expr2f.c
|
||||||
OBJSFILTER=fskmodem_int.o fskmodem_float.o cygload.o buildinfo.o
|
OBJSFILTER=fskmodem_int.o fskmodem_float.o cygload.o buildinfo.o
|
||||||
OBJS=$(filter-out $(OBJSFILTER),$(SRC:.c=.o))
|
OBJS=$(filter-out $(OBJSFILTER),$(SRC:.c=.o))
|
||||||
|
|
||||||
|
|||||||
@@ -251,17 +251,13 @@ void ast_yyfree(void *ptr, yyscan_t yyscanner)
|
|||||||
|
|
||||||
int ast_expr(char *expr, char *buf, int length, struct ast_channel *chan)
|
int ast_expr(char *expr, char *buf, int length, struct ast_channel *chan)
|
||||||
{
|
{
|
||||||
struct parse_io io;
|
struct parse_io io = { .string = expr, .chan = chan };
|
||||||
int return_value = 0;
|
int return_value = 0;
|
||||||
|
|
||||||
memset(&io, 0, sizeof(io));
|
|
||||||
io.string = expr; /* to pass to the error routine */
|
|
||||||
io.chan = chan;
|
|
||||||
|
|
||||||
ast_yylex_init(&io.scanner);
|
ast_yylex_init(&io.scanner);
|
||||||
|
|
||||||
ast_yy_scan_string(expr, io.scanner);
|
ast_yy_scan_string(expr, io.scanner);
|
||||||
|
|
||||||
ast_yyparse ((void *) &io);
|
ast_yyparse ((void *) &io);
|
||||||
|
|
||||||
ast_yylex_destroy(io.scanner);
|
ast_yylex_destroy(io.scanner);
|
||||||
@@ -294,6 +290,32 @@ int ast_expr(char *expr, char *buf, int length, struct ast_channel *chan)
|
|||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef STANDALONE
|
||||||
|
int ast_str_expr(struct ast_str **str, ssize_t maxlen, struct ast_channel *chan, char *expr)
|
||||||
|
{
|
||||||
|
struct parse_io io = { .string = expr, .chan = chan };
|
||||||
|
|
||||||
|
ast_yylex_init(&io.scanner);
|
||||||
|
ast_yy_scan_string(expr, io.scanner);
|
||||||
|
ast_yyparse ((void *) &io);
|
||||||
|
ast_yylex_destroy(io.scanner);
|
||||||
|
|
||||||
|
if (!io.val) {
|
||||||
|
ast_str_set(str, maxlen, "0");
|
||||||
|
} else {
|
||||||
|
if (io.val->type == AST_EXPR_number) {
|
||||||
|
int res_length;
|
||||||
|
ast_str_set(str, maxlen, FP___PRINTF, io.val->u.i);
|
||||||
|
} else if (io.val->u.s) {
|
||||||
|
ast_str_set(str, maxlen, "%s", io.val->u.s);
|
||||||
|
free(io.val->u.s);
|
||||||
|
}
|
||||||
|
free(io.val);
|
||||||
|
}
|
||||||
|
return ast_str_strlen(*str);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
char extra_error_message[4095];
|
char extra_error_message[4095];
|
||||||
int extra_error_message_supplied = 0;
|
int extra_error_message_supplied = 0;
|
||||||
@@ -370,7 +392,8 @@ static char *expr2_token_subst(const char *mess)
|
|||||||
/* calc a length, malloc, fill, and return; yyerror had better free it! */
|
/* calc a length, malloc, fill, and return; yyerror had better free it! */
|
||||||
int len=0,i;
|
int len=0,i;
|
||||||
const char *p;
|
const char *p;
|
||||||
char *res, *s,*t;
|
char *res, *s;
|
||||||
|
const char *t;
|
||||||
int expr2_token_equivs_entries = sizeof(expr2_token_equivs1)/sizeof(char*);
|
int expr2_token_equivs_entries = sizeof(expr2_token_equivs1)/sizeof(char*);
|
||||||
|
|
||||||
for (p=mess; *p; p++) {
|
for (p=mess; *p; p++) {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
#define FLEX_SCANNER
|
#define FLEX_SCANNER
|
||||||
#define YY_FLEX_MAJOR_VERSION 2
|
#define YY_FLEX_MAJOR_VERSION 2
|
||||||
#define YY_FLEX_MINOR_VERSION 5
|
#define YY_FLEX_MINOR_VERSION 5
|
||||||
#define YY_FLEX_SUBMINOR_VERSION 35
|
#define YY_FLEX_SUBMINOR_VERSION 34
|
||||||
#if YY_FLEX_SUBMINOR_VERSION > 0
|
#if YY_FLEX_SUBMINOR_VERSION > 0
|
||||||
#define FLEX_BETA
|
#define FLEX_BETA
|
||||||
#endif
|
#endif
|
||||||
@@ -56,6 +56,7 @@ typedef int flex_int32_t;
|
|||||||
typedef unsigned char flex_uint8_t;
|
typedef unsigned char flex_uint8_t;
|
||||||
typedef unsigned short int flex_uint16_t;
|
typedef unsigned short int flex_uint16_t;
|
||||||
typedef unsigned int flex_uint32_t;
|
typedef unsigned int flex_uint32_t;
|
||||||
|
#endif /* ! C99 */
|
||||||
|
|
||||||
/* Limits of integral types. */
|
/* Limits of integral types. */
|
||||||
#ifndef INT8_MIN
|
#ifndef INT8_MIN
|
||||||
@@ -86,8 +87,6 @@ typedef unsigned int flex_uint32_t;
|
|||||||
#define UINT32_MAX (4294967295U)
|
#define UINT32_MAX (4294967295U)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* ! C99 */
|
|
||||||
|
|
||||||
#endif /* ! FLEXINT_H */
|
#endif /* ! FLEXINT_H */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@@ -195,6 +194,13 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE;
|
|||||||
|
|
||||||
#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
|
#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
|
||||||
|
|
||||||
|
/* The following is because we cannot portably get our hands on size_t
|
||||||
|
* (without autoconf's help, which isn't available because we want
|
||||||
|
* flex-generated scanners to compile on their own).
|
||||||
|
* Given that the standard has decreed that size_t exists since 1989,
|
||||||
|
* I guess we can afford to depend on it. Manoj.
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef YY_TYPEDEF_YY_SIZE_T
|
#ifndef YY_TYPEDEF_YY_SIZE_T
|
||||||
#define YY_TYPEDEF_YY_SIZE_T
|
#define YY_TYPEDEF_YY_SIZE_T
|
||||||
typedef size_t yy_size_t;
|
typedef size_t yy_size_t;
|
||||||
@@ -596,7 +602,7 @@ int ast_yyget_column(yyscan_t yyscanner);
|
|||||||
static int curlycount = 0;
|
static int curlycount = 0;
|
||||||
static char *expr2_token_subst(const char *mess);
|
static char *expr2_token_subst(const char *mess);
|
||||||
|
|
||||||
#line 598 "ast_expr2f.c"
|
#line 604 "ast_expr2f.c"
|
||||||
|
|
||||||
#define INITIAL 0
|
#define INITIAL 0
|
||||||
#define var 1
|
#define var 1
|
||||||
@@ -743,7 +749,7 @@ static int input (yyscan_t yyscanner );
|
|||||||
/* This used to be an fputs(), but since the string might contain NUL's,
|
/* This used to be an fputs(), but since the string might contain NUL's,
|
||||||
* we now use fwrite().
|
* we now use fwrite().
|
||||||
*/
|
*/
|
||||||
#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
|
#define ECHO fwrite( yytext, yyleng, 1, yyout )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
|
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
|
||||||
@@ -754,7 +760,7 @@ static int input (yyscan_t yyscanner );
|
|||||||
if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
|
if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
|
||||||
{ \
|
{ \
|
||||||
int c = '*'; \
|
int c = '*'; \
|
||||||
size_t n; \
|
int n; \
|
||||||
for ( n = 0; n < max_size && \
|
for ( n = 0; n < max_size && \
|
||||||
(c = getc( yyin )) != EOF && c != '\n'; ++n ) \
|
(c = getc( yyin )) != EOF && c != '\n'; ++n ) \
|
||||||
buf[n] = (char) c; \
|
buf[n] = (char) c; \
|
||||||
@@ -842,7 +848,7 @@ YY_DECL
|
|||||||
#line 125 "ast_expr2.fl"
|
#line 125 "ast_expr2.fl"
|
||||||
|
|
||||||
|
|
||||||
#line 844 "ast_expr2f.c"
|
#line 850 "ast_expr2f.c"
|
||||||
|
|
||||||
yylval = yylval_param;
|
yylval = yylval_param;
|
||||||
|
|
||||||
@@ -1188,7 +1194,7 @@ YY_RULE_SETUP
|
|||||||
#line 233 "ast_expr2.fl"
|
#line 233 "ast_expr2.fl"
|
||||||
ECHO;
|
ECHO;
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
#line 1190 "ast_expr2f.c"
|
#line 1196 "ast_expr2f.c"
|
||||||
case YY_STATE_EOF(INITIAL):
|
case YY_STATE_EOF(INITIAL):
|
||||||
case YY_STATE_EOF(var):
|
case YY_STATE_EOF(var):
|
||||||
yyterminate();
|
yyterminate();
|
||||||
@@ -1962,8 +1968,8 @@ YY_BUFFER_STATE ast_yy_scan_string (yyconst char * yystr , yyscan_t yyscanner)
|
|||||||
|
|
||||||
/** Setup the input buffer state to scan the given bytes. The next call to ast_yylex() will
|
/** Setup the input buffer state to scan the given bytes. The next call to ast_yylex() will
|
||||||
* scan from a @e copy of @a bytes.
|
* scan from a @e copy of @a bytes.
|
||||||
* @param yybytes the byte buffer to scan
|
* @param bytes the byte buffer to scan
|
||||||
* @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
|
* @param len the number of bytes in the buffer pointed to by @a bytes.
|
||||||
* @param yyscanner The scanner object.
|
* @param yyscanner The scanner object.
|
||||||
* @return the newly allocated buffer state object.
|
* @return the newly allocated buffer state object.
|
||||||
*/
|
*/
|
||||||
@@ -2124,7 +2130,7 @@ void ast_yyset_lineno (int line_number , yyscan_t yyscanner)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Set the current column.
|
/** Set the current column.
|
||||||
* @param column_no
|
* @param line_number
|
||||||
* @param yyscanner The scanner object.
|
* @param yyscanner The scanner object.
|
||||||
*/
|
*/
|
||||||
void ast_yyset_column (int column_no , yyscan_t yyscanner)
|
void ast_yyset_column (int column_no , yyscan_t yyscanner)
|
||||||
@@ -2379,10 +2385,10 @@ int ast_yyerror(const char *, YYLTYPE *, struct parse_io *); /* likewise */
|
|||||||
|
|
||||||
void ast_yyfree(void *ptr, yyscan_t yyscanner)
|
void ast_yyfree(void *ptr, yyscan_t yyscanner)
|
||||||
{
|
{
|
||||||
/* the normal generated ast_yyfree func just frees its first arg;
|
/* the normal generated ast_yyfree func just frees its first arg;
|
||||||
this get complaints on some systems, as sometimes this
|
this get complaints on some systems, as sometimes this
|
||||||
arg is a nil ptr! It's usually not fatal, but is irritating! */
|
arg is a nil ptr! It's usually not fatal, but is irritating! */
|
||||||
free( (char *) ptr );
|
free( (char *) ptr );
|
||||||
}
|
}
|
||||||
|
|
||||||
int ast_expr(char *expr, char *buf, int length, struct ast_channel *chan)
|
int ast_expr(char *expr, char *buf, int length, struct ast_channel *chan)
|
||||||
@@ -2391,8 +2397,11 @@ int ast_expr(char *expr, char *buf, int length, struct ast_channel *chan)
|
|||||||
int return_value = 0;
|
int return_value = 0;
|
||||||
|
|
||||||
ast_yylex_init(&io.scanner);
|
ast_yylex_init(&io.scanner);
|
||||||
|
|
||||||
ast_yy_scan_string(expr, io.scanner);
|
ast_yy_scan_string(expr, io.scanner);
|
||||||
|
|
||||||
ast_yyparse ((void *) &io);
|
ast_yyparse ((void *) &io);
|
||||||
|
|
||||||
ast_yylex_destroy(io.scanner);
|
ast_yylex_destroy(io.scanner);
|
||||||
|
|
||||||
if (!io.val) {
|
if (!io.val) {
|
||||||
@@ -2423,7 +2432,7 @@ int ast_expr(char *expr, char *buf, int length, struct ast_channel *chan)
|
|||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(STANDALONE)
|
#ifndef STANDALONE
|
||||||
int ast_str_expr(struct ast_str **str, ssize_t maxlen, struct ast_channel *chan, char *expr)
|
int ast_str_expr(struct ast_str **str, ssize_t maxlen, struct ast_channel *chan, char *expr)
|
||||||
{
|
{
|
||||||
struct parse_io io = { .string = expr, .chan = chan };
|
struct parse_io io = { .string = expr, .chan = chan };
|
||||||
@@ -2467,7 +2476,7 @@ void ast_expr_clear_extra_error_info(void)
|
|||||||
extra_error_message[0] = 0;
|
extra_error_message[0] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *expr2_token_equivs1[] =
|
static const char * const expr2_token_equivs1[] =
|
||||||
{
|
{
|
||||||
"TOKEN",
|
"TOKEN",
|
||||||
"TOK_COND",
|
"TOK_COND",
|
||||||
@@ -2493,7 +2502,7 @@ static char *expr2_token_equivs1[] =
|
|||||||
"TOK_LP"
|
"TOK_LP"
|
||||||
};
|
};
|
||||||
|
|
||||||
static char *expr2_token_equivs2[] =
|
static const char * const expr2_token_equivs2[] =
|
||||||
{
|
{
|
||||||
"<token>",
|
"<token>",
|
||||||
"?",
|
"?",
|
||||||
@@ -2525,7 +2534,8 @@ static char *expr2_token_subst(const char *mess)
|
|||||||
/* calc a length, malloc, fill, and return; yyerror had better free it! */
|
/* calc a length, malloc, fill, and return; yyerror had better free it! */
|
||||||
int len=0,i;
|
int len=0,i;
|
||||||
const char *p;
|
const char *p;
|
||||||
char *res, *s,*t;
|
char *res, *s;
|
||||||
|
const char *t;
|
||||||
int expr2_token_equivs_entries = sizeof(expr2_token_equivs1)/sizeof(char*);
|
int expr2_token_equivs_entries = sizeof(expr2_token_equivs1)/sizeof(char*);
|
||||||
|
|
||||||
for (p=mess; *p; p++) {
|
for (p=mess; *p; p++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user