summaryrefslogtreecommitdiffstats
path: root/source/theme.c
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2017-01-09 22:29:31 +0100
committerDave Davenport <qball@gmpclient.org>2017-01-09 22:29:31 +0100
commitca01af6338382c75f31555160f40aa5385be6521 (patch)
treea7722edb1e926ba49ab107b09ab15c53ed71f161 /source/theme.c
parentb010da57d74922ba35e94e254417a569fa3097d5 (diff)
Try to improve error handling and messages
Diffstat (limited to 'source/theme.c')
-rw-r--r--source/theme.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/source/theme.c b/source/theme.c
index 65810073..6979b07d 100644
--- a/source/theme.c
+++ b/source/theme.c
@@ -12,7 +12,7 @@
/** Logging domain for theme */
#define LOG_DOMAIN "Theme"
-void yyerror ( YYLTYPE *ylloc, const char * );
+void yyerror ( YYLTYPE *ylloc, const char *,const char * );
static gboolean distance_compare ( Distance d, Distance e )
{
return d.type == e.type && d.distance == e.distance && d.style == e.style;
@@ -261,11 +261,14 @@ extern FILE* yyin;
*
* Error handler for the lex parser.
*/
-void yyerror ( YYLTYPE *yylloc, const char* s )
+void yyerror ( YYLTYPE *yylloc, const char *what, const char* s )
{
- GString *str = g_string_new ("<big><b>Error while parsing theme file:</b></big>\n");
+ char *what_esc = g_markup_escape_text ( what, -1);
+ GString *str = g_string_new("");
+ g_string_printf ( str, "<big><b>Error while parsing them:</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: %s\n", esc );
+ g_string_append_printf(str, "\tParser error: <i>%s</i>\n", esc );
g_free(esc);
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 );
@@ -864,7 +867,7 @@ gboolean rofi_theme_parse_file ( const char *file )
extern const char*input_str;
str_len = 0;
input_str = NULL;
- int parser_retv = yyparse();
+ int parser_retv = yyparse(file);
yylex_destroy ();
g_free ( filename );
yyin = NULL;
@@ -880,7 +883,7 @@ gboolean rofi_theme_parse_string ( const char *string )
yyin = NULL;
input_str = string;
str_len = strlen ( string );
- while ( yyparse () ) {
+ while ( yyparse (string) ) {
;
}
yylex_destroy ();