summaryrefslogtreecommitdiff
path: root/console-client
diff options
context:
space:
mode:
authorDiego Nieto Cid <dnietoc@gmail.com>2010-12-25 22:13:20 -0300
committerDiego Nieto Cid <dnietoc@gmail.com>2011-04-08 14:36:22 -0300
commit06df861f4c9b2bd31af7aaba06977bb67aad6e28 (patch)
treed5668c4de3d60be0a4915ced4810ab33a31b8a24 /console-client
parenta6115630d2e5bba6e71e8e0174e8d7d6befef481 (diff)
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.
Diffstat (limited to 'console-client')
-rw-r--r--console-client/xkb/parser.y32
1 files changed, 30 insertions, 2 deletions
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) {