]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
xgettext: Fix a portability problem: Don't assume anything about the value of EOF.
authorBruno Haible <bruno@clisp.org>
Fri, 2 Jun 2023 23:23:14 +0000 (01:23 +0200)
committerBruno Haible <bruno@clisp.org>
Fri, 2 Jun 2023 23:23:14 +0000 (01:23 +0200)
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.

gettext-tools/src/x-c.c
gettext-tools/src/x-vala.c

index 206b0e65ccfd1a48ecf3b2075eebb60f4d61097d..763f0317c2d94340be5412629b633a19d62cfae9 100644 (file)
@@ -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 = '\'';
index 20dccb606161b952a5eaf8b3bd69e09ff9f0fe59..a89f8e0a82a4fdd84b326593a47284e27207ff13 100644 (file)
@@ -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 = '\'';