From cf04292691625e8abcd8cc8af9436809f273e5a0 Mon Sep 17 00:00:00 2001 From: Jan de Groot Date: Thu, 20 Oct 2016 12:14:19 +0000 Subject: giscanner: fix EOF check with flex >= 2.6.1 It looks like flex 2.6.1 changed [1] the return code for EOF in yyinput. Therefore, use the right value depending on the version of flex which generates the lexer. [1] https://github.com/westes/flex/commit/f863c9490e6912ffcaeb12965fb3a567a10745ff https://bugzilla.gnome.org/show_bug.cgi?id=773272 --- giscanner/scannerlexer.l | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'giscanner/scannerlexer.l') diff --git a/giscanner/scannerlexer.l b/giscanner/scannerlexer.l index 61c0a92d..7dbab5c8 100644 --- a/giscanner/scannerlexer.l +++ b/giscanner/scannerlexer.l @@ -59,6 +59,15 @@ static void process_linemarks (GISourceScanner *scanner, gboolean has_line); static int check_identifier (GISourceScanner *scanner, const char *); static int parse_ignored_macro (void); static void print_error (GISourceScanner *scanner); + +#if (YY_FLEX_MAJOR_VERSION > 2) \ + || ((YY_FLEX_MAJOR_VERSION == 2) && (YY_FLEX_MINOR_VERSION > 6)) \ + || ((YY_FLEX_MAJOR_VERSION == 2) && (YY_FLEX_MINOR_VERSION == 6) && (YY_FLEX_SUBMINOR_VERSION >= 1)) +#define IS_EOF 0 +#else +#define IS_EOF EOF +#endif + %} %option nounput @@ -273,7 +282,7 @@ parse_comment (GISourceScanner *scanner) c1 = input(); c2 = input(); - if (c2 != EOF && (c1 == '*' && c2 != '*' && c2 != '/')) { + if (c2 != IS_EOF && (c1 == '*' && c2 != '*' && c2 != '/')) { /* * Store GTK-Doc comment blocks, * starts with one '/' followed by exactly two '*' and not followed by a '/' @@ -286,7 +295,7 @@ parse_comment (GISourceScanner *scanner) comment_lineno = lineno; - while (c2 != EOF && !(c1 == '*' && c2 == '/')) + while (c2 != IS_EOF && !(c1 == '*' && c2 == '/')) { if (!skip) g_string_append_c (string, c1); @@ -314,7 +323,7 @@ parse_comment (GISourceScanner *scanner) /* * Ignore all other comment blocks */ - while (c2 != EOF && !(c1 == '*' && c2 == '/')) + while (c2 != IS_EOF && !(c1 == '*' && c2 == '/')) { if (c1 == '\n') lineno++; @@ -439,19 +448,19 @@ parse_ignored_macro (void) int c; int nest; - while ((c = input ()) != EOF && isspace (c)) + while ((c = input ()) != IS_EOF && isspace (c)) ; if (c != '(') return FALSE; nest = 0; - while ((c = input ()) != EOF && (nest > 0 || c != ')')) { + while ((c = input ()) != IS_EOF && (nest > 0 || c != ')')) { if (c == '(') nest++; else if (c == ')') nest--; else if (c == '"') { - while ((c = input ()) != EOF && c != '"') { + while ((c = input ()) != IS_EOF && c != '"') { if (c == '\\') c = input (); } -- cgit v1.2.1