Ian Jackson
2011-Jan-11 15:44 UTC
[Xen-devel] [PATCH 0/3] libxl: config parser: warn about arbitrary python
In this series we arrange to print a special warning about things in xl config files which look like arbitrary python code. There are three small patches: 1/3 Fix an unrelated bug which can cause a segfault if config parsing fails 2/3 Move some boilerplate code into subfunctions 3/3 Add the new functionality to the lexer and to those subfunctions _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Jackson
2011-Jan-11 15:45 UTC
[Xen-devel] [PATCH 1/3] libxl: config parser: do not segfault in some error paths
In error paths, xlu__cfg_set_free can be called on NULL. So check for that rather than segfaulting. Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com> --- tools/libxl/libxlu_cfg.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/tools/libxl/libxlu_cfg.c b/tools/libxl/libxlu_cfg.c index 864a723..1ade7ea 100644 --- a/tools/libxl/libxlu_cfg.c +++ b/tools/libxl/libxlu_cfg.c @@ -93,6 +93,7 @@ int xlu_cfg_readdata(XLU_Config *cfg, const char *data, int length) { void xlu__cfg_set_free(XLU_ConfigSetting *set) { int i; + if (!set) return; free(set->name); for (i=0; i<set->nvalues; i++) free(set->values[i]); -- 1.5.6.5 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Jackson
2011-Jan-11 15:45 UTC
[Xen-devel] [PATCH 2/3] libxl: config parser: make CfgParseContext initialisation common
xlu_cfg_readfile and xlu_cfg_readdata had some somewhat-boilerplate code for initialisation, parsing, and cleanup. Make that common. No functional change. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> --- tools/libxl/libxlu_cfg.c | 82 ++++++++++++++++++++++++-------------------- tools/libxl/libxlu_cfg_l.c | 30 ++++++++++++---- tools/libxl/libxlu_cfg_l.h | 18 ++++++++- 3 files changed, 83 insertions(+), 47 deletions(-) diff --git a/tools/libxl/libxlu_cfg.c b/tools/libxl/libxlu_cfg.c index 1ade7ea..821b8c0 100644 --- a/tools/libxl/libxlu_cfg.c +++ b/tools/libxl/libxlu_cfg.c @@ -18,59 +18,68 @@ XLU_Config *xlu_cfg_init(FILE *report, const char *report_filename) { return cfg; } +static int ctx_prep(CfgParseContext *ctx, XLU_Config *cfg) { + int e; + + ctx->cfg= cfg; + ctx->err= 0; + ctx->lexerrlineno= -1; + ctx->scanner= 0; + + e= xlu__cfg_yylex_init_extra(ctx, &ctx->scanner); + if (e) { + fprintf(cfg->report,"%s: unable to create scanner: %s\n", + cfg->filename, strerror(e)); + return e; + } + return 0; +} + +static void ctx_dispose(CfgParseContext *ctx) { + if (ctx->scanner) xlu__cfg_yylex_destroy(ctx->scanner); +} + +static void parse(CfgParseContext *ctx) { + /* On return, ctx.err will be updated with the error status. */ + int r; + r= xlu__cfg_yyparse(ctx); + if (r) assert(ctx->err); +} + int xlu_cfg_readfile(XLU_Config *cfg, const char *real_filename) { + FILE *f = 0; + int e; + CfgParseContext ctx; - FILE *f; - int e, r; + e = ctx_prep(&ctx, cfg); + if (e) { ctx.err= e; goto xe; } - ctx.cfg= cfg; - ctx.err= 0; - ctx.lexerrlineno= -1; - f= fopen(real_filename, "r"); if (!f) { - e= errno; + ctx.err = errno; fprintf(cfg->report,"%s: unable to open configuration file: %s\n", real_filename, strerror(e)); - return e; - } - - e= xlu__cfg_yylex_init_extra(&ctx, &ctx.scanner); - if (e) { - fprintf(cfg->report,"%s: unable to create scanner: %s\n", - cfg->filename, strerror(e)); - return e; + goto xe; } xlu__cfg_yyrestart(f, ctx.scanner); - r= xlu__cfg_yyparse(&ctx); - if (r) assert(ctx.err); + parse(&ctx); - xlu__cfg_yylex_destroy(ctx.scanner); - fclose(f); + xe: + ctx_dispose(&ctx); + if (f) fclose(f); return ctx.err; } int xlu_cfg_readdata(XLU_Config *cfg, const char *data, int length) { - CfgParseContext ctx; - int e, r; + int e; YY_BUFFER_STATE buf= 0; - ctx.scanner= 0; - ctx.cfg= cfg; - ctx.err= 0; - ctx.lexerrlineno= -1; - - e= xlu__cfg_yylex_init_extra(&ctx, &ctx.scanner); - if (e) { - fprintf(cfg->report,"%s: unable to create scanner: %s\n", - cfg->filename, strerror(e)); - ctx.err= e; - ctx.scanner= 0; - goto xe; - } + CfgParseContext ctx; + e= ctx_prep(&ctx, cfg); + if (e) { ctx.err= e; goto xe; } buf = xlu__cfg_yy_scan_bytes(data, length, ctx.scanner); if (!buf) { @@ -80,12 +89,11 @@ int xlu_cfg_readdata(XLU_Config *cfg, const char *data, int length) { goto xe; } - r= xlu__cfg_yyparse(&ctx); - if (r) assert(ctx.err); + parse(&ctx); xe: if (buf) xlu__cfg_yy_delete_buffer(buf, ctx.scanner); - if (ctx.scanner) xlu__cfg_yylex_destroy(ctx.scanner); + ctx_dispose(&ctx); return ctx.err; } diff --git a/tools/libxl/libxlu_cfg_l.c b/tools/libxl/libxlu_cfg_l.c index e1078f1..917a156 100644 --- a/tools/libxl/libxlu_cfg_l.c +++ b/tools/libxl/libxlu_cfg_l.c @@ -54,7 +54,6 @@ typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; -#endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN @@ -85,6 +84,8 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif +#endif /* ! C99 */ + #endif /* ! FLEXINT_H */ #ifdef __cplusplus @@ -158,7 +159,15 @@ typedef void* yyscan_t; /* Size of default input buffer. */ #ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else #define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ #endif /* The state buf must be large enough to hold one state per character in the main buffer. @@ -487,7 +496,7 @@ int xlu__cfg_yyget_column(yyscan_t yyscanner); void xlu__cfg_yyset_column(int column_no, yyscan_t yyscanner); -#line 491 "libxlu_cfg_l.c" +#line 500 "libxlu_cfg_l.c" #define INITIAL 0 #define lexerr 1 @@ -623,7 +632,12 @@ static int input (yyscan_t yyscanner ); /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else #define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ #endif /* Copy whatever the last rule matched to the standard output. */ @@ -631,7 +645,7 @@ static int input (yyscan_t yyscanner ); /* This used to be an fputs(), but since the string might contain NUL''s, * we now use fwrite(). */ -#define ECHO fwrite( yytext, yyleng, 1, yyout ) +#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, @@ -642,7 +656,7 @@ static int input (yyscan_t yyscanner ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = ''*''; \ - int n; \ + size_t n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != ''\n''; ++n ) \ buf[n] = (char) c; \ @@ -730,7 +744,7 @@ YY_DECL #line 37 "libxlu_cfg_l.l" -#line 734 "libxlu_cfg_l.c" +#line 748 "libxlu_cfg_l.c" yylval = yylval_param; @@ -930,7 +944,7 @@ YY_RULE_SETUP #line 82 "libxlu_cfg_l.l" YY_FATAL_ERROR( "flex scanner jammed" ); YY_BREAK -#line 934 "libxlu_cfg_l.c" +#line 948 "libxlu_cfg_l.c" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(lexerr): yyterminate(); @@ -1673,8 +1687,8 @@ YY_BUFFER_STATE xlu__cfg_yy_scan_string (yyconst char * yystr , yyscan_t yyscann /** Setup the input buffer state to scan the given bytes. The next call to xlu__cfg_yylex() will * scan from a @e copy of @a bytes. - * @param bytes the byte buffer to scan - * @param len the number of bytes in the buffer pointed to by @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ diff --git a/tools/libxl/libxlu_cfg_l.h b/tools/libxl/libxlu_cfg_l.h index 3dd1215..26f6dd6 100644 --- a/tools/libxl/libxlu_cfg_l.h +++ b/tools/libxl/libxlu_cfg_l.h @@ -58,7 +58,6 @@ typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; -#endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN @@ -89,6 +88,8 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif +#endif /* ! C99 */ + #endif /* ! FLEXINT_H */ #ifdef __cplusplus @@ -131,7 +132,15 @@ typedef void* yyscan_t; /* Size of default input buffer. */ #ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else #define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ #endif #ifndef YY_TYPEDEF_YY_BUFFER_STATE @@ -301,7 +310,12 @@ static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else #define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ #endif /* Number of entries by which start-condition stack grows. */ @@ -338,6 +352,6 @@ extern int xlu__cfg_yylex \ #line 82 "libxlu_cfg_l.l" -#line 342 "libxlu_cfg_l.h" +#line 356 "libxlu_cfg_l.h" #undef xlu__cfg_yyIN_HEADER #endif /* xlu__cfg_yyHEADER_H */ -- 1.5.6.5 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Jackson
2011-Jan-11 15:45 UTC
[Xen-devel] [PATCH 3/3] libxl: config parser: print warning for apparent arbitrary python
The characters - + . ( ) : are not legal in xl config files but are valid Python and use of at least one of them is almost essential for writing arbitrary Python in the config file. So if we see one of these during lexing, note it, and then after the parse is complete if it failed we print a special extra warning. Currently this warning refers to the nonexistent wiki page http://wiki.xen.org/xenwiki/PythonInXlConfig which will have to be written (and/or given a better name) before the actual 4.1 release. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> --- tools/libxl/libxlu_cfg.c | 9 +++ tools/libxl/libxlu_cfg_i.h | 2 + tools/libxl/libxlu_cfg_l.c | 129 ++++++++++++++++++++++------------------- tools/libxl/libxlu_cfg_l.h | 2 +- tools/libxl/libxlu_cfg_l.l | 6 ++ tools/libxl/libxlu_internal.h | 2 +- 6 files changed, 89 insertions(+), 61 deletions(-) diff --git a/tools/libxl/libxlu_cfg.c b/tools/libxl/libxlu_cfg.c index 821b8c0..663fdf9 100644 --- a/tools/libxl/libxlu_cfg.c +++ b/tools/libxl/libxlu_cfg.c @@ -24,6 +24,7 @@ static int ctx_prep(CfgParseContext *ctx, XLU_Config *cfg) { ctx->cfg= cfg; ctx->err= 0; ctx->lexerrlineno= -1; + ctx->likely_python= 0; ctx->scanner= 0; e= xlu__cfg_yylex_init_extra(ctx, &ctx->scanner); @@ -44,6 +45,14 @@ static void parse(CfgParseContext *ctx) { int r; r= xlu__cfg_yyparse(ctx); if (r) assert(ctx->err); + + if (ctx->err && ctx->likely_python) { + fputs( + "warning: Config file looks like it contains Python code.\n" + "warning: Arbitrary Python is no longer supported.\n" + "warning: See http://wiki.xen.org/xenwiki/PythonInXlConfig\n", + ctx->cfg->report); + } } int xlu_cfg_readfile(XLU_Config *cfg, const char *real_filename) { diff --git a/tools/libxl/libxlu_cfg_i.h b/tools/libxl/libxlu_cfg_i.h index f6b241c..88d2a02 100644 --- a/tools/libxl/libxlu_cfg_i.h +++ b/tools/libxl/libxlu_cfg_i.h @@ -16,6 +16,8 @@ char *xlu__cfgl_dequote(CfgParseContext*, const char *src); void xlu__cfg_yyerror(YYLTYPE *locp, CfgParseContext*, char const *msg); void xlu__cfgl_lexicalerror(CfgParseContext*, char const *msg); +void xlu__cfgl_likely_python(CfgParseContext *ctx); + /* Why oh why does bison not declare this in its autogenerated .h ? */ diff --git a/tools/libxl/libxlu_cfg_l.c b/tools/libxl/libxlu_cfg_l.c index 917a156..e063461 100644 --- a/tools/libxl/libxlu_cfg_l.c +++ b/tools/libxl/libxlu_cfg_l.c @@ -370,8 +370,8 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); *yy_cp = ''\0''; \ yyg->yy_c_buf_p = yy_cp; -#define YY_NUM_RULES 15 -#define YY_END_OF_BUFFER 16 +#define YY_NUM_RULES 16 +#define YY_END_OF_BUFFER 17 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -379,12 +379,12 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[34] +static yyconst flex_int16_t yy_accept[35] { 0, - 0, 0, 13, 13, 16, 12, 3, 9, 12, 12, - 12, 4, 2, 8, 7, 5, 6, 1, 13, 13, - 14, 0, 11, 0, 0, 9, 0, 10, 0, 2, - 1, 13, 0 + 0, 0, 14, 14, 17, 13, 3, 9, 13, 13, + 13, 12, 4, 2, 8, 7, 5, 6, 1, 14, + 14, 15, 0, 11, 0, 0, 9, 0, 10, 0, + 2, 1, 14, 0 } ; static yyconst flex_int32_t yy_ec[256] @@ -392,17 +392,17 @@ static yyconst flex_int32_t yy_ec[256] 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 1, 4, 5, 1, 1, 1, 6, 1, - 1, 1, 1, 7, 1, 1, 1, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 1, 9, 1, - 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 4, 5, 1, 1, 1, 6, 7, + 7, 1, 7, 8, 7, 7, 1, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 7, 10, 1, + 11, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 11, 12, 13, 1, 14, 1, 15, 15, 15, 15, + 12, 13, 14, 1, 15, 1, 16, 16, 16, 16, - 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, - 16, 16, 1, 1, 1, 1, 1, 1, 1, 1, + 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 16, + 17, 17, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -419,54 +419,56 @@ static yyconst flex_int32_t yy_ec[256] 1, 1, 1, 1, 1 } ; -static yyconst flex_int32_t yy_meta[17] +static yyconst flex_int32_t yy_meta[18] { 0, - 1, 2, 3, 1, 1, 1, 1, 4, 1, 1, - 1, 1, 1, 4, 4, 4 + 1, 2, 3, 1, 1, 1, 1, 1, 4, 1, + 1, 1, 1, 1, 4, 4, 4 } ; -static yyconst flex_int16_t yy_base[40] +static yyconst flex_int16_t yy_base[41] { 0, - 0, 0, 15, 17, 51, 54, 54, 54, 17, 45, - 16, 54, 15, 54, 54, 54, 54, 0, 0, 54, - 54, 20, 54, 0, 37, 54, 19, 54, 0, 18, - 0, 0, 54, 33, 37, 41, 45, 23, 49 + 0, 0, 16, 18, 50, 56, 56, 56, 18, 39, + 17, 56, 56, 16, 56, 56, 56, 56, 0, 0, + 56, 56, 20, 56, 0, 26, 56, 21, 56, 0, + 19, 0, 0, 56, 35, 39, 43, 47, 22, 51 } ; -static yyconst flex_int16_t yy_def[40] +static yyconst flex_int16_t yy_def[41] { 0, - 33, 1, 34, 34, 33, 33, 33, 33, 35, 36, - 37, 33, 33, 33, 33, 33, 33, 38, 39, 33, - 33, 35, 33, 35, 36, 33, 37, 33, 37, 33, - 38, 39, 0, 33, 33, 33, 33, 33, 33 + 34, 1, 35, 35, 34, 34, 34, 34, 36, 37, + 38, 34, 34, 34, 34, 34, 34, 34, 39, 40, + 34, 34, 36, 34, 36, 37, 34, 38, 34, 38, + 34, 39, 40, 0, 34, 34, 34, 34, 34, 34 } ; -static yyconst flex_int16_t yy_nxt[71] +static yyconst flex_int16_t yy_nxt[74] { 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 6, 17, 6, 18, 18, 20, 21, 20, 21, - 23, 28, 30, 23, 28, 30, 31, 29, 24, 30, - 29, 24, 30, 19, 19, 19, 19, 22, 22, 26, - 22, 25, 25, 25, 25, 27, 27, 26, 27, 32, - 33, 33, 32, 5, 33, 33, 33, 33, 33, 33, - 33, 33, 33, 33, 33, 33, 33, 33, 33, 33 + 16, 17, 6, 18, 6, 19, 19, 21, 22, 21, + 22, 24, 29, 24, 31, 32, 29, 31, 27, 30, + 25, 31, 25, 30, 31, 20, 20, 20, 20, 23, + 23, 27, 23, 26, 26, 26, 26, 28, 28, 34, + 28, 33, 34, 34, 33, 5, 34, 34, 34, 34, + 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, + 34, 34, 34 } ; -static yyconst flex_int16_t yy_chk[71] +static yyconst flex_int16_t yy_chk[74] { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 3, 3, 4, 4, - 9, 11, 13, 22, 27, 30, 38, 11, 9, 13, - 27, 22, 30, 34, 34, 34, 34, 35, 35, 25, - 35, 36, 36, 36, 36, 37, 37, 10, 37, 39, - 5, 0, 39, 33, 33, 33, 33, 33, 33, 33, - 33, 33, 33, 33, 33, 33, 33, 33, 33, 33 + 1, 1, 1, 1, 1, 1, 1, 3, 3, 4, + 4, 9, 11, 23, 14, 39, 28, 31, 26, 11, + 9, 14, 23, 28, 31, 35, 35, 35, 35, 36, + 36, 10, 36, 37, 37, 37, 37, 38, 38, 5, + 38, 40, 0, 0, 40, 34, 34, 34, 34, 34, + 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, + 34, 34, 34 } ; /* Table of booleans, true if rule could match eol. */ -static yyconst flex_int32_t yy_rule_can_match_eol[16] +static yyconst flex_int32_t yy_rule_can_match_eol[17] { 0, -0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, }; +0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, }; /* The intent behind this definition is that it''ll catch * any uses of REJECT which flex missed. @@ -496,7 +498,7 @@ int xlu__cfg_yyget_column(yyscan_t yyscanner); void xlu__cfg_yyset_column(int column_no, yyscan_t yyscanner); -#line 500 "libxlu_cfg_l.c" +#line 502 "libxlu_cfg_l.c" #define INITIAL 0 #define lexerr 1 @@ -744,7 +746,7 @@ YY_DECL #line 37 "libxlu_cfg_l.l" -#line 748 "libxlu_cfg_l.c" +#line 750 "libxlu_cfg_l.c" yylval = yylval_param; @@ -807,13 +809,13 @@ yy_match: while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 34 ) + if ( yy_current_state >= 35 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } - while ( yy_current_state != 33 ); + while ( yy_current_state != 34 ); yy_cp = yyg->yy_last_accepting_cpos; yy_current_state = yyg->yy_last_accepting_state; @@ -917,34 +919,43 @@ case 12: YY_RULE_SETUP #line 67 "libxlu_cfg_l.l" { + ctx->likely_python= 1; BEGIN(lexerr); yymore(); } YY_BREAK case 13: YY_RULE_SETUP -#line 72 "libxlu_cfg_l.l" +#line 73 "libxlu_cfg_l.l" +{ + BEGIN(lexerr); + yymore(); + } + YY_BREAK +case 14: +YY_RULE_SETUP +#line 78 "libxlu_cfg_l.l" { xlu__cfgl_lexicalerror(ctx,"lexical error"); BEGIN(0); } YY_BREAK -case 14: -/* rule 14 can match eol */ +case 15: +/* rule 15 can match eol */ YY_RULE_SETUP -#line 77 "libxlu_cfg_l.l" +#line 83 "libxlu_cfg_l.l" { xlu__cfgl_lexicalerror(ctx,"lexical error"); BEGIN(0); GOT(NEWLINE); } YY_BREAK -case 15: +case 16: YY_RULE_SETUP -#line 82 "libxlu_cfg_l.l" +#line 88 "libxlu_cfg_l.l" YY_FATAL_ERROR( "flex scanner jammed" ); YY_BREAK -#line 948 "libxlu_cfg_l.c" +#line 959 "libxlu_cfg_l.c" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(lexerr): yyterminate(); @@ -1240,7 +1251,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 34 ) + if ( yy_current_state >= 35 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; @@ -1269,11 +1280,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 34 ) + if ( yy_current_state >= 35 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 33); + yy_is_jam = (yy_current_state == 34); return yy_is_jam ? 0 : yy_current_state; } @@ -2094,4 +2105,4 @@ void xlu__cfg_yyfree (void * ptr , yyscan_t yyscanner) #define YYTABLES_NAME "yytables" -#line 82 "libxlu_cfg_l.l" +#line 88 "libxlu_cfg_l.l" diff --git a/tools/libxl/libxlu_cfg_l.h b/tools/libxl/libxlu_cfg_l.h index 26f6dd6..02a0803 100644 --- a/tools/libxl/libxlu_cfg_l.h +++ b/tools/libxl/libxlu_cfg_l.h @@ -350,7 +350,7 @@ extern int xlu__cfg_yylex \ #undef YY_DECL #endif -#line 82 "libxlu_cfg_l.l" +#line 88 "libxlu_cfg_l.l" #line 356 "libxlu_cfg_l.h" #undef xlu__cfg_yyIN_HEADER diff --git a/tools/libxl/libxlu_cfg_l.l b/tools/libxl/libxlu_cfg_l.l index ac6b011..21c11ff 100644 --- a/tools/libxl/libxlu_cfg_l.l +++ b/tools/libxl/libxlu_cfg_l.l @@ -64,6 +64,12 @@ void xlu__cfg_yyset_column(int column_no, yyscan_t yyscanner); GOT(STRING); } +[+-.():] { + ctx->likely_python= 1; + BEGIN(lexerr); + yymore(); + } + . { BEGIN(lexerr); yymore(); diff --git a/tools/libxl/libxlu_internal.h b/tools/libxl/libxlu_internal.h index fd7addc..e251a63 100644 --- a/tools/libxl/libxlu_internal.h +++ b/tools/libxl/libxlu_internal.h @@ -41,7 +41,7 @@ struct XLU_Config { typedef struct { XLU_Config *cfg; - int err, lexerrlineno; + int err, lexerrlineno, likely_python; void *scanner; } CfgParseContext; -- 1.5.6.5 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Jackson
2011-Jan-11 15:50 UTC
[Xen-devel] Re: [PATCH 2/3] libxl: config parser: make CfgParseContext initialisation common
Ian Jackson writes ("[PATCH 2/3] libxl: config parser: make CfgParseContext initialisation common"):> xlu_cfg_readfile and xlu_cfg_readdata had some somewhat-boilerplate > code for initialisation, parsing, and cleanup. Make that common.This patch mistakenly includes changes to libxlu_cfg_l.[ch] which are due purely to rerunning flex. I did wonder what had become of them. If this patchset gets suitable acks I will apply these> tools/libxl/libxlu_cfg_l.c | 30 ++++++++++++---- > tools/libxl/libxlu_cfg_l.h | 18 ++++++++-hunks as a separate commit. That way the patch 3/3 (or 4/4 if you prefer) contains only changes to libxlu_cfg.[ch] which are actually due to the change to libxl_cfg_l.l. Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel