From: Bruno Haible Date: Sun, 15 Jun 2003 13:45:55 +0000 (+0000) Subject: Perl needs two formatstring parsers, not just one. X-Git-Tag: v0.13~444 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=32d7edc1a0f6f0436d17006dfdbd6cd93900d44d;p=thirdparty%2Fgettext.git Perl needs two formatstring parsers, not just one. --- diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index 949afa467..40cf7dc2f 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,30 @@ +2003-06-15 Bruno Haible + + * xgettext.c (current_formatstring_parser1, + current_formatstring_parser2): New variables, replacing + current_formatstring_parser. + (remember_a_message, remember_a_message_plural): Try both + formatstring parsers. + (language_to_extractor): Allow two formatstring parsers per language, + not just one. + * x-perl.h (SCANNERS_PERL): Add formatstring_c as secondary format + string parser. + * x-awk.h (SCANNERS_AWK): Update. + * x-c.h (SCANNERS_C): Update. + * x-elisp.h (SCANNERS_ELISP): Update. + * x-glade.h (SCANNERS_GLADE): Update. + * x-java.h (SCANNERS_JAVA): Update. + * x-librep.h (SCANNERS_LIBREP): Update. + * x-lisp.h (SCANNERS_LISP): Update. + * x-php.h (SCANNERS_PHP): Update. + * x-po.h (SCANNERS_PO): Update. + * x-properties.h (SCANNERS_PROPERTIES): Update. + * x-python.h (SCANNERS_PYTHON): Update. + * x-rst.h (SCANNERS_RST): Update. + * x-smalltalk.h (SCANNERS_SMALLTALK): Update. + * x-tcl.h (SCANNERS_TCL): Update. + * x-ycp.h (SCANNERS_YCP): Update. + 2003-06-15 Bruno Haible * x-perl.c (case_whitespace): New macro. diff --git a/gettext-tools/src/x-awk.h b/gettext-tools/src/x-awk.h index a9a2c7f56..44ca341db 100644 --- a/gettext-tools/src/x-awk.h +++ b/gettext-tools/src/x-awk.h @@ -1,5 +1,5 @@ /* xgettext awk backend. - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002-2003 Free Software Foundation, Inc. Written by Bruno Haible , 2002. This program is free software; you can redistribute it and/or modify @@ -21,7 +21,7 @@ { "awk", "awk" }, \ #define SCANNERS_AWK \ - { "awk", extract_awk, &formatstring_awk }, \ + { "awk", extract_awk, &formatstring_awk, NULL }, \ /* Scan an awk file and add its translatable strings to mdlp. */ extern void extract_awk (FILE *fp, const char *real_filename, diff --git a/gettext-tools/src/x-c.h b/gettext-tools/src/x-c.h index 738e19f2a..ed1fd3058 100644 --- a/gettext-tools/src/x-c.h +++ b/gettext-tools/src/x-c.h @@ -1,5 +1,5 @@ /* xgettext C/C++/ObjectiveC backend. - Copyright (C) 2001-2002 Free Software Foundation, Inc. + Copyright (C) 2001-2003 Free Software Foundation, Inc. Written by Bruno Haible , 2001. This program is free software; you can redistribute it and/or modify @@ -31,9 +31,9 @@ { "m", "ObjectiveC" }, \ #define SCANNERS_C \ - { "C", extract_c, &formatstring_c }, \ - { "C++", extract_c, &formatstring_c }, \ - { "ObjectiveC", extract_c, &formatstring_c }, \ + { "C", extract_c, &formatstring_c, NULL }, \ + { "C++", extract_c, &formatstring_c, NULL }, \ + { "ObjectiveC", extract_c, &formatstring_c, NULL }, \ /* Scan a C/C++/ObjectiveC file and add its translatable strings to mdlp. */ extern void extract_c (FILE *fp, const char *real_filename, diff --git a/gettext-tools/src/x-elisp.h b/gettext-tools/src/x-elisp.h index 9dfe1d658..a9d338e9d 100644 --- a/gettext-tools/src/x-elisp.h +++ b/gettext-tools/src/x-elisp.h @@ -1,5 +1,5 @@ /* xgettext Emacs Lisp backend. - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002-2003 Free Software Foundation, Inc. Written by Bruno Haible , 2002. This program is free software; you can redistribute it and/or modify @@ -21,7 +21,7 @@ { "el", "EmacsLisp" }, \ #define SCANNERS_ELISP \ - { "EmacsLisp", extract_elisp, &formatstring_elisp }, \ + { "EmacsLisp", extract_elisp, &formatstring_elisp, NULL }, \ /* Scan an Emacs Lisp file and add its translatable strings to mdlp. */ extern void extract_elisp (FILE *fp, const char *real_filename, diff --git a/gettext-tools/src/x-glade.h b/gettext-tools/src/x-glade.h index 0e750ff8f..b7872fd0d 100644 --- a/gettext-tools/src/x-glade.h +++ b/gettext-tools/src/x-glade.h @@ -22,7 +22,7 @@ { "glade2", "glade" }, \ #define SCANNERS_GLADE \ - { "glade", extract_glade, NULL }, \ + { "glade", extract_glade, NULL, NULL }, \ /* Scan a glade XML file and add its translatable strings to mdlp. */ extern void extract_glade (FILE *fp, const char *real_filename, diff --git a/gettext-tools/src/x-java.h b/gettext-tools/src/x-java.h index fd30fcd38..50d17f6ab 100644 --- a/gettext-tools/src/x-java.h +++ b/gettext-tools/src/x-java.h @@ -1,5 +1,5 @@ /* xgettext Java backend. - Copyright (C) 2001-2002 Free Software Foundation, Inc. + Copyright (C) 2001-2003 Free Software Foundation, Inc. Written by Tommy Johansson , 2001. This program is free software; you can redistribute it and/or modify @@ -20,7 +20,7 @@ { "java", "Java" }, \ #define SCANNERS_JAVA \ - { "Java", extract_java, &formatstring_java }, \ + { "Java", extract_java, &formatstring_java, NULL }, \ extern void extract_java (FILE *fp, const char *real_filename, const char *logical_filename, diff --git a/gettext-tools/src/x-librep.h b/gettext-tools/src/x-librep.h index 9280d7efd..2dc4cc5f5 100644 --- a/gettext-tools/src/x-librep.h +++ b/gettext-tools/src/x-librep.h @@ -1,5 +1,5 @@ /* xgettext librep backend. - Copyright (C) 2001-2002 Free Software Foundation, Inc. + Copyright (C) 2001-2003 Free Software Foundation, Inc. Written by Bruno Haible , 2001. This program is free software; you can redistribute it and/or modify @@ -21,7 +21,7 @@ { "jl", "librep" }, \ #define SCANNERS_LIBREP \ - { "librep", extract_librep, &formatstring_librep }, \ + { "librep", extract_librep, &formatstring_librep, NULL }, \ /* Scan a librep file and add its translatable strings to mdlp. */ extern void extract_librep (FILE *fp, const char *real_filename, diff --git a/gettext-tools/src/x-lisp.h b/gettext-tools/src/x-lisp.h index b7377b1f8..63c447cd2 100644 --- a/gettext-tools/src/x-lisp.h +++ b/gettext-tools/src/x-lisp.h @@ -1,5 +1,5 @@ /* xgettext Lisp backend. - Copyright (C) 2001-2002 Free Software Foundation, Inc. + Copyright (C) 2001-2003 Free Software Foundation, Inc. Written by Bruno Haible , 2001. This program is free software; you can redistribute it and/or modify @@ -21,7 +21,7 @@ { "lisp", "Lisp" }, \ #define SCANNERS_LISP \ - { "Lisp", extract_lisp, &formatstring_lisp }, \ + { "Lisp", extract_lisp, &formatstring_lisp, NULL }, \ /* Scan a Lisp file and add its translatable strings to mdlp. */ extern void extract_lisp (FILE *fp, const char *real_filename, diff --git a/gettext-tools/src/x-perl.h b/gettext-tools/src/x-perl.h index 3e7031fee..28f3e4ebb 100644 --- a/gettext-tools/src/x-perl.h +++ b/gettext-tools/src/x-perl.h @@ -24,7 +24,7 @@ { "cgi", "perl" }, \ #define SCANNERS_PERL \ - { "perl", extract_perl, &formatstring_perl }, \ + { "perl", extract_perl, &formatstring_c, &formatstring_perl }, \ /* Scan a Perl file and add its translatable strings to mdlp. */ extern void extract_perl (FILE *fp, const char *real_filename, diff --git a/gettext-tools/src/x-php.h b/gettext-tools/src/x-php.h index 603e40079..7ec6cddaf 100644 --- a/gettext-tools/src/x-php.h +++ b/gettext-tools/src/x-php.h @@ -1,5 +1,5 @@ /* xgettext PHP backend. - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002-2003 Free Software Foundation, Inc. Written by Bruno Haible , 2002. This program is free software; you can redistribute it and/or modify @@ -23,7 +23,7 @@ { "php4", "PHP" }, \ #define SCANNERS_PHP \ - { "PHP", extract_php, &formatstring_php }, \ + { "PHP", extract_php, &formatstring_php, NULL }, \ /* Scan a PHP file and add its translatable strings to mdlp. */ extern void extract_php (FILE *fp, const char *real_filename, diff --git a/gettext-tools/src/x-po.h b/gettext-tools/src/x-po.h index 986d6e2da..72ae8b05a 100644 --- a/gettext-tools/src/x-po.h +++ b/gettext-tools/src/x-po.h @@ -1,5 +1,5 @@ /* xgettext PO backend. - Copyright (C) 2001-2002 Free Software Foundation, Inc. + Copyright (C) 2001-2003 Free Software Foundation, Inc. Written by Bruno Haible , 2001. This program is free software; you can redistribute it and/or modify @@ -22,7 +22,7 @@ { "pot", "PO" }, \ #define SCANNERS_PO \ - { "PO", extract_po, NULL }, \ + { "PO", extract_po, NULL, NULL }, \ /* Scan a PO file and add its translatable strings to mdlp. */ extern void extract_po (FILE *fp, const char *real_filename, diff --git a/gettext-tools/src/x-properties.h b/gettext-tools/src/x-properties.h index e9e5f1e91..10c1acb04 100644 --- a/gettext-tools/src/x-properties.h +++ b/gettext-tools/src/x-properties.h @@ -21,7 +21,7 @@ { "properties", "JavaProperties" }, \ #define SCANNERS_PROPERTIES \ - { "JavaProperties", extract_properties, NULL }, \ + { "JavaProperties", extract_properties, NULL, NULL }, \ /* Scan a JavaProperties file and add its translatable strings to mdlp. */ extern void extract_properties (FILE *fp, const char *real_filename, diff --git a/gettext-tools/src/x-python.h b/gettext-tools/src/x-python.h index e2edeeec4..af96927d0 100644 --- a/gettext-tools/src/x-python.h +++ b/gettext-tools/src/x-python.h @@ -1,5 +1,5 @@ /* xgettext Python backend. - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002-2003 Free Software Foundation, Inc. Written by Bruno Haible , 2002. This program is free software; you can redistribute it and/or modify @@ -21,7 +21,7 @@ { "py", "Python" }, \ #define SCANNERS_PYTHON \ - { "Python", extract_python, &formatstring_python }, \ + { "Python", extract_python, &formatstring_python, NULL }, \ /* Scan a Python file and add its translatable strings to mdlp. */ extern void extract_python (FILE *fp, const char *real_filename, diff --git a/gettext-tools/src/x-rst.h b/gettext-tools/src/x-rst.h index de0b152bf..4dfe206e7 100644 --- a/gettext-tools/src/x-rst.h +++ b/gettext-tools/src/x-rst.h @@ -1,5 +1,5 @@ /* xgettext RST backend. - Copyright (C) 2001-2002 Free Software Foundation, Inc. + Copyright (C) 2001-2003 Free Software Foundation, Inc. Written by Bruno Haible , 2001. This program is free software; you can redistribute it and/or modify @@ -21,7 +21,7 @@ { "rst", "RST" }, \ #define SCANNERS_RST \ - { "RST", extract_rst, &formatstring_pascal }, \ + { "RST", extract_rst, &formatstring_pascal, NULL }, \ /* Scan an RST file and add its translatable strings to mdlp. */ extern void extract_rst (FILE *fp, const char *real_filename, diff --git a/gettext-tools/src/x-smalltalk.h b/gettext-tools/src/x-smalltalk.h index ca5a9eb5f..407ce4461 100644 --- a/gettext-tools/src/x-smalltalk.h +++ b/gettext-tools/src/x-smalltalk.h @@ -1,5 +1,5 @@ /* xgettext Smalltalk backend. - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002-2003 Free Software Foundation, Inc. Written by Bruno Haible , 2002. This program is free software; you can redistribute it and/or modify @@ -21,7 +21,7 @@ { "st", "Smalltalk" }, \ #define SCANNERS_SMALLTALK \ - { "Smalltalk", extract_smalltalk, &formatstring_smalltalk }, \ + { "Smalltalk", extract_smalltalk, &formatstring_smalltalk, NULL }, \ /* Scan a Smalltalk file and add its translatable strings to mdlp. */ extern void extract_smalltalk (FILE *fp, const char *real_filename, diff --git a/gettext-tools/src/x-tcl.h b/gettext-tools/src/x-tcl.h index 494171184..13d155193 100644 --- a/gettext-tools/src/x-tcl.h +++ b/gettext-tools/src/x-tcl.h @@ -1,5 +1,5 @@ /* xgettext Tcl Lisp backend. - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002-2003 Free Software Foundation, Inc. Written by Bruno Haible , 2002. This program is free software; you can redistribute it and/or modify @@ -21,7 +21,7 @@ { "tcl", "Tcl" }, \ #define SCANNERS_TCL \ - { "Tcl", extract_tcl, &formatstring_tcl }, \ + { "Tcl", extract_tcl, &formatstring_tcl, NULL }, \ /* Scan a Tcl file and add its translatable strings to mdlp. */ extern void extract_tcl (FILE *fp, const char *real_filename, diff --git a/gettext-tools/src/x-ycp.h b/gettext-tools/src/x-ycp.h index 3cd31e491..e092452fd 100644 --- a/gettext-tools/src/x-ycp.h +++ b/gettext-tools/src/x-ycp.h @@ -1,5 +1,5 @@ /* xgettext YCP backend. - Copyright (C) 2001-2002 Free Software Foundation, Inc. + Copyright (C) 2001-2003 Free Software Foundation, Inc. Written by Bruno Haible , 2001. This program is free software; you can redistribute it and/or modify @@ -21,7 +21,7 @@ { "ycp", "YCP" }, \ #define SCANNERS_YCP \ - { "YCP", extract_ycp, &formatstring_ycp }, \ + { "YCP", extract_ycp, &formatstring_ycp, NULL }, \ /* Scan an YCP file and add its translatable strings to mdlp. */ extern void extract_ycp (FILE *fp, const char *real_filename, diff --git a/gettext-tools/src/xgettext.c b/gettext-tools/src/xgettext.c index a2287d2cd..c72ca0751 100644 --- a/gettext-tools/src/xgettext.c +++ b/gettext-tools/src/xgettext.c @@ -1005,7 +1005,8 @@ extract_from_file (const char *file_name, extractor_func extractor, /* Language dependent format string parser. NULL if the language has no notion of format strings. */ -static struct formatstring_parser *current_formatstring_parser; +static struct formatstring_parser *current_formatstring_parser1; +static struct formatstring_parser *current_formatstring_parser2; /* Convert the given string from xgettext_current_source_encoding to @@ -1182,7 +1183,8 @@ meta information, not the empty string.\n"))); for (i = 0; i < NFORMATS; i++) { if (is_format[i] == undecided - && formatstring_parsers[i] == current_formatstring_parser) + && (formatstring_parsers[i] == current_formatstring_parser1 + || formatstring_parsers[i] == current_formatstring_parser2)) { struct formatstring_parser *parser = formatstring_parsers[i]; char *invalid_reason = NULL; @@ -1269,7 +1271,8 @@ remember_a_message_plural (message_ty *mp, char *string, lex_pos_ty *pos) the msgid, whether the msgid is a format string, examine the msgid_plural. This is a heuristic. */ for (i = 0; i < NFORMATS; i++) - if (formatstring_parsers[i] == current_formatstring_parser + if ((formatstring_parsers[i] == current_formatstring_parser1 + || formatstring_parsers[i] == current_formatstring_parser2) && (mp->is_format[i] == undecided || mp->is_format[i] == possible)) { struct formatstring_parser *parser = formatstring_parsers[i]; @@ -1445,7 +1448,8 @@ language_to_extractor (const char *name) { const char *name; extractor_func func; - struct formatstring_parser *formatstring_parser; + struct formatstring_parser *formatstring_parser1; + struct formatstring_parser *formatstring_parser2; }; static table_ty table[] = @@ -1476,7 +1480,8 @@ language_to_extractor (const char *name) if (strcasecmp (name, tp->name) == 0) { /* XXX Ugly side effect. */ - current_formatstring_parser = tp->formatstring_parser; + current_formatstring_parser1 = tp->formatstring_parser1; + current_formatstring_parser2 = tp->formatstring_parser2; return tp->func; }