From: Rémi Bernon rbernon@codeweavers.com
--- tools/widl/parser.h | 9 +++++--- tools/widl/parser.l | 51 ++++++++++++++++++++++++++++++++++++++++++ tools/widl/parser.y | 10 ++------- tools/widl/utils.c | 45 ++----------------------------------- tools/widl/utils.h | 2 +- tools/widl/widl.c | 2 -- tools/widl/widl.h | 3 --- tools/widl/widltypes.h | 2 -- 8 files changed, 62 insertions(+), 62 deletions(-)
diff --git a/tools/widl/parser.h b/tools/widl/parser.h index 81418fca160..6111193561f 100644 --- a/tools/widl/parser.h +++ b/tools/widl/parser.h @@ -21,16 +21,19 @@ #ifndef __WIDL_PARSER_H #define __WIDL_PARSER_H
+#include "widltypes.h" + int parser_parse(void);
+extern void generic_msg( const struct location *where, const char *s, const char *t, va_list ap ); +extern void parser_error( const char *message ); +extern void init_location( struct location *where ); + extern FILE *parser_in; -extern char *parser_text; extern int parser_debug; extern int yy_flex_debug;
extern int parse_only; -void push_import( char *import_name ); -void pop_import(void);
int is_type(const char *name);
diff --git a/tools/widl/parser.l b/tools/widl/parser.l index 9fc6a10c501..a89e9cc00b9 100644 --- a/tools/widl/parser.l +++ b/tools/widl/parser.l @@ -78,6 +78,7 @@ struct import struct list entry; }; static struct list imports = LIST_INIT( imports ); +static int line_number = 1;
/* converts an integer in string form to an unsigned long and prints an error * on overflow */ @@ -511,6 +512,56 @@ static void switch_to_acf(void) yy_switch_to_buffer( yy_create_buffer( file, YY_BUF_SIZE ) ); }
+#define CURRENT_LOCATION { input_name ? input_name : "stdin", parser_text, line_number, 0, line_number, 0 } + +static const int want_near_indication = 0; + +static void make_print(char *str) +{ + while(*str) + { + if(!isprint(*str)) + *str = ' '; + str++; + } +} + +void init_location( struct location *where ) +{ + where->input_name = input_name ? input_name : "stdin"; + where->near_text = parser_text; + where->first_line = line_number; + where->last_line = line_number; +} + +void generic_msg( const struct location *where, const char *s, const char *t, va_list ap ) +{ + struct location cur_loc = CURRENT_LOCATION; + + if (!where) where = &cur_loc; + + fprintf( stderr, "%s:%d: %s: ", where->input_name, where->first_line, t ); + vfprintf( stderr, s, ap ); + + if (want_near_indication) + { + char *cpy; + if (where->near_text) + { + cpy = xstrdup( where->near_text ); + make_print( cpy ); + fprintf( stderr, " near '%s'", cpy ); + free( cpy ); + } + } +} + +/* yyerror: yacc assumes this is not newline terminated. */ +void parser_error( const char *message ) +{ + error_loc( "%s\n", message ); +} + static void warning_disable(int warning) { warning_t *warning_entry; diff --git a/tools/widl/parser.y b/tools/widl/parser.y index 5b45c000163..97ee48cbfa7 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -125,6 +125,8 @@ static typelib_t *current_typelib; {
int parser_lex( PARSER_STYPE *yylval ); +void push_import( char *input_name ); +void pop_import(void);
}
@@ -3389,14 +3391,6 @@ static statement_list_t *append_statement(statement_list_t *list, statement_t *s return list; }
-void init_location( struct location *where ) -{ - where->input_name = input_name ? input_name : "stdin"; - where->near_text = parser_text; - where->first_line = line_number; - where->last_line = line_number; -} - type_t *find_parameterized_type(type_t *type, typeref_list_t *params) { char *name = format_parameterized_type_name(type, params); diff --git a/tools/widl/utils.c b/tools/widl/utils.c index 979851e1b44..987301d1585 100644 --- a/tools/widl/utils.c +++ b/tools/widl/utils.c @@ -32,51 +32,11 @@ #include "utils.h" #include "parser.h"
-#define CURRENT_LOCATION { input_name ? input_name : "stdin", parser_text, line_number, 0, line_number, 0 } - -static const int want_near_indication = 0; - -static void make_print(char *str) -{ - while(*str) - { - if(!isprint(*str)) - *str = ' '; - str++; - } -} - -static void generic_msg( const struct location *where, const char *s, const char *t, va_list ap ) -{ - fprintf( stderr, "%s:%d: %s: ", where->input_name, where->first_line, t ); - vfprintf( stderr, s, ap ); - - if (want_near_indication) - { - char *cpy; - if (where->near_text) - { - cpy = xstrdup( where->near_text ); - make_print( cpy ); - fprintf( stderr, " near '%s'", cpy ); - free( cpy ); - } - } -} - - -/* yyerror: yacc assumes this is not newline terminated. */ -void parser_error(const char *s) -{ - error_loc("%s\n", s); -} - void error_at( const struct location *where, const char *s, ... ) { - struct location cur_loc = CURRENT_LOCATION; va_list ap; va_start( ap, s ); - generic_msg( where ? where : &cur_loc, s, "error", ap ); + generic_msg( where, s, "error", ap ); va_end( ap ); exit( 1 ); } @@ -102,10 +62,9 @@ void warning(const char *s, ...)
void warning_at( const struct location *where, const char *s, ... ) { - struct location cur_loc = CURRENT_LOCATION; va_list ap; va_start( ap, s ); - generic_msg( where ? where : &cur_loc, s, "warning", ap ); + generic_msg( where, s, "warning", ap ); va_end( ap ); }
diff --git a/tools/widl/utils.h b/tools/widl/utils.h index 0196dce95fd..2a6bc7d7930 100644 --- a/tools/widl/utils.h +++ b/tools/widl/utils.h @@ -22,8 +22,8 @@ #define __WIDL_UTILS_H
#include "widltypes.h" +#include "parser.h"
-void parser_error(const char *s) __attribute__((noreturn)); void error(const char *s, ...) __attribute__((format (printf, 1, 2))) __attribute__((noreturn)); void error_at( const struct location *, const char *s, ... ) __attribute__((format( printf, 2, 3 ))) __attribute__((noreturn)); #define error_loc( ... ) error_at( NULL, ## __VA_ARGS__ ) diff --git a/tools/widl/widl.c b/tools/widl/widl.c index 2cb1b59ac45..5bbaeb970fb 100644 --- a/tools/widl/widl.c +++ b/tools/widl/widl.c @@ -140,8 +140,6 @@ static struct strarray dlldirs; static char *output_name; static const char *sysroot = "";
-int line_number = 1; - static FILE *idfile;
unsigned int pointer_size = 0; diff --git a/tools/widl/widl.h b/tools/widl/widl.h index c63882108a8..a816ec2bb46 100644 --- a/tools/widl/widl.h +++ b/tools/widl/widl.h @@ -72,9 +72,6 @@ extern const char *prefix_server; extern unsigned int pointer_size; extern time_t now;
-extern int line_number; -extern int char_number; - enum stub_mode { MODE_Os, /* inline stubs */ diff --git a/tools/widl/widltypes.h b/tools/widl/widltypes.h index 4311811f051..c3371e66871 100644 --- a/tools/widl/widltypes.h +++ b/tools/widl/widltypes.h @@ -656,8 +656,6 @@ type_t *reg_type(type_t *type, const char *name, struct namespace *namespace, in var_t *make_var(char *name); var_list_t *append_var(var_list_t *list, var_t *var);
-void init_location( struct location * ); - char *format_namespace(struct namespace *namespace, const char *prefix, const char *separator, const char *suffix, const char *abi_prefix); char *format_parameterized_type_name(type_t *type, typeref_list_t *params);