From: Bruno Haible Date: Mon, 29 Dec 2003 11:58:04 +0000 (+0000) Subject: Reduce the size of the pushback buffers. X-Git-Tag: v0.14~104 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=99f5cb5cc75abfcf1c28ad2be0ac5a904b02b9f5;p=thirdparty%2Fgettext.git Reduce the size of the pushback buffers. --- diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index 41f392259..d259c5718 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,24 @@ +2003-12-14 Bruno Haible + + * 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 Assume automake-1.8. diff --git a/gettext-tools/src/x-awk.c b/gettext-tools/src/x-awk.c index a90234036..e9e606113 100644 --- a/gettext-tools/src/x-awk.c +++ b/gettext-tools/src/x-awk.c @@ -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) { diff --git a/gettext-tools/src/x-c.c b/gettext-tools/src/x-c.c index 5d5e092a5..22b9e40ee 100644 --- a/gettext-tools/src/x-c.c +++ b/gettext-tools/src/x-c.c @@ -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) { diff --git a/gettext-tools/src/x-java.c b/gettext-tools/src/x-java.c index fd3d5c298..b18f19677 100644 --- a/gettext-tools/src/x-java.c +++ b/gettext-tools/src/x-java.c @@ -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) { diff --git a/gettext-tools/src/x-perl.c b/gettext-tools/src/x-perl.c index 86ae68f35..9fe5b8192 100644 --- a/gettext-tools/src/x-perl.c +++ b/gettext-tools/src/x-perl.c @@ -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) { diff --git a/gettext-tools/src/x-php.c b/gettext-tools/src/x-php.c index 6a8310be3..db71b3982 100644 --- a/gettext-tools/src/x-php.c +++ b/gettext-tools/src/x-php.c @@ -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) { diff --git a/gettext-tools/src/x-python.c b/gettext-tools/src/x-python.c index 8b19d8253..fb53dc350 100644 --- a/gettext-tools/src/x-python.c +++ b/gettext-tools/src/x-python.c @@ -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) { diff --git a/gettext-tools/src/x-sh.c b/gettext-tools/src/x-sh.c index 9efbb6ded..5feda599c 100644 --- a/gettext-tools/src/x-sh.c +++ b/gettext-tools/src/x-sh.c @@ -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) { diff --git a/gettext-tools/src/x-smalltalk.c b/gettext-tools/src/x-smalltalk.c index 15a8e6513..54768032f 100644 --- a/gettext-tools/src/x-smalltalk.c +++ b/gettext-tools/src/x-smalltalk.c @@ -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) { diff --git a/gettext-tools/src/x-tcl.c b/gettext-tools/src/x-tcl.c index f35143a76..1b4d64a87 100644 --- a/gettext-tools/src/x-tcl.c +++ b/gettext-tools/src/x-tcl.c @@ -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) diff --git a/gettext-tools/src/x-ycp.c b/gettext-tools/src/x-ycp.c index e13ed185d..8a8beae37 100644 --- a/gettext-tools/src/x-ycp.c +++ b/gettext-tools/src/x-ycp.c @@ -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) {