From: Bruno Haible Date: Tue, 25 Nov 2003 11:07:27 +0000 (+0000) Subject: Fix the extraction of tagged comments. X-Git-Tag: v0.13~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e69bdd7e5b115d0c5ec8de42fe0e248e14bbfb2e;p=thirdparty%2Fgettext.git Fix the extraction of tagged comments. --- diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index 60ab037bf..8f60594b4 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,20 @@ +2003-11-22 Bruno Haible + + * x-c.c (phase4_getc): Skip leading whitespace in C++ style comments + as well. + * x-sh.c (read_word): Skip leading whitespace in comments. + * x-lisp.c (read_object): Skip leading whitespace in single-line + comments as well. + * x-elisp.c (read_object): Skip leading whitespace in comments. + * x-librep.c (read_object): Skip leading whitespace in single-line + comments as well. + * x-java.c (phase4_getc): Skip leading whitespace in C++ style comments + as well. + * x-awk.c (phase2_getc): Skip leading whitespace in comments. + * x-ycp.c (phase2_getc): Skip leading whitespace in single-line + comments as well. + * x-tcl.c (read_command): Skip leading whitespace in comments. + 2003-11-24 Bruno Haible * format-lisp.c (check_params): Use ngettext for one of the messages. diff --git a/gettext-tools/src/x-awk.c b/gettext-tools/src/x-awk.c index 933daedd0..a90234036 100644 --- a/gettext-tools/src/x-awk.c +++ b/gettext-tools/src/x-awk.c @@ -187,12 +187,16 @@ phase2_getc () c = phase1_getc (); if (c == '\n' || c == EOF) break; - if (buflen >= bufmax) + /* We skip all leading white space, but not EOLs. */ + if (!(buflen == 0 && (c == ' ' || c == '\t'))) { - bufmax = 2 * bufmax + 10; - buffer = xrealloc (buffer, bufmax); + if (buflen >= bufmax) + { + bufmax = 2 * bufmax + 10; + buffer = xrealloc (buffer, bufmax); + } + buffer[buflen++] = c; } - buffer[buflen++] = c; } if (buflen >= bufmax) { diff --git a/gettext-tools/src/x-c.c b/gettext-tools/src/x-c.c index cfff2d32d..d38bc6aad 100644 --- a/gettext-tools/src/x-c.c +++ b/gettext-tools/src/x-c.c @@ -662,7 +662,9 @@ phase4_getc () c = phase3_getc (); if (c == '\n' || c == EOF) break; - comment_add (c); + /* We skip all leading white space, but not EOLs. */ + if (!(buflen == 0 && (c == ' ' || c == '\t'))) + comment_add (c); } comment_line_end (0); last_comment_line = newline_count; diff --git a/gettext-tools/src/x-elisp.c b/gettext-tools/src/x-elisp.c index d1ecabc7b..03251636a 100644 --- a/gettext-tools/src/x-elisp.c +++ b/gettext-tools/src/x-elisp.c @@ -864,7 +864,11 @@ read_object (struct object *op, bool first_in_list, bool new_backquote_flag, if (c != ';') all_semicolons = false; if (!all_semicolons) - comment_add (c); + { + /* We skip all leading white space, but not EOLs. */ + if (!(buflen == 0 && (c == ' ' || c == '\t'))) + comment_add (c); + } } comment_line_end (0); continue; diff --git a/gettext-tools/src/x-java.c b/gettext-tools/src/x-java.c index eb38a8482..04a61c33b 100644 --- a/gettext-tools/src/x-java.c +++ b/gettext-tools/src/x-java.c @@ -766,7 +766,9 @@ phase4_getc () c = phase3_getc (); if (RED (c) == '\n' || c == P2_EOF) break; - comment_add (c); + /* We skip all leading white space, but not EOLs. */ + if (!(comment_at_start () && (RED (c) == ' ' || RED (c) == '\t'))) + comment_add (c); } phase3_ungetc (c); /* push back the newline, to decrement line_number */ comment_line_end (0); diff --git a/gettext-tools/src/x-librep.c b/gettext-tools/src/x-librep.c index 106b80867..afa99fc3b 100644 --- a/gettext-tools/src/x-librep.c +++ b/gettext-tools/src/x-librep.c @@ -800,7 +800,11 @@ read_object (struct object *op, flag_context_ty outer_context) if (c != ';') all_semicolons = false; if (!all_semicolons) - comment_add (c); + { + /* We skip all leading white space, but not EOLs. */ + if (!(buflen == 0 && (c == ' ' || c == '\t'))) + comment_add (c); + } } comment_line_end (0); continue; diff --git a/gettext-tools/src/x-lisp.c b/gettext-tools/src/x-lisp.c index 0c687ee9a..c3c8a556b 100644 --- a/gettext-tools/src/x-lisp.c +++ b/gettext-tools/src/x-lisp.c @@ -1174,7 +1174,11 @@ read_object (struct object *op, flag_context_ty outer_context) if (c != ';') all_semicolons = false; if (!all_semicolons) - comment_add (c); + { + /* We skip all leading white space, but not EOLs. */ + if (!(buflen == 0 && (c == ' ' || c == '\t'))) + comment_add (c); + } } comment_line_end (0); continue; diff --git a/gettext-tools/src/x-sh.c b/gettext-tools/src/x-sh.c index 2d8afa743..de634065e 100644 --- a/gettext-tools/src/x-sh.c +++ b/gettext-tools/src/x-sh.c @@ -714,7 +714,9 @@ read_word (struct word *wp, int looking_for, flag_context_ty context) c = phase1_getc (); if (c == EOF || c == '\n') break; - comment_add (c); + /* We skip all leading white space, but not EOLs. */ + if (!(buflen == 0 && (c == ' ' || c == '\t'))) + comment_add (c); } comment_line_end (); } diff --git a/gettext-tools/src/x-tcl.c b/gettext-tools/src/x-tcl.c index bfad46077..f35143a76 100644 --- a/gettext-tools/src/x-tcl.c +++ b/gettext-tools/src/x-tcl.c @@ -830,7 +830,9 @@ read_command (int looking_for, flag_context_ty outer_context) c = phase2_getc (); if (c == EOF || c == CL_BRACE || c == '\n') break; - comment_add (c); + /* We skip all leading white space, but not EOLs. */ + if (!(buflen == 0 && (c == ' ' || c == '\t'))) + comment_add (c); } comment_line_end (); continue; diff --git a/gettext-tools/src/x-ycp.c b/gettext-tools/src/x-ycp.c index 80a8cfd83..e13ed185d 100644 --- a/gettext-tools/src/x-ycp.c +++ b/gettext-tools/src/x-ycp.c @@ -159,12 +159,16 @@ phase2_getc () c = phase1_getc (); if (c == '\n' || c == EOF) break; - if (buflen >= bufmax) + /* We skip all leading white space, but not EOLs. */ + if (!(buflen == 0 && (c == ' ' || c == '\t'))) { - bufmax = 2 * bufmax + 10; - buffer = xrealloc (buffer, bufmax); + if (buflen >= bufmax) + { + bufmax = 2 * bufmax + 10; + buffer = xrealloc (buffer, bufmax); + } + buffer[buflen++] = c; } - buffer[buflen++] = c; } if (buflen >= bufmax) { @@ -201,7 +205,7 @@ phase2_getc () if (c == EOF) break; /* We skip all leading white space, but not EOLs. */ - if (buflen == 0 && isspace (c) && c != '\n') + if (buflen == 0 && (c == ' ' || c == '\t')) continue; if (buflen >= bufmax) { @@ -260,12 +264,16 @@ phase2_getc () c = phase1_getc (); if (c == '\n' || c == EOF) break; - if (buflen >= bufmax) + /* We skip all leading white space, but not EOLs. */ + if (!(buflen == 0 && (c == ' ' || c == '\t'))) { - bufmax = 2 * bufmax + 10; - buffer = xrealloc (buffer, bufmax); + if (buflen >= bufmax) + { + bufmax = 2 * bufmax + 10; + buffer = xrealloc (buffer, bufmax); + } + buffer[buflen++] = c; } - buffer[buflen++] = c; } if (buflen >= bufmax) { diff --git a/gettext-tools/tests/ChangeLog b/gettext-tools/tests/ChangeLog index a1963b9c7..344239e13 100644 --- a/gettext-tools/tests/ChangeLog +++ b/gettext-tools/tests/ChangeLog @@ -1,3 +1,20 @@ +2003-11-22 Bruno Haible + + * xgettext-c-9: New file. + * xgettext-sh-2: New file. + * xgettext-python-2: New file. + * xgettext-lisp-1: New file. + * xgettext-elisp-1: New file. + * xgettext-librep-1: New file. + * xgettext-smalltalk-1: New file. + * xgettext-java-5: New file. + * xgettext-awk-1: New file. + * xgettext-ycp-2: New file. + * xgettext-tcl-2: New file. + * xgettext-perl-5: New file. + * xgettext-php-1: New file. + * Makefile.am (TESTS): Add them. + 2003-11-15 Bruno Haible * Makefile.am (AM_CPPFLAGS): Renamed from INCLUDES. diff --git a/gettext-tools/tests/Makefile.am b/gettext-tools/tests/Makefile.am index 54bc68b9b..ffbe12c9c 100644 --- a/gettext-tools/tests/Makefile.am +++ b/gettext-tools/tests/Makefile.am @@ -57,19 +57,27 @@ TESTS = gettext-1 gettext-2 \ msguniq-1 msguniq-2 msguniq-3 msguniq-4 \ xgettext-1 xgettext-2 xgettext-3 xgettext-4 xgettext-5 xgettext-6 \ xgettext-7 \ + xgettext-awk-1 \ xgettext-c-1 xgettext-c-2 xgettext-c-3 xgettext-c-4 xgettext-c-5 \ - xgettext-c-6 xgettext-c-7 xgettext-c-8 \ + xgettext-c-6 xgettext-c-7 xgettext-c-8 xgettext-c-9 \ + xgettext-elisp-1 \ xgettext-glade-1 xgettext-glade-2 xgettext-glade-3 \ xgettext-java-1 xgettext-java-2 xgettext-java-3 xgettext-java-4 \ + xgettext-java-5 \ + xgettext-librep-1 \ + xgettext-lisp-1 \ xgettext-objc-1 \ xgettext-perl-1 xgettext-perl-2 xgettext-perl-3 xgettext-perl-4 \ + xgettext-perl-5 \ + xgettext-php-1 \ xgettext-po-1 \ xgettext-properties-1 \ - xgettext-python-1 \ - xgettext-sh-1 \ + xgettext-python-1 xgettext-python-2 \ + xgettext-sh-1 xgettext-sh-2 \ + xgettext-smalltalk-1 \ xgettext-stringtable-1 \ - xgettext-tcl-1 \ - xgettext-ycp-1 \ + xgettext-tcl-1 xgettext-tcl-2 \ + xgettext-ycp-1 xgettext-ycp-2 \ format-awk-1 format-awk-2 \ format-c-1 format-c-2 format-c-3 format-c-4 \ format-elisp-1 format-elisp-2 \