mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
Add filename to location in error message.
This commit is contained in:
parent
d67a562d88
commit
9cfb075bc4
3 changed files with 39 additions and 2 deletions
|
@ -142,6 +142,7 @@ YY_LLOC_START
|
|||
%{
|
||||
if ( queue == NULL ){
|
||||
queue = g_queue_new ( );
|
||||
yylloc->filename = current->filename;
|
||||
}
|
||||
%}
|
||||
|
||||
|
@ -219,6 +220,7 @@ if ( queue == NULL ){
|
|||
yypush_buffer_state (yy_create_buffer ( 0, YY_BUF_SIZE ));
|
||||
yylloc->first_line = yylloc->last_line = 1;
|
||||
yylloc->first_column = yylloc->last_column = 1;
|
||||
yylloc->filename = current->filename;
|
||||
} else {
|
||||
char *str = g_markup_printf_escaped ( "Failed to open theme: <i>%s</i>\nError: <b>%s</b>",
|
||||
filename, strerror ( errno ) );
|
||||
|
|
|
@ -7,6 +7,35 @@
|
|||
%parse-param {const char *what}
|
||||
%code requires {
|
||||
#include "theme.h"
|
||||
|
||||
typedef struct YYLTYPE {
|
||||
int first_line;
|
||||
int first_column;
|
||||
int last_line;
|
||||
int last_column;
|
||||
char *filename;
|
||||
} YYLTYPE;
|
||||
# define YYLTYPE_IS_DECLARED 1 /* alert the parser that we have our own definition */
|
||||
|
||||
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
||||
do \
|
||||
if (N) \
|
||||
{ \
|
||||
(Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
|
||||
(Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
|
||||
(Current).last_line = YYRHSLOC (Rhs, N).last_line; \
|
||||
(Current).last_column = YYRHSLOC (Rhs, N).last_column; \
|
||||
(Current).filename = YYRHSLOC (Rhs, 1).filename; \
|
||||
} \
|
||||
else \
|
||||
{ /* empty RHS */ \
|
||||
(Current).first_line = (Current).last_line = \
|
||||
YYRHSLOC (Rhs, 0).last_line; \
|
||||
(Current).first_column = (Current).last_column = \
|
||||
YYRHSLOC (Rhs, 0).last_column; \
|
||||
(Current).filename = NULL; /* new */ \
|
||||
} \
|
||||
while (0)
|
||||
}
|
||||
%{
|
||||
#include <stdio.h>
|
||||
|
|
|
@ -270,9 +270,15 @@ void yyerror ( YYLTYPE *yylloc, const char *what, const char* s )
|
|||
g_string_printf ( str, "<big><b>Error while parsing theme:</b></big> <i>%s</i>\n", what_esc );
|
||||
g_free ( what_esc );
|
||||
char *esc = g_markup_escape_text ( s, -1 );
|
||||
g_string_append_printf ( str, "\tParser error: <i>%s</i>\n", esc );
|
||||
g_string_append_printf ( str, "\tParser error: <span size=\"smaller\" style=\"italic\">%s</span>\n", esc );
|
||||
g_free ( esc );
|
||||
if ( yylloc->filename != NULL ) {
|
||||
g_string_append_printf ( str, "\tLocation: line %d column %d to line %d column %d.\n"\
|
||||
"\tFile '%s'\n", yylloc->first_line, yylloc->first_column, yylloc->last_line, yylloc->last_column, yylloc->filename);
|
||||
|
||||
}else {
|
||||
g_string_append_printf ( str, "\tLocation: line %d column %d to line %d column %d\n", yylloc->first_line, yylloc->first_column, yylloc->last_line, yylloc->last_column );
|
||||
}
|
||||
rofi_add_error_message ( str );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue