From: Bruno Haible Date: Fri, 2 Jun 2023 23:23:14 +0000 (+0200) Subject: xgettext: Fix a portability problem: Don't assume anything about the value of EOF. X-Git-Tag: v0.22~69 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6e6bfad8c9abf930084c844d66891e8da9d56535;p=thirdparty%2Fgettext.git xgettext: Fix a portability problem: Don't assume anything about the value of EOF. Pinpointed by gcc 13 warning: warning: macro "P7_EOF" is not used [-Wunused-macros] * gettext-tools/src/x-c.c (P7_STRING_END): Remove macro. (phase7_getc): Transform EOF to P7_EOF. (phase5_get): Test for P7_EOF, not EOF. * gettext-tools/src/x-vala.c (P7_STRING_END): Remove macro. (phase7_getc): Transform EOF to P7_EOF. (phase3_get): Test for P7_EOF, not EOF. --- diff --git a/gettext-tools/src/x-c.c b/gettext-tools/src/x-c.c index 206b0e65c..763f0317c 100644 --- a/gettext-tools/src/x-c.c +++ b/gettext-tools/src/x-c.c @@ -970,7 +970,6 @@ struct token_ty /* Return value of phase7_getc when EOF is reached. */ #define P7_EOF (-1) -#define P7_STRING_END (-2) /* Replace escape sequences within character strings with their single character equivalents. */ @@ -999,6 +998,9 @@ phase7_getc () /* Use phase 3, because phase 4 elides comments. */ c = phase3_getc (); + if (c == EOF) + return P7_EOF; + /* Return a magic newline indicator, so that we can distinguish between the user requesting a newline in the string (e.g. using "\n" or "\012") from the user failing to terminate the string or @@ -1681,7 +1683,7 @@ phase5_get (token_ty *tp) phase7_ungetc ('\n'); break; } - if (c == EOF || c == P7_QUOTE) + if (c == P7_EOF || c == P7_QUOTE) break; } tp->type = token_type_character_constant; @@ -1718,7 +1720,7 @@ phase5_get (token_ty *tp) phase7_ungetc ('\n'); break; } - if (c == EOF || c == P7_QUOTES) + if (c == P7_EOF || c == P7_QUOTES) break; if (c == P7_QUOTE) c = '\''; diff --git a/gettext-tools/src/x-vala.c b/gettext-tools/src/x-vala.c index 20dccb606..a89f8e0a8 100644 --- a/gettext-tools/src/x-vala.c +++ b/gettext-tools/src/x-vala.c @@ -388,7 +388,6 @@ free_token (token_ty *tp) /* Return value of phase7_getc when EOF is reached. */ #define P7_EOF (-1) -#define P7_STRING_END (-2) /* Replace escape sequences within character strings with their single character equivalents. */ @@ -417,6 +416,9 @@ phase7_getc () /* Use phase 1, because phase 2 elides comments. */ c = phase1_getc (); + if (c == EOF) + return P7_EOF; + /* Return a magic newline indicator, so that we can distinguish between the user requesting a newline in the string (e.g. using "\n" or "\012") from the user failing to terminate the string or @@ -839,7 +841,7 @@ phase3_get (token_ty *tp) phase7_ungetc ('\n'); break; } - if (c == EOF || c == P7_QUOTE) + if (c == P7_EOF || c == P7_QUOTE) break; } tp->type = last_token_type = token_type_character_constant; @@ -940,7 +942,7 @@ phase3_get (token_ty *tp) } if (c == P7_QUOTES) break; - if (c == EOF) + if (c == P7_EOF) break; if (c == P7_QUOTE) c = '\'';