summaryrefslogtreecommitdiff
path: root/console-client
diff options
context:
space:
mode:
authorDiego Nieto Cid <dnietoc@gmail.com>2010-07-20 14:10:18 -0300
committerDiego Nieto Cid <dnietoc@gmail.com>2011-04-08 14:36:18 -0300
commit650a8244fcb3a2f7897842d70073a491832b918e (patch)
tree123cf25a0f2269e5c1f12ba15246d88ef987bc5b /console-client
parent22e017432a130728b5b0f535aa490bfaaadacc73 (diff)
Check for end of file.
* console-client/xkb/parser.y [!YY_NULL]: Define YY_NULL, the end of file token. * console-client/xkb/parser.y (skip_to_sectionname): If the end of file is reached while skipping symbols return an error. Return 0 on success. * console-client/xkb/parser.y (skip_to_defaultsection): Likewise.
Diffstat (limited to 'console-client')
-rw-r--r--console-client/xkb/parser.y26
1 files changed, 19 insertions, 7 deletions
diff --git a/console-client/xkb/parser.y b/console-client/xkb/parser.y
index d6e27c79..866dc34f 100644
--- a/console-client/xkb/parser.y
+++ b/console-client/xkb/parser.y
@@ -78,6 +78,10 @@ mergemode merge_mode = override;
//#define YYDEBUG 1
+#ifndef YY_NULL
+#define YY_NULL 0
+#endif
+
static struct keytype *current_keytype;
%}
@@ -1142,7 +1146,7 @@ geometry:
%%
/* Skip all tokens until a section of the type SECTIONSYMBOL with the
name SECTIONNAME is found. */
-static void
+static int
skip_to_sectionname (char *sectionname, int sectionsymbol)
{
int symbol;
@@ -1152,17 +1156,22 @@ skip_to_sectionname (char *sectionname, int sectionsymbol)
do
{
symbol = yylex ();
- } while (symbol != sectionsymbol);
- symbol = yylex ();
+ } while ((symbol != YY_NULL) && (symbol != sectionsymbol));
+
+ if (symbol != YY_NULL)
+ symbol = yylex ();
- if (symbol != STR)
+ if (symbol == YY_NULL) {
+ return 1;
+ } else if (symbol != STR)
continue;
} while (strcmp (yylval.str, sectionname));
+ return 0;
}
/* Skip all tokens until the default section is found. */
-static void
+static int
skip_to_defaultsection (void)
{
int symbol;
@@ -1170,14 +1179,17 @@ skip_to_defaultsection (void)
/* Search the default section. */
do
{
- symbol = yylex ();
+ if ((symbol = yylex ()) == YY_NULL)
+ return 1;
} while (symbol != DEFAULT);
do
{
- symbol = yylex ();
+ if ((symbol = yylex ()) == YY_NULL)
+ return 1;
} while (symbol != '{');
scanner_unput ('{');
+ return 0;
}
/* Include a single file. INCL is the filename. SECTIONSYMBOL is the