]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
xgettext: Refactor.
authorBruno Haible <bruno@clisp.org>
Wed, 11 Sep 2024 12:09:08 +0000 (14:09 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 11 Sep 2024 12:09:08 +0000 (14:09 +0200)
* gettext-tools/src/x-awk.c (SE_QUOTES): Renamed from P7_QUOTES.
(get_string_element): Renamed from phase7_getc.
(x_awk_lex): Update.
* gettext-tools/src/x-c.c (SE_EOF): Renamed from P7_EOF.
(SE_QUOTES): Renamed from P7_QUOTES.
(SE_QUOTE): Renamed from P7_QUOTE.
(SE_NEWLINE): Renamed from P7_NEWLINE.
(get_string_element): Renamed from phase7_getc.
(unget_string_element): Renamed from phase7_ungetc.
(phase5_get): Update.
* gettext-tools/src/x-vala.c (SE_EOF): Renamed from P7_EOF.
(SE_QUOTES): Renamed from P7_QUOTES.
(SE_QUOTE): Renamed from P7_QUOTE.
(SE_NEWLINE): Renamed from P7_NEWLINE.
(get_string_element): Renamed from phase7_getc.
(unget_string_element): Renamed from phase7_ungetc.
(phase3_get): Update.
* gettext-tools/src/x-ycp.c (SE_QUOTES): Renamed from P7_QUOTES.
(get_string_element): Renamed from phase7_getc.
(phase5_get): Update.

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

index f304ba2aa05b2f4f875caad488336d8e1b6185ba..71edaf6d0794b7ba05bdcd3ae60028c936209441 100644 (file)
@@ -242,13 +242,13 @@ struct token_ty
 };
 
 
-/* 7. Replace escape sequences within character strings with their
+/* Replace escape sequences within character strings with their
    single character equivalents.  */
 
-#define P7_QUOTES (1000 + '"')
+#define SE_QUOTES (1000 + '"')
 
 static int
-phase7_getc ()
+get_string_element ()
 {
   int c;
 
@@ -260,7 +260,7 @@ phase7_getc ()
       if (c == EOF || c == '\n')
         break;
       if (c == '"')
-        return P7_QUOTES;
+        return SE_QUOTES;
       if (c != '\\')
         return c;
       c = phase1_getc ();
@@ -340,7 +340,7 @@ phase7_getc ()
   if_error (IF_SEVERITY_WARNING,
             logical_file_name, line_number, (size_t)(-1), false,
             _("unterminated string"));
-  return P7_QUOTES;
+  return SE_QUOTES;
 }
 
 
@@ -516,8 +516,8 @@ x_awk_lex (token_ty *tp)
           bufpos = 0;
           for (;;)
             {
-              c = phase7_getc ();
-              if (c == EOF || c == P7_QUOTES)
+              c = get_string_element ();
+              if (c == EOF || c == SE_QUOTES)
                 break;
               if (bufpos >= bufmax)
                 {
index 7b43c245f170ab7a24f72546d6b88ee3ade03ddc..5b7125d50007343e5c76a92b196c7a548f906019 100644 (file)
@@ -986,20 +986,20 @@ struct token_ty
 };
 
 
-/* 7. Replace escape sequences within character strings with their
+/* Replace escape sequences within character strings with their
    single character equivalents.  This is called from phase 5, because
    we don't have to worry about the #include argument.  There are
    pathological cases which could bite us (like the DOS directory
    separator), but just pretend it can't happen.  */
 
-/* Return value of phase7_getc when EOF is reached.  */
-#define P7_EOF (-1)
+/* Return value of get_string_element when EOF is reached.  */
+#define SE_EOF (-1)
 
 /* Replace escape sequences within character strings with their single
    character equivalents.  */
-#define P7_QUOTES (-3)
-#define P7_QUOTE (-4)
-#define P7_NEWLINE (-5)
+#define SE_QUOTES (-3)
+#define SE_QUOTE (-4)
+#define SE_NEWLINE (-5)
 
 /* Convert an UTF-16 or UTF-32 code point to a return value that can be
    distinguished from a single-byte return value.  */
@@ -1015,7 +1015,7 @@ struct token_ty
 
 
 static int
-phase7_getc ()
+get_string_element ()
 {
   int c, j;
 
@@ -1023,7 +1023,7 @@ phase7_getc ()
   c = phase3_getc ();
 
   if (c == EOF)
-    return P7_EOF;
+    return SE_EOF;
 
   /* Return a magic newline indicator, so that we can distinguish
      between the user requesting a newline in the string (e.g. using
@@ -1043,12 +1043,12 @@ phase7_getc ()
      you may not embed newlines in character constants; try it, you get
      a useful diagnostic.  --PMiller  */
   if (c == '\n')
-    return P7_NEWLINE;
+    return SE_NEWLINE;
 
   if (c == '"')
-    return P7_QUOTES;
+    return SE_QUOTES;
   if (c == '\'')
-    return P7_QUOTE;
+    return SE_QUOTE;
   if (c != '\\')
     return c;
   c = phase3_getc ();
@@ -1213,7 +1213,7 @@ phase7_getc ()
 
 
 static void
-phase7_ungetc (int c)
+unget_string_element (int c)
 {
   phase3_ungetc (c);
 }
@@ -1688,16 +1688,16 @@ phase5_get (token_ty *tp)
          remember the character constant.  */
       for (;;)
         {
-          c = phase7_getc ();
-          if (c == P7_NEWLINE)
+          c = get_string_element ();
+          if (c == SE_NEWLINE)
             {
               if_error (IF_SEVERITY_WARNING,
                         logical_file_name, line_number - 1, (size_t)(-1), false,
                         _("unterminated character constant"));
-              phase7_ungetc ('\n');
+              unget_string_element ('\n');
               break;
             }
-          if (c == P7_EOF || c == P7_QUOTE)
+          if (c == SE_EOF || c == SE_QUOTE)
             break;
         }
       tp->type = token_type_character_constant;
@@ -1720,22 +1720,22 @@ phase5_get (token_ty *tp)
 
         for (;;)
           {
-            c = phase7_getc ();
+            c = get_string_element ();
 
             /* Keep line_number in sync.  */
             msb.line_number = line_number;
 
-            if (c == P7_NEWLINE)
+            if (c == SE_NEWLINE)
               {
                 if_error (IF_SEVERITY_WARNING,
                           logical_file_name, line_number - 1, (size_t)(-1), false,
                           _("unterminated string literal"));
-                phase7_ungetc ('\n');
+                unget_string_element ('\n');
                 break;
               }
-            if (c == P7_EOF || c == P7_QUOTES)
+            if (c == SE_EOF || c == SE_QUOTES)
               break;
-            if (c == P7_QUOTE)
+            if (c == SE_QUOTE)
               c = '\'';
             if (IS_UNICODE (c))
               {
index 74cfbeea426a1d9a7fe2b02abc446ebec1c14296..bfe2a2bb057e9e6cef11720e82f49403ac44a1b6 100644 (file)
@@ -440,14 +440,14 @@ free_token (token_ty *tp)
 }
 
 
-/* Return value of phase7_getc when EOF is reached.  */
-#define P7_EOF (-1)
+/* Return value of get_string_element when EOF is reached.  */
+#define SE_EOF (-1)
 
 /* Replace escape sequences within character strings with their single
    character equivalents.  */
-#define P7_QUOTES (-3)
-#define P7_QUOTE (-4)
-#define P7_NEWLINE (-5)
+#define SE_QUOTES (-3)
+#define SE_QUOTE (-4)
+#define SE_NEWLINE (-5)
 
 /* Convert an UTF-16 or UTF-32 code point to a return value that can be
    distinguished from a single-byte return value.  */
@@ -463,7 +463,7 @@ free_token (token_ty *tp)
 
 
 static int
-phase7_getc ()
+get_string_element ()
 {
   int c, j;
 
@@ -471,7 +471,7 @@ phase7_getc ()
   c = phase1_getc ();
 
   if (c == EOF)
-    return P7_EOF;
+    return SE_EOF;
 
   /* Return a magic newline indicator, so that we can distinguish
      between the user requesting a newline in the string (e.g. using
@@ -491,12 +491,12 @@ phase7_getc ()
      you may not embed newlines in character constants; try it, you get
      a useful diagnostic.  --PMiller  */
   if (c == '\n')
-    return P7_NEWLINE;
+    return SE_NEWLINE;
 
   if (c == '"')
-    return P7_QUOTES;
+    return SE_QUOTES;
   if (c == '\'')
-    return P7_QUOTE;
+    return SE_QUOTE;
   if (c != '\\')
     return c;
   c = phase1_getc ();
@@ -657,7 +657,7 @@ phase7_getc ()
 
 
 static void
-phase7_ungetc (int c)
+unget_string_element (int c)
 {
   phase1_ungetc (c);
 }
@@ -879,16 +879,16 @@ phase3_get (token_ty *tp)
         case '\'':
           for (;;)
             {
-              c = phase7_getc ();
-              if (c == P7_NEWLINE)
+              c = get_string_element ();
+              if (c == SE_NEWLINE)
                 {
                   if_error (IF_SEVERITY_WARNING,
                             logical_file_name, line_number - 1, (size_t)(-1), false,
                             _("unterminated character constant"));
-                  phase7_ungetc ('\n');
+                  unget_string_element ('\n');
                   break;
                 }
-              if (c == P7_EOF || c == P7_QUOTE)
+              if (c == SE_EOF || c == SE_QUOTE)
                 break;
             }
           tp->type = last_token_type = token_type_character_constant;
@@ -974,24 +974,24 @@ phase3_get (token_ty *tp)
             else
               for (;;)
                 {
-                  c = phase7_getc ();
+                  c = get_string_element ();
 
                   /* Keep line_number in sync.  */
                   msb.line_number = line_number;
 
-                  if (c == P7_NEWLINE)
+                  if (c == SE_NEWLINE)
                     {
                       if_error (IF_SEVERITY_WARNING,
                                 logical_file_name, line_number - 1, (size_t)(-1), false,
                                 _("unterminated string literal"));
-                      phase7_ungetc ('\n');
+                      unget_string_element ('\n');
                       break;
                     }
-                  if (c == P7_QUOTES)
+                  if (c == SE_QUOTES)
                     break;
-                  if (c == P7_EOF)
+                  if (c == SE_EOF)
                     break;
-                  if (c == P7_QUOTE)
+                  if (c == SE_QUOTE)
                     c = '\'';
                   if (IS_UNICODE (c))
                     {
index d55400c2ce2789da87c2c0d906a4f6be24797a93..7fb560e38f1d6f2bc1662b5a026db2197fc52afa 100644 (file)
@@ -332,13 +332,13 @@ struct token_ty
 };
 
 
-/* 7. Replace escape sequences within character strings with their
+/* Replace escape sequences within character strings with their
    single character equivalents.  */
 
-#define P7_QUOTES (1000 + '"')
+#define SE_QUOTES (1000 + '"')
 
 static int
-phase7_getc ()
+get_string_element ()
 {
   int c;
 
@@ -348,7 +348,7 @@ phase7_getc ()
       c = phase1_getc ();
 
       if (c == '"')
-        return P7_QUOTES;
+        return SE_QUOTES;
       if (c != '\\')
         return c;
       c = phase1_getc ();
@@ -524,8 +524,8 @@ phase5_get (token_ty *tp)
           bufpos = 0;
           for (;;)
             {
-              c = phase7_getc ();
-              if (c == EOF || c == P7_QUOTES)
+              c = get_string_element ();
+              if (c == EOF || c == SE_QUOTES)
                 break;
               if (bufpos >= bufmax)
                 {