From cef65d39eb422917ddbd51174c577c741f0c5fd3 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Wed, 11 Sep 2024 14:09:08 +0200 Subject: [PATCH] xgettext: Refactor. * 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 | 14 ++++++------- gettext-tools/src/x-c.c | 42 +++++++++++++++++++------------------- gettext-tools/src/x-vala.c | 42 +++++++++++++++++++------------------- gettext-tools/src/x-ycp.c | 12 +++++------ 4 files changed, 55 insertions(+), 55 deletions(-) diff --git a/gettext-tools/src/x-awk.c b/gettext-tools/src/x-awk.c index f304ba2aa..71edaf6d0 100644 --- a/gettext-tools/src/x-awk.c +++ b/gettext-tools/src/x-awk.c @@ -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) { diff --git a/gettext-tools/src/x-c.c b/gettext-tools/src/x-c.c index 7b43c245f..5b7125d50 100644 --- a/gettext-tools/src/x-c.c +++ b/gettext-tools/src/x-c.c @@ -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)) { diff --git a/gettext-tools/src/x-vala.c b/gettext-tools/src/x-vala.c index 74cfbeea4..bfe2a2bb0 100644 --- a/gettext-tools/src/x-vala.c +++ b/gettext-tools/src/x-vala.c @@ -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)) { diff --git a/gettext-tools/src/x-ycp.c b/gettext-tools/src/x-ycp.c index d55400c2c..7fb560e38 100644 --- a/gettext-tools/src/x-ycp.c +++ b/gettext-tools/src/x-ycp.c @@ -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) { -- 2.47.3