From 06df861f4c9b2bd31af7aaba06977bb67aad6e28 Mon Sep 17 00:00:00 2001 From: Diego Nieto Cid Date: Sat, 25 Dec 2010 22:13:20 -0300 Subject: Use first section when there's no default. * console-client/xkb/parser.y (skip_to_firstsection): New function. (include_section): Call skip_to_firstsection when skip_to_defaultsection fails. --- console-client/xkb/parser.y | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'console-client/xkb') diff --git a/console-client/xkb/parser.y b/console-client/xkb/parser.y index 0b279462..1ce52f8e 100644 --- a/console-client/xkb/parser.y +++ b/console-client/xkb/parser.y @@ -1180,6 +1180,29 @@ skip_to_sectionname (char *sectionname, int sectionsymbol) return 0; } +/* Skip all tokens until the first section of the type SECTIONSYMBOL + is found. */ +static int +skip_to_firstsection (int sectionsymbol) +{ + int symbol; + + do + { + do + { + symbol = yylex (); + } while ((symbol != YY_NULL) && (symbol != sectionsymbol)); + + if (symbol != YY_NULL) + symbol = yylex (); + + if (symbol == YY_NULL) + return 1; + } while (symbol != STR); + return 0; +} + /* Skip all tokens until the default section is found. */ static int skip_to_defaultsection (void) @@ -1269,8 +1292,13 @@ include_section (char *incl, int sectionsymbol, char *dirname, if (sectionname) err = skip_to_sectionname (sectionname, sectionsymbol); else - err = skip_to_defaultsection (); - + if ((err = skip_to_defaultsection ()) != 0) + { + /* XXX: after skip_to_defaultsection failed the whole file was + consumed and it is required to include it here, too. */ + include_file (includefile, new_mm, strdup (filename)); + err = skip_to_firstsection (sectionsymbol); + } if (err != 0) { char* tmpbuf = malloc (sizeof(char)*1024); if (tmpbuf) { -- cgit v1.2.3