Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
3149d272
Commit
3149d272
authored
Mar 23, 2023
by
Rémi Bernon
Committed by
Alexandre Julliard
Mar 23, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
widl: Print the import stack and context in messages.
parent
472b2eca
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
32 deletions
+52
-32
parser.h
tools/widl/parser.h
+1
-1
parser.l
tools/widl/parser.l
+41
-28
utils.c
tools/widl/utils.c
+10
-2
widltypes.h
tools/widl/widltypes.h
+0
-1
No files found.
tools/widl/parser.h
View file @
3149d272
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
int
parser_parse
(
void
);
int
parser_parse
(
void
);
extern
void
generic_msg
(
const
struct
location
*
where
,
const
char
*
s
,
const
char
*
t
,
va_list
ap
);
extern
void
parser_warning
(
const
struct
location
*
where
,
const
char
*
message
);
extern
void
parser_error
(
const
struct
location
*
where
,
const
char
*
message
);
extern
void
parser_error
(
const
struct
location
*
where
,
const
char
*
message
);
extern
void
init_location
(
struct
location
*
copy
,
const
struct
location
*
begin
,
const
struct
location
*
end
);
extern
void
init_location
(
struct
location
*
copy
,
const
struct
location
*
begin
,
const
struct
location
*
end
);
...
...
tools/widl/parser.l
View file @
3149d272
...
@@ -461,6 +461,22 @@ SAFEARRAY{ws}*/\( return tSAFEARRAY;
...
@@ -461,6 +461,22 @@ SAFEARRAY{ws}*/\( return tSAFEARRAY;
}
}
%%
%%
static void print_imports(void)
{
struct import_state *state, *next;
if (list_empty( &import_stack )) return;
fprintf( stderr, "In file included from " );
LIST_FOR_EACH_ENTRY_SAFE_REV( state, next, &import_stack, struct import_state, entry )
{
if (&next->entry == &import_stack) break;
fprintf( stderr, "%s:%d,\n", state->input_name, state->where.first_line );
fprintf( stderr, " from ");
}
fprintf( stderr, "%s:%d:\n", state->input_name, state->where.first_line );
}
void pop_import( struct location *where )
void pop_import( struct location *where )
{
{
struct list *entry = list_head( &import_stack );
struct list *entry = list_head( &import_stack );
...
@@ -551,18 +567,6 @@ static void end_of_line( struct location *where )
...
@@ -551,18 +567,6 @@ static void end_of_line( struct location *where )
where->last_column = 1;
where->last_column = 1;
}
}
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, const struct location *begin, const struct location *end )
void init_location( struct location *where, const struct location *begin, const struct location *end )
{
{
if (!begin) begin = &previous_location;
if (!begin) begin = &previous_location;
...
@@ -580,30 +584,39 @@ void init_location( struct location *where, const struct location *begin, const
...
@@ -580,30 +584,39 @@ void init_location( struct location *where, const struct location *begin, const
}
}
}
}
void generic_msg( const struct location *where, const char *s, const char *t, va_list ap
)
static void diagnostic( const struct location *where, const char *type, const char *message
)
{
{
char buffer[1024], *line = NULL;
FILE *file;
int i;
if (!where) where = &previous_location;
if (!where) where = &previous_location;
fprintf( stderr, "%s:%d: %s: ", where->input_name, where->first_line, t );
print_imports();
vfprintf( stderr, s, ap );
if (want_near_indication)
fprintf( stderr, "%s:%d:%d: %s: %s\n", where->input_name, where->first_line, where->first_column, type, message );
{
char *cpy;
if (!where->input_name || !(file = fopen( where->input_name, "r" ))) return;
if (where->near_text)
for (i = 0; i < where->first_line; i++) if (!(line = fgets( buffer, sizeof(buffer), file ))) break;
{
fclose( file );
cpy = xstrdup( where->near_text );
if (!line) return;
make_print( cpy );
fprintf( stderr, "%s", line );
fprintf( stderr, " near '%s'", cpy );
free( cpy );
line = buffer;
}
for (i = 0; i < where->first_column - 1; i++) line += sprintf( line, " " );
}
line += sprintf( line, "^" );
for (i = where->first_column + 1; i < where->last_column; i++) line += sprintf( line, "~" );
fprintf( stderr, "%s\n", buffer );
}
}
/* yyerror: yacc assumes this is not newline terminated. */
void parser_error( const struct location *where, const char *message )
void parser_error( const struct location *where, const char *message )
{
{
error_at( where, "%s\n", message );
diagnostic( where, "error", message );
}
void parser_warning( const struct location *where, const char *message )
{
diagnostic( where, "warning", message );
}
}
static void warning_disable(int warning)
static void warning_disable(int warning)
...
...
tools/widl/utils.c
View file @
3149d272
...
@@ -34,10 +34,14 @@
...
@@ -34,10 +34,14 @@
void
error_at
(
const
struct
location
*
where
,
const
char
*
s
,
...
)
void
error_at
(
const
struct
location
*
where
,
const
char
*
s
,
...
)
{
{
char
buffer
[
1024
];
va_list
ap
;
va_list
ap
;
va_start
(
ap
,
s
);
va_start
(
ap
,
s
);
generic_msg
(
where
,
s
,
"error"
,
ap
);
vsnprintf
(
buffer
,
sizeof
(
buffer
),
s
,
ap
);
va_end
(
ap
);
va_end
(
ap
);
parser_error
(
where
,
buffer
);
exit
(
1
);
exit
(
1
);
}
}
...
@@ -62,10 +66,14 @@ void warning(const char *s, ...)
...
@@ -62,10 +66,14 @@ void warning(const char *s, ...)
void
warning_at
(
const
struct
location
*
where
,
const
char
*
s
,
...
)
void
warning_at
(
const
struct
location
*
where
,
const
char
*
s
,
...
)
{
{
char
buffer
[
1024
];
va_list
ap
;
va_list
ap
;
va_start
(
ap
,
s
);
va_start
(
ap
,
s
);
generic_msg
(
where
,
s
,
"warning"
,
ap
);
vsnprintf
(
buffer
,
sizeof
(
buffer
),
s
,
ap
);
va_end
(
ap
);
va_end
(
ap
);
parser_warning
(
where
,
buffer
);
}
}
void
chat
(
const
char
*
s
,
...)
void
chat
(
const
char
*
s
,
...)
...
...
tools/widl/widltypes.h
View file @
3149d272
...
@@ -313,7 +313,6 @@ enum type_basic_type
...
@@ -313,7 +313,6 @@ enum type_basic_type
struct
location
struct
location
{
{
const
char
*
input_name
;
const
char
*
input_name
;
const
char
*
near_text
;
int
first_line
;
int
first_line
;
int
last_line
;
int
last_line
;
int
first_column
;
int
first_column
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment