]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Reduce the size of the pushback buffers.
authorBruno Haible <bruno@clisp.org>
Mon, 29 Dec 2003 11:58:04 +0000 (11:58 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:11:33 +0000 (12:11 +0200)
gettext-tools/src/ChangeLog
gettext-tools/src/x-awk.c
gettext-tools/src/x-c.c
gettext-tools/src/x-java.c
gettext-tools/src/x-perl.c
gettext-tools/src/x-php.c
gettext-tools/src/x-python.c
gettext-tools/src/x-sh.c
gettext-tools/src/x-smalltalk.c
gettext-tools/src/x-tcl.c
gettext-tools/src/x-ycp.c

index 41f3922592f4eec9a29ada4ee7af719d7527c021..d259c5718254b653d36adad2149f884b1c2f247f 100644 (file)
@@ -1,3 +1,24 @@
+2003-12-14  Bruno Haible  <bruno@clisp.org>
+
+       * x-c.c (phase1_pushback): Reduce size to 2.
+       (phase2_pushback): Reduce size to 1.
+       (phase3_pushback): Reduce size to 2.
+       (phase5_pushback): Reduce size to 1.
+       (phase6_pushback): Reduce size to 2.
+       * x-java.c (phase2_pushback): Reduce size to 1.
+       (phase3_pushback): Reduce size to 2.
+       (phase5_pushback): Reduce size to 3.
+       (phase6_pushback): Reduce size to 2.
+       * x-php.c (phase1_pushback): Reduce size to 2.
+       * x-python.c (max): New macro.
+       (phase1_pushback): Reduce size to UNINAME_MAX + 3.
+       (phase5_pushback): Reduce size to 1.
+       * x-sh.c (phase1_pushback): Reduce size to 1.
+       (phase2_pushback): Reduce size to 2.
+       * x-smalltalk.c (phase2_pushback): Reduce size to 1.
+       * x-tcl.c (phase1_pushback): Reduce size to 1.
+       (phase2_pushback): Reduce size to 2.
+
 2003-12-12  Bruno Haible  <bruno@clisp.org>
 
        Assume automake-1.8.
index a9023403659a6d60373489b2cb9028b86d925601..e9e6061132e435340722338db799b8dd631d34f9 100644 (file)
@@ -151,6 +151,7 @@ phase1_getc ()
   return c;
 }
 
+/* Supports only one pushback character.  */
 static void
 phase1_ungetc (int c)
 {
@@ -210,6 +211,7 @@ phase2_getc ()
   return c;
 }
 
+/* Supports only one pushback character.  */
 static void
 phase2_ungetc (int c)
 {
index 5d5e092a5ec8d7aac744834942825bbcb71b2b98..22b9e40ee8eefc5b8116f61bfde4a0b04ea6d893 100644 (file)
@@ -369,7 +369,7 @@ phase0_getc ()
 }
 
 
-/* Only one pushback character supported, and not '\n'.  */
+/* Supports only one pushback character, and not '\n'.  */
 static inline void
 phase0_ungetc (int c)
 {
@@ -378,12 +378,9 @@ phase0_ungetc (int c)
 }
 
 
-/* 1. line_number handling.  Combine backslash-newline to nothing.
-   Cope with potentially 2 characters of pushback, not just the one that
-   ungetc can cope with.  */
+/* 1. line_number handling.  Combine backslash-newline to nothing.  */
 
-/* Maximum used guaranteed to be < 4.  */
-static unsigned char phase1_pushback[4];
+static unsigned char phase1_pushback[2];
 static int phase1_pushback_length;
 
 
@@ -425,6 +422,7 @@ phase1_getc ()
 }
 
 
+/* Supports 2 characters of pushback.  */
 static void
 phase1_ungetc (int c)
 {
@@ -448,8 +446,7 @@ phase1_ungetc (int c)
    sane human beings vomit copiously at the mention of trigraphs, which
    is why they are an option.  */
 
-/* Maximum used guaranteed to be < 4.  */
-static unsigned char phase2_pushback[4];
+static unsigned char phase2_pushback[1];
 static int phase2_pushback_length;
 
 
@@ -500,6 +497,7 @@ phase2_getc ()
 }
 
 
+/* Supports only one pushback character.  */
 static void
 phase2_ungetc (int c)
 {
@@ -512,8 +510,7 @@ phase2_ungetc (int c)
    line.  Basically, all you need to do is elide "\\\n" sequences from
    the input.  */
 
-/* Maximum used guaranteed to be < 4.  */
-static unsigned char phase3_pushback[4];
+static unsigned char phase3_pushback[2];
 static int phase3_pushback_length;
 
 
@@ -537,6 +534,7 @@ phase3_getc ()
 }
 
 
+/* Supports 2 characters of pushback.  */
 static void
 phase3_ungetc (int c)
 {
@@ -673,6 +671,7 @@ phase4_getc ()
 }
 
 
+/* Supports only one pushback character.  */
 static void
 phase4_ungetc (int c)
 {
@@ -878,8 +877,7 @@ free_token (token_ty *tp)
 /* 5. Parse each resulting logical line as preprocessing tokens and
    white space.  Preprocessing tokens and C tokens don't always match.  */
 
-/* Maximum used guaranteed to be < 4.  */
-static token_ty phase5_pushback[4];
+static token_ty phase5_pushback[1];
 static int phase5_pushback_length;
 
 
@@ -1164,6 +1162,7 @@ phase5_get (token_ty *tp)
 }
 
 
+/* Supports only one pushback token.  */
 static void
 phase5_unget (token_ty *tp)
 {
@@ -1219,8 +1218,7 @@ phaseX_get (token_ty *tp)
    we care about are the #line and #define directive.  We throw all the
    others away.  */
 
-/* Maximum used guaranteed to be < 4.  */
-static token_ty phase6_pushback[4];
+static token_ty phase6_pushback[2];
 static int phase6_pushback_length;
 
 
@@ -1303,6 +1301,7 @@ phase6_get (token_ty *tp)
 }
 
 
+/* Supports 2 tokens of pushback.  */
 static void
 phase6_unget (token_ty *tp)
 {
@@ -1372,6 +1371,7 @@ phase8a_get (token_ty *tp)
     }
 }
 
+/* Supports 2 tokens of pushback.  */
 static inline void
 phase8a_unget (token_ty *tp)
 {
@@ -1408,6 +1408,7 @@ phase8b_get (token_ty *tp)
     }
 }
 
+/* Supports 2 tokens of pushback.  */
 static inline void
 phase8b_unget (token_ty *tp)
 {
@@ -1435,6 +1436,7 @@ phase8c_get (token_ty *tp)
   *tp = tmp;
 }
 
+/* Supports only one pushback token.  */
 static inline void
 phase8c_unget (token_ty *tp)
 {
index fd3d5c29801734bdc0c5e703fe66d1c1912ec32c..b18f19677ca07cdcd271a95cd2992383f14356ca 100644 (file)
@@ -178,6 +178,7 @@ error while reading \"%s\""), real_file_name);
   return c;
 }
 
+/* Supports any number of 'u' and up to 4 arbitrary characters of pushback.  */
 static void
 phase1_ungetc (int c)
 {
@@ -199,8 +200,7 @@ phase1_ungetc (int c)
 
 /* Fetch the next single-byte character or Unicode character from the file.
    (Here, as in the Java Language Specification, when we say "Unicode
-   character", we actually mean "UTF-16 encoding unit".)
-   Cope with potentially 2 pushback characters.  */
+   character", we actually mean "UTF-16 encoding unit".)  */
 
 /* Return value of phase 2, 3, 4 when EOF is reached.  */
 #define P2_EOF 0xffff
@@ -221,8 +221,7 @@ phase1_ungetc (int c)
    (RED (c) == 'x')  is equivalent to  (c == 'x' || c == UNICODE ('x')).  */
 #define RED(p2_result) ((p2_result) & 0xffff)
 
-/* Maximum used guaranteed to be < 2.  */
-static int phase2_pushback[2];
+static int phase2_pushback[1];
 static int phase2_pushback_length;
 
 static int
@@ -286,6 +285,7 @@ phase2_getc ()
   return c;
 }
 
+/* Supports only one pushback character.  */
 static void
 phase2_ungetc (int c)
 {
@@ -296,10 +296,8 @@ phase2_ungetc (int c)
 
 /* Fetch the next single-byte character or Unicode character from the file.
    With line number handling.
-   Convert line terminators to '\n' or UNICODE ('\n').
-   Cope with potentially 2 pushback characters.  */
+   Convert line terminators to '\n' or UNICODE ('\n').  */
 
-/* Maximum used guaranteed to be < 2.  */
 static int phase3_pushback[2];
 static int phase3_pushback_length;
 
@@ -350,6 +348,7 @@ phase3_getc ()
   return c;
 }
 
+/* Supports 2 characters of pushback.  */
 static void
 phase3_ungetc (int c)
 {
@@ -777,6 +776,7 @@ phase4_getc ()
     }
 }
 
+/* Supports only one pushback character.  */
 static void
 phase4_ungetc (int c)
 {
@@ -917,8 +917,7 @@ accumulate_escaped (struct string_buffer *literal, int delimiter)
 
 /* Combine characters into tokens.  Discard whitespace.  */
 
-/* Maximum used guaranteed to be < 4.  */
-static token_ty phase5_pushback[4];
+static token_ty phase5_pushback[3];
 static int phase5_pushback_length;
 
 static void
@@ -1122,6 +1121,7 @@ phase5_get (token_ty *tp)
     }
 }
 
+/* Supports 3 tokens of pushback.  */
 static void
 phase5_unget (token_ty *tp)
 {
@@ -1137,8 +1137,7 @@ phase5_unget (token_ty *tp)
      - the token after this expression is not '.' (because then the last
        string could be part of a method call expression).  */
 
-/* Maximum used guaranteed to be < 4.  */
-static token_ty phase6_pushback[4];
+static token_ty phase6_pushback[2];
 static int phase6_pushback_length;
 
 static token_type_ty phase6_last;
@@ -1199,6 +1198,7 @@ phase6_get (token_ty *tp)
   phase6_last = tp->type;
 }
 
+/* Supports 2 tokens of pushback.  */
 static void
 phase6_unget (token_ty *tp)
 {
@@ -1213,6 +1213,7 @@ x_java_lex (token_ty *tp)
   phase6_get (tp);
 }
 
+/* Supports 2 tokens of pushback.  */
 static void
 x_java_unlex (token_ty *tp)
 {
index 86ae68f35bdf96c51ea5f3a743153cb1c4be8ae3..9fe5b8192f07d2eb6cabbe33927d1f6b8a181085 100644 (file)
@@ -155,7 +155,7 @@ init_flag_table_perl ()
   xgettext_record_flag ("gettext_noop:1:pass-perl-brace-format");
   xgettext_record_flag ("printf:1:perl-format"); /* argument 1 or 2 ?? */
   xgettext_record_flag ("sprintf:1:perl-format");
-#if 0 
+#if 0
   xgettext_record_flag ("__:1:pass-perl-format");
   xgettext_record_flag ("__:1:pass-perl-brace-format");
   xgettext_record_flag ("%__:1:pass-perl-format");
@@ -253,6 +253,7 @@ phase1_getc ()
   return linebuf[linepos++];
 }
 
+/* Supports only one pushback character.  */
 static void
 phase1_ungetc (int c)
 {
@@ -479,6 +480,7 @@ phase2_getc ()
   return c;
 }
 
+/* Supports only one pushback character.  */
 static void
 phase2_ungetc (int c)
 {
index 6a8310be3194a8cffaaf7483758efab4714442ef..db71b3982223dd1e32878fd266dc5c0b016c1dbf 100644 (file)
@@ -140,8 +140,7 @@ static FILE *fp;
 
 /* 1. line_number handling.  */
 
-/* Maximum used guaranteed to be < 4.  */
-static unsigned char phase1_pushback[4];
+static unsigned char phase1_pushback[2];
 static int phase1_pushback_length;
 
 static int
@@ -170,6 +169,7 @@ phase1_getc ()
   return c;
 }
 
+/* Supports 2 characters of pushback.  */
 static void
 phase1_ungetc (int c)
 {
index 8b19d825343a6b7f2a9f6a03613585f770becddb..fb53dc35052fa4ca620ef4d5b521fa3ea2bdff64 100644 (file)
@@ -42,6 +42,7 @@
 #include "gettext.h"
 
 #define _(s) gettext(s)
+#define max(a,b) ((a) > (b) ? (a) : (b))
 
 
 /* The Python syntax is defined in the Python Reference Manual
@@ -144,10 +145,9 @@ static int line_number;
 static FILE *fp;
 
 
-/* 1. line_number handling.  Also allow a lookahead of 9 characters.  */
+/* 1. line_number handling.  Also allow a lookahead.  */
 
-/* Maximum used guaranteed to be < UNINAME_MAX + 4.  */
-static unsigned char phase1_pushback[UNINAME_MAX + 4];
+static unsigned char phase1_pushback[max (9, UNINAME_MAX + 3)];
 static int phase1_pushback_length;
 
 static int
@@ -176,6 +176,7 @@ phase1_getc ()
   return c;
 }
 
+/* Supports max (9, UNINAME_MAX + 3) characters of pushback.  */
 static void
 phase1_ungetc (int c)
 {
@@ -288,6 +289,7 @@ phase2_getc ()
     }
 }
 
+/* Supports only one pushback character.  */
 static void
 phase2_ungetc (int c)
 {
@@ -656,8 +658,7 @@ phase7_getuc (int quote_char,
 /* Number of pending open parentheses/braces/brackets.  */
 static int open_pbb;
 
-/* Maximum used guaranteed to be < 2.  */
-static token_ty phase5_pushback[2];
+static token_ty phase5_pushback[1];
 static int phase5_pushback_length;
 
 static void
@@ -945,6 +946,7 @@ phase5_get (token_ty *tp)
     }
 }
 
+/* Supports only one pushback token.  */
 static void
 phase5_unget (token_ty *tp)
 {
index 9efbb6dedc324e0c2defb33aa3c45d1c6636ecd4..5feda599c6cf5cd2f9c6028015d78e4bd7ec73b2 100644 (file)
@@ -172,11 +172,9 @@ do_ungetc (int c)
 }
 
 
-/* Remove backslash followed by newline from the input stream.
-   Cope with potentially 2 characters of pushback.  */
+/* Remove backslash followed by newline from the input stream.  */
 
-/* Maximum used guaranteed to be < 4.  */
-static int phase1_pushback[4];
+static int phase1_pushback[1];
 static int phase1_pushback_length;
 
 static int
@@ -206,6 +204,7 @@ phase1_getc ()
     }
 }
 
+/* Supports only one pushback character.  */
 static void
 phase1_ungetc (int c)
 {
@@ -498,13 +497,9 @@ is_operator_start (int c)
 #define OPENING_BACKQUOTE (2 * (UCHAR_MAX + 1) + '`')
 #define CLOSING_BACKQUOTE (3 * (UCHAR_MAX + 1) + '`')
 
-/* Maximum used guaranteed to be < 4.  */
-static int phase2_pushback[4];
+static int phase2_pushback[2];
 static int phase2_pushback_length;
 
-/* Forward declaration of local functions.  */
-static void phase2_ungetc (int c);
-
 /* Return the next character, with backslashes removed.
    The result is QUOTED(c) for some unsigned char c, if the next character
    is escaped sufficiently often to make it a regular constituent character,
@@ -663,6 +658,7 @@ phase2_getc ()
   return (open_singlequote || open_doublequote ? QUOTED (c) : c);
 }
 
+/* Supports 2 characters of pushback.  */
 static void
 phase2_ungetc (int c)
 {
index 15a8e6513695433f6af3af5359d1874964be2200..54768032f8e62de898d5c06d8dffed29c17387e3 100644 (file)
@@ -96,6 +96,7 @@ phase1_getc ()
   return c;
 }
 
+/* Supports only one pushback character.  */
 static void
 phase1_ungetc (int c)
 {
@@ -178,8 +179,7 @@ struct token_ty
 
 /* 2. Combine characters into tokens.  Discard comments and whitespace.  */
 
-/* Maximum used guaranteed to be < 2.  */
-static token_ty phase2_pushback[2];
+static token_ty phase2_pushback[1];
 static int phase2_pushback_length;
 
 static void
@@ -434,6 +434,7 @@ phase2_get (token_ty *tp)
     }
 }
 
+/* Supports only one pushback token.  */
 static void
 phase2_unget (token_ty *tp)
 {
index f35143a7671dc133b7562afa41bff2c1c03384aa..1b4d64a879de93b72061ac3ff1035565b6d89599 100644 (file)
@@ -167,13 +167,12 @@ do_ungetc (int c)
 
 
 /* Combine backslash followed by newline and additional whitespace to
-   a single space.  Cope with potentially 2 characters of pushback.  */
+   a single space.  */
 
 /* An int that becomes a space when casted to 'unsigned char'.  */
 #define BS_NL (UCHAR_MAX + 1 + ' ')
 
-/* Maximum used guaranteed to be < 4.  */
-static int phase1_pushback[4];
+static int phase1_pushback[1];
 static int phase1_pushback_length;
 
 static int
@@ -209,6 +208,7 @@ phase1_getc ()
   return BS_NL;
 }
 
+/* Supports only one pushback character.  */
 static void
 phase1_ungetc (int c)
 {
@@ -239,8 +239,7 @@ phase1_ungetc (int c)
 /* An int that becomes a closing brace when casted to 'unsigned char'.  */
 #define CL_BRACE (UCHAR_MAX + 1 + '}')
 
-/* Maximum used guaranteed to be < 4.  */
-static int phase2_pushback[4];
+static int phase2_pushback[2];
 static int phase2_pushback_length;
 
 /* Brace nesting depth inside the current character group.  */
@@ -287,6 +286,7 @@ phase2_getc ()
   return c;
 }
 
+/* Supports 2 characters of pushback.  */
 static void
 phase2_ungetc (int c)
 {
@@ -570,7 +570,8 @@ static enum word_type read_command_list (int looking_for,
                                         flag_context_ty outer_context);
 
 /* Accumulate tokens into the given word.
-   'looking_for' denotes a parse terminator combination.  */
+   'looking_for' denotes a parse terminator combination.
+   Return the first character past the token.  */
 static int
 accumulate_word (struct word *wp, enum terminator looking_for,
                 flag_context_ty context)
index e13ed185d3a5e3bc9ad1c98c081d381926cdaf0d..8a8beae378b175471224bb754425bad302746346 100644 (file)
@@ -102,6 +102,7 @@ phase1_getc ()
   return c;
 }
 
+/* Supports only one pushback character.  */
 static void
 phase1_ungetc (int c)
 {
@@ -290,6 +291,7 @@ phase2_getc ()
     return c;
 }
 
+/* Supports only one pushback character.  */
 static void
 phase2_ungetc (int c)
 {