]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
xgettext: Define alternate parser signature for the Ruby support.
authorBruno Haible <bruno@clisp.org>
Sun, 26 Apr 2020 21:51:23 +0000 (23:51 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 26 Apr 2020 22:23:15 +0000 (00:23 +0200)
* gettext-tools/src/xgettext.c (extract_from_stream_func): Renamed from
extractor_func.
(extract_from_file_func): New type.
(struct extractor_ty): Rename field func to extract_from_stream. New field
extract_from_file.
(main): Consider both fields.
(xgettext_find_file): New function.
(extract_from_file): Add alternative code for when the other extraction function
is defined.
(language_to_extractor): In the table, rename field func to extract_from_stream,
and add new field extract_from_file.
* gettext-tools/src/x-*.h (SCANNERS_*): Update.

27 files changed:
gettext-tools/src/x-appdata.h
gettext-tools/src/x-awk.h
gettext-tools/src/x-c.h
gettext-tools/src/x-csharp.h
gettext-tools/src/x-desktop.h
gettext-tools/src/x-elisp.h
gettext-tools/src/x-glade.h
gettext-tools/src/x-gsettings.h
gettext-tools/src/x-java.h
gettext-tools/src/x-javascript.h
gettext-tools/src/x-librep.h
gettext-tools/src/x-lisp.h
gettext-tools/src/x-lua.h
gettext-tools/src/x-perl.h
gettext-tools/src/x-php.h
gettext-tools/src/x-po.h
gettext-tools/src/x-properties.h
gettext-tools/src/x-python.h
gettext-tools/src/x-rst.h
gettext-tools/src/x-scheme.h
gettext-tools/src/x-sh.h
gettext-tools/src/x-smalltalk.h
gettext-tools/src/x-stringtable.h
gettext-tools/src/x-tcl.h
gettext-tools/src/x-vala.h
gettext-tools/src/x-ycp.h
gettext-tools/src/xgettext.c

index 5d13989bca117abb3152e9b944fd3833c0cf4559..bf85997bc7a90919eed100a25911d6af65470eb0 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext AppData file backend.
-   Copyright (C) 2002-2003, 2006, 2013, 2015, 2017-2018 Free Software Foundation, Inc.
+   Copyright (C) 2002-2003, 2006, 2013, 2015, 2017-2018, 2020 Free Software Foundation, Inc.
    Written by Philip Withnall <philip.withnall@collabora.co.uk>, 2015.
 
    This program is free software: you can redistribute it and/or modify
@@ -32,7 +32,7 @@ extern "C" {
 #define EXTENSIONS_APPDATA
 
 #define SCANNERS_APPDATA \
-  { "appdata", NULL, NULL, NULL, NULL },
+  { "appdata", NULL, NULL, NULL, NULL, NULL },
 
 
 #ifdef __cplusplus
index af35d3711ec19b252ff3523de349900de78afbc3..a8c7bbd267962cba75dc583e0609ef2b572d6406 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext awk backend.
-   Copyright (C) 2002-2003, 2006, 2014-2015, 2018 Free Software Foundation, Inc.
+   Copyright (C) 2002-2003, 2006, 2014-2015, 2018, 2020 Free Software Foundation, Inc.
    Written by Bruno Haible <haible@clisp.cons.org>, 2002.
 
    This program is free software: you can redistribute it and/or modify
@@ -33,7 +33,7 @@ extern "C" {
   { "twjr",   "awk"   },                                                \
 
 #define SCANNERS_AWK \
-  { "awk",              extract_awk,                                    \
+  { "awk",              extract_awk, NULL,                              \
                         &flag_table_awk, &formatstring_awk, NULL },     \
 
 /* Scan an awk file and add its translatable strings to mdlp.  */
index 323c6187eea05c1d86d681039742b6c5a0dc4d3b..c1635e7f431684fdf4c26a47c130e45a2a65184f 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext C/C++/ObjectiveC backend.
-   Copyright (C) 2001-2003, 2006, 2009, 2014-2015, 2018 Free Software Foundation, Inc.
+   Copyright (C) 2001-2003, 2006, 2009, 2014-2015, 2018, 2020 Free Software Foundation, Inc.
    Written by Bruno Haible <haible@clisp.cons.org>, 2001.
 
    This program is free software: you can redistribute it and/or modify
@@ -41,16 +41,16 @@ extern "C" {
   { "m",      "ObjectiveC" },                                           \
 
 #define SCANNERS_C \
-  { "C",                extract_c,                                      \
+  { "C",                extract_c, NULL,                                \
                         &flag_table_c,                                  \
                         &formatstring_c, NULL },                        \
-  { "C++",              extract_cxx,                                    \
+  { "C++",              extract_cxx, NULL,                              \
                         &flag_table_c,                                  \
                         &formatstring_c, NULL },                        \
-  { "ObjectiveC",       extract_objc,                                   \
+  { "ObjectiveC",       extract_objc, NULL,                             \
                         &flag_table_objc,                               \
                         &formatstring_c, &formatstring_objc },          \
-  { "GCC-source",       extract_c,                                      \
+  { "GCC-source",       extract_c, NULL,                                \
                         &flag_table_gcc_internal,                       \
                         &formatstring_gcc_internal, &formatstring_gfc_internal }, \
 
index 54fb0582c9fc78045455554b66c7b8f4bed8403a..143787e2e5ea0c94a349c2f6b50ece233ad8f526 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext C# backend.
-   Copyright (C) 2003-2004, 2006, 2014, 2018 Free Software Foundation, Inc.
+   Copyright (C) 2003-2004, 2006, 2014, 2018, 2020 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2003.
 
    This program is free software: you can redistribute it and/or modify
@@ -31,7 +31,7 @@ extern "C" {
   { "cs",      "C#"  },                                                 \
 
 #define SCANNERS_CSHARP \
-  { "C#",               extract_csharp,                                   \
+  { "C#",               extract_csharp, NULL,                             \
                         &flag_table_csharp, &formatstring_csharp, NULL }, \
 
 extern void extract_csharp (FILE *fp, const char *real_filename,
index b606530559597651f2b20ad5d683b7941335f018..1a73e629305c7d2728502ee1b10dd02be234fca2 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext Desktop Entry backend.
-   Copyright (C) 2014, 2018 Free Software Foundation, Inc.
+   Copyright (C) 2014, 2018, 2020 Free Software Foundation, Inc.
    Written by Daiki Ueno <ueno@gnu.org>, 2014.
 
    This program is free software: you can redistribute it and/or modify
@@ -31,7 +31,7 @@ extern "C" {
   { "desktop", "Desktop" }, \
 
 #define SCANNERS_DESKTOP \
-  { "Desktop", extract_desktop, NULL, NULL, NULL }, \
+  { "Desktop", extract_desktop, NULL, NULL, NULL, NULL }, \
 
 /* Scan a Desktop Entry file and add its translatable strings to mdlp.  */
 extern void extract_desktop (FILE *fp, const char *real_filename,
index f3806de605c050730695dc94e1805b815f483797..033868e82aabd068aa9ea684395ec840d8e5eed2 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext Emacs Lisp backend.
-   Copyright (C) 2002-2003, 2006, 2014, 2018 Free Software Foundation, Inc.
+   Copyright (C) 2002-2003, 2006, 2014, 2018, 2020 Free Software Foundation, Inc.
    Written by Bruno Haible <haible@clisp.cons.org>, 2002.
 
    This program is free software: you can redistribute it and/or modify
@@ -31,7 +31,7 @@ extern "C" {
   { "el",        "EmacsLisp"     },                                     \
 
 #define SCANNERS_ELISP \
-  { "EmacsLisp",        extract_elisp,                                  \
+  { "EmacsLisp",        extract_elisp, NULL,                            \
                         &flag_table_elisp, &formatstring_elisp, NULL }, \
 
 /* Scan an Emacs Lisp file and add its translatable strings to mdlp.  */
index 1c70bba37297614196d4b1d7cd542eb6cef366c4..d80958b8ceb49d5c87aad9e9a0f1732edd9e7d84 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext glade backend.
-   Copyright (C) 2002-2003, 2006, 2013-2015, 2018 Free Software Foundation, Inc.
+   Copyright (C) 2002-2003, 2006, 2013-2015, 2018, 2020 Free Software Foundation, Inc.
    Written by Bruno Haible <haible@clisp.cons.org>, 2002.
 
    This program is free software: you can redistribute it and/or modify
@@ -36,7 +36,7 @@ extern "C" {
   { "ui",        NULL    },                                          \
 
 #define SCANNERS_GLADE \
-  { "glade",            NULL, NULL, NULL, NULL },                    \
+  { "glade",            NULL, NULL, NULL, NULL, NULL },              \
 
 
 #ifdef __cplusplus
index 2f1da540f87ec5a08c09464edac6fd8f7e9d91c2..c852c4c40c6242c590b4173ab207f17995c9dde8 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext GSettings schema file backend.
-   Copyright (C) 2002-2003, 2006, 2013-2015, 2018 Free Software Foundation, Inc.
+   Copyright (C) 2002-2003, 2006, 2013-2015, 2018, 2020 Free Software Foundation, Inc.
    Written by Daiki Ueno <ueno@gnu.org>, 2013.
 
    This program is free software: you can redistribute it and/or modify
@@ -33,7 +33,7 @@ extern "C" {
   { "gschema.xml", NULL }, \
 
 #define SCANNERS_GSETTINGS \
-  { "gsettings", NULL, NULL, NULL, NULL },      \
+  { "gsettings", NULL, NULL, NULL, NULL, NULL }, \
 
 
 #ifdef __cplusplus
index c46feeee4cc5bbf548ba904d77dbdc8a8048fdef..05e997c55617af231b6edafb36a9987a549f40e4 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext Java backend.
-   Copyright (C) 2001-2003, 2006, 2014, 2018-2019 Free Software Foundation, Inc.
+   Copyright (C) 2001-2003, 2006, 2014, 2018-2020 Free Software Foundation, Inc.
    Written by Tommy Johansson <tommy.johansson@kanalen.org>, 2001.
 
    This program is free software: you can redistribute it and/or modify
@@ -31,7 +31,7 @@ extern "C" {
   { "java",    "Java"  },                                               \
 
 #define SCANNERS_JAVA \
-  { "Java",             extract_java,                                    \
+  { "Java",             extract_java, NULL,                              \
                         &flag_table_java,                                \
                         &formatstring_java, &formatstring_java_printf }, \
 
index 6188750a50c0a3416143e71af07a5fea5660ba4c..09b530704bc2848909acd81915e1be6b62f4146d 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext JavaScript backend.
-   Copyright (C) 2002-2003, 2006, 2010, 2013-2014, 2018 Free Software Foundation, Inc.
+   Copyright (C) 2002-2003, 2006, 2010, 2013-2014, 2018, 2020 Free Software Foundation, Inc.
    This file was written by Andreas Stricker <andy@knitter.ch>, 2010.
    It's based on x-python from Bruno Haible.
 
@@ -32,7 +32,7 @@ extern "C" {
   { "js",        "JavaScript"   },                                        \
 
 #define SCANNERS_JAVASCRIPT \
-  { "JavaScript",       extract_javascript,                               \
+  { "JavaScript",       extract_javascript, NULL,                         \
                         &flag_table_javascript, &formatstring_javascript, NULL }, \
 
 /* Scan a Python file and add its translatable strings to mdlp.  */
index 0da791f5eeea27679e736dfd06a5e333273d056c..b79c875a42201da616ad417a9d7c8f14fb3b7c37 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext librep backend.
-   Copyright (C) 2001-2003, 2006, 2014, 2018 Free Software Foundation, Inc.
+   Copyright (C) 2001-2003, 2006, 2014, 2018, 2020 Free Software Foundation, Inc.
    Written by Bruno Haible <haible@clisp.cons.org>, 2001.
 
    This program is free software: you can redistribute it and/or modify
@@ -31,7 +31,7 @@ extern "C" {
   { "jl",        "librep"     },                                        \
 
 #define SCANNERS_LIBREP \
-  { "librep",           extract_librep,                                   \
+  { "librep",           extract_librep, NULL,                             \
                         &flag_table_librep, &formatstring_librep, NULL }, \
 
 /* Scan a librep file and add its translatable strings to mdlp.  */
index 97b31dccf655504ef19f7a3de2262974fc59e09d..7b7a17a630fdc44996313c7032c9e20eceee2b27 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext Lisp backend.
-   Copyright (C) 2001-2003, 2006, 2014, 2018 Free Software Foundation, Inc.
+   Copyright (C) 2001-2003, 2006, 2014, 2018, 2020 Free Software Foundation, Inc.
    Written by Bruno Haible <haible@clisp.cons.org>, 2001.
 
    This program is free software: you can redistribute it and/or modify
@@ -31,7 +31,7 @@ extern "C" {
   { "lisp",      "Lisp"     },                                          \
 
 #define SCANNERS_LISP \
-  { "Lisp",             extract_lisp,                                   \
+  { "Lisp",             extract_lisp, NULL,                             \
                         &flag_table_lisp, &formatstring_lisp, NULL },   \
 
 /* Scan a Lisp file and add its translatable strings to mdlp.  */
index dca3016aa2c25de90fee3f2c711ef6c15da1ba30..9eb949f2688d37170fee50c8c715fa8cf43faa55 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext Lua backend.
-   Copyright (C) 2011-2014, 2018 Free Software Foundation, Inc.
+   Copyright (C) 2011-2014, 2018, 2020 Free Software Foundation, Inc.
    Written by Ä½ubomír Remák <lubomirrk@lubomirr.eu>, 2011
 
    This program is free software: you can redistribute it and/or modify
@@ -31,7 +31,7 @@ extern "C"
   { "lua",    "Lua"   },                                                \
 
 #define SCANNERS_LUA \
-  { "Lua",             extract_lua,                                     \
+  { "Lua",             extract_lua, NULL,                               \
                        &flag_table_lua, &formatstring_lua, NULL },      \
 
   /* Scan a Lua file and add its translatable strings to mdlp.  */
index b375714c377847921734f703601b3857bc7f9fe1..95948dd37897372d91a89858ba71825599b0446f 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext Perl backend.
-   Copyright (C) 2002-2003, 2006, 2010, 2014, 2018 Free Software Foundation, Inc.
+   Copyright (C) 2002-2003, 2006, 2010, 2014, 2018, 2020 Free Software Foundation, Inc.
    Written by Guido Flohr <guido@imperia.net>, 2002-2003
 
    This program is free software: you can redistribute it and/or modify
@@ -35,7 +35,7 @@ extern "C" {
   { "cgi",   "perl"   },                                                \
 
 #define SCANNERS_PERL \
-  { "perl",             extract_perl,                                   \
+  { "perl",             extract_perl, NULL,                             \
             &flag_table_perl, &formatstring_perl, &formatstring_perl_brace }, \
 
 /* Scan a Perl file and add its translatable strings to mdlp.  */
index f66abe64b1b97cbbc08aaf3304669e676bee9d7b..a95deab3c6f5790c3491d234abeeed79a41e32c7 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext PHP backend.
-   Copyright (C) 2002-2003, 2006, 2014, 2018 Free Software Foundation, Inc.
+   Copyright (C) 2002-2003, 2006, 2014, 2018, 2020 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2002.
 
    This program is free software: you can redistribute it and/or modify
@@ -33,7 +33,7 @@ extern "C" {
   { "php4",   "PHP"   },                                                \
 
 #define SCANNERS_PHP \
-  { "PHP",              extract_php,                                    \
+  { "PHP",              extract_php, NULL,                              \
                         &flag_table_php, &formatstring_php, NULL },     \
 
 /* Scan a PHP file and add its translatable strings to mdlp.  */
index 41708db3636523e69d3078fc31ecdae1e5075fdb..e948d1eb4dc34c5171e4c1acf20b18a3106c7e86 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext PO backend.
-   Copyright (C) 2001-2003, 2006, 2014, 2018 Free Software Foundation, Inc.
+   Copyright (C) 2001-2003, 2006, 2014, 2018, 2020 Free Software Foundation, Inc.
    Written by Bruno Haible <haible@clisp.cons.org>, 2001.
 
    This program is free software: you can redistribute it and/or modify
@@ -32,7 +32,7 @@ extern "C" {
   { "pot",    "PO"    },                                                \
 
 #define SCANNERS_PO \
-  { "PO",               extract_po, NULL, NULL, NULL },                 \
+  { "PO",               extract_po, NULL, NULL, NULL, NULL },           \
 
 /* Scan a PO file and add its translatable strings to mdlp.  */
 extern void extract_po (FILE *fp, const char *real_filename,
index 20d486fcfa2dd1fd76d5599c34c2e498f1f89bde..ff0dc3d58651a784e4e457027cb2e2f5e6d054b9 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext JavaProperties backend.
-   Copyright (C) 2003, 2006, 2014, 2018 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2006, 2014, 2018, 2020 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2003.
 
    This program is free software: you can redistribute it and/or modify
@@ -31,7 +31,7 @@ extern "C" {
   { "properties", "JavaProperties" },                                   \
 
 #define SCANNERS_PROPERTIES \
-  { "JavaProperties",   extract_properties, NULL, NULL, NULL },         \
+  { "JavaProperties",   extract_properties, NULL, NULL, NULL, NULL },   \
 
 /* Scan a JavaProperties file and add its translatable strings to mdlp.  */
 extern void extract_properties (FILE *fp, const char *real_filename,
index d045ee603753e284da5b45b03e7b8ce9e278a8fa..11a74cffb968b8a3de26a71ebd60b1dfd25cdd61 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext Python backend.
-   Copyright (C) 2002-2003, 2006, 2013-2014, 2018 Free Software Foundation, Inc.
+   Copyright (C) 2002-2003, 2006, 2013-2014, 2018, 2020 Free Software Foundation, Inc.
    Written by Bruno Haible <haible@clisp.cons.org>, 2002.
 
    This program is free software: you can redistribute it and/or modify
@@ -31,7 +31,7 @@ extern "C" {
   { "py",        "Python"   },                                          \
 
 #define SCANNERS_PYTHON \
-  { "Python",           extract_python,                                   \
+  { "Python",           extract_python, NULL,                           \
                         &flag_table_python, &formatstring_python, &formatstring_python_brace }, \
 
 /* Scan a Python file and add its translatable strings to mdlp.  */
index a5c2a049563fbe3bbac03aa0a1f65eff57a5346a..6f27496bbd6fca367558aa58a03817be16aa0f12 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext RST/RSJ backend.
-   Copyright (C) 2001-2003, 2006, 2014, 2018 Free Software Foundation, Inc.
+   Copyright (C) 2001-2003, 2006, 2014, 2018, 2020 Free Software Foundation, Inc.
    Written by Bruno Haible <haible@clisp.cons.org>, 2001.
 
    This program is free software: you can redistribute it and/or modify
@@ -32,9 +32,9 @@ extern "C" {
   { "rsj",    "RSJ"   },                                                \
 
 #define SCANNERS_RST \
-  { "RST",              extract_rst,                                    \
+  { "RST",              extract_rst, NULL,                              \
                         NULL, &formatstring_pascal, NULL },             \
-  { "RSJ",              extract_rsj,                                    \
+  { "RSJ",              extract_rsj, NULL,                              \
                         NULL, &formatstring_pascal, NULL },             \
 
 /* Scan an RST file and add its translatable strings to mdlp.  */
index 6e5562b511595f0a57d968aa4424caa9b17f26c6..cff03ac21f82dfe7fd66486b69b01ac779e66682 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext Scheme backend.
-   Copyright (C) 2004, 2006, 2014, 2018 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2006, 2014, 2018, 2020 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2004.
 
    This program is free software: you can redistribute it and/or modify
@@ -31,7 +31,7 @@ extern "C" {
   { "scm",       "Scheme"     },                                        \
 
 #define SCANNERS_SCHEME \
-  { "Scheme",           extract_scheme,                                   \
+  { "Scheme",           extract_scheme, NULL,                             \
                         &flag_table_scheme, &formatstring_scheme, NULL }, \
 
 /* Scan a Scheme file and add its translatable strings to mdlp.  */
index 44b7e67ee4850206ceb7684708bd6298afe73629..297480cd3ac4c4ce981bed65b7324d8bc6dacbbe 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext sh backend.
-   Copyright (C) 2003, 2006, 2014, 2018 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2006, 2014, 2018, 2020 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2003.
 
    This program is free software: you can redistribute it and/or modify
@@ -32,7 +32,7 @@ extern "C" {
   { "bash",  "Shell"   },                                               \
 
 #define SCANNERS_SH \
-  { "Shell",            extract_sh,                                     \
+  { "Shell",            extract_sh, NULL,                               \
                         &flag_table_sh, &formatstring_sh, NULL },       \
 
 /* Scan a shell script file and add its translatable strings to mdlp.  */
index 14bd5efe59730b0c5f71bc052e1075bca4167be3..0ba2179c74ae38645320ad07edfa58ed58a2bd6d 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext Smalltalk backend.
-   Copyright (C) 2002-2003, 2006, 2014, 2018 Free Software Foundation, Inc.
+   Copyright (C) 2002-2003, 2006, 2014, 2018, 2020 Free Software Foundation, Inc.
    Written by Bruno Haible <haible@clisp.cons.org>, 2002.
 
    This program is free software: you can redistribute it and/or modify
@@ -31,7 +31,7 @@ extern "C" {
   { "st",     "Smalltalk"   },                                          \
 
 #define SCANNERS_SMALLTALK \
-  { "Smalltalk",        extract_smalltalk,                              \
+  { "Smalltalk",        extract_smalltalk, NULL,                        \
                         NULL, &formatstring_smalltalk, NULL },          \
 
 /* Scan a Smalltalk file and add its translatable strings to mdlp.  */
index 75505c48cbc942f94b5f68d0a9cf463bf9fe2bba..f5e9cc31516a672e2ba36c0dfcfff152ab5c2d53 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext NXStringTable backend.
-   Copyright (C) 2003, 2006, 2014, 2018 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2006, 2014, 2018, 2020 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2003.
 
    This program is free software: you can redistribute it and/or modify
@@ -31,7 +31,7 @@ extern "C" {
   { "strings", "NXStringTable" },                                       \
 
 #define SCANNERS_STRINGTABLE \
-  { "NXStringTable",    extract_stringtable, NULL, NULL, NULL },        \
+  { "NXStringTable",    extract_stringtable, NULL, NULL, NULL, NULL },  \
 
 /* Scan an NXStringTable file and add its translatable strings to mdlp.  */
 extern void extract_stringtable (FILE *fp, const char *real_filename,
index 3efb09fffe29f9979b6ffe4f285d183d9f43f96a..8e66feccfd50ab22da7000c6ed7348e9b530c900 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext Tcl Lisp backend.
-   Copyright (C) 2002-2003, 2006, 2014, 2018 Free Software Foundation, Inc.
+   Copyright (C) 2002-2003, 2006, 2014, 2018, 2020 Free Software Foundation, Inc.
    Written by Bruno Haible <haible@clisp.cons.org>, 2002.
 
    This program is free software: you can redistribute it and/or modify
@@ -31,7 +31,7 @@ extern "C" {
   { "tcl",       "Tcl"           },                                     \
 
 #define SCANNERS_TCL \
-  { "Tcl",              extract_tcl,                                    \
+  { "Tcl",              extract_tcl, NULL,                              \
                         &flag_table_tcl, &formatstring_tcl, NULL },     \
 
 /* Scan a Tcl file and add its translatable strings to mdlp.  */
index 686283422554d1a2c203dba8f8c77c919f4ca3b8..29b266dfd22ffef51c186d76dfd0667d7b265948 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext Vala backend.
-   Copyright (C) 2002-2003, 2006, 2013-2014, 2018 Free Software Foundation, Inc.
+   Copyright (C) 2002-2003, 2006, 2013-2014, 2018, 2020 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -30,7 +30,7 @@ extern "C" {
   { "vala",        "Vala"   },                                        \
 
 #define SCANNERS_VALA \
-  { "Vala",       extract_vala,                                       \
+  { "Vala",       extract_vala, NULL,                                 \
                   &flag_table_vala, &formatstring_c, NULL },          \
 
 /* Scan a Vala file and add its translatable strings to mdlp.  */
index d6f836b6b3d936a6356e45283a006574ffee14b5..c681ba22b057f58c151c72eaebb7ad91d77b5cd3 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext YCP backend.
-   Copyright (C) 2001-2003, 2006, 2014, 2018 Free Software Foundation, Inc.
+   Copyright (C) 2001-2003, 2006, 2014, 2018, 2020 Free Software Foundation, Inc.
    Written by Bruno Haible <haible@clisp.cons.org>, 2001.
 
    This program is free software: you can redistribute it and/or modify
@@ -31,7 +31,7 @@ extern "C" {
   { "ycp",    "YCP"   },                                                \
 
 #define SCANNERS_YCP \
-  { "YCP",              extract_ycp,                                    \
+  { "YCP",              extract_ycp, NULL,                              \
                         &flag_table_ycp, &formatstring_ycp, NULL },     \
 
 /* Scan an YCP file and add its translatable strings to mdlp.  */
index a9192b3855d925e7967b311b7b16f3ef06285891..3c85c1f03e98b1fcf54c4386f0c4964f663df90e 100644 (file)
@@ -269,18 +269,26 @@ static const struct option long_options[] =
 };
 
 
-/* The extractors must all be functions returning void and taking three
-   arguments designating the input stream and one message domain list argument
-   in which to add the messages.  */
-typedef void (*extractor_func) (FILE *fp, const char *real_filename,
-                                const char *logical_filename,
-                                flag_context_list_table_ty *flag_table,
-                                msgdomain_list_ty *mdlp);
+/* The extractors must all be functions returning void and taking as arguments
+   - the file name or file stream,
+   - the flag table,
+   - a message domain list argument in which to add the messages.
+   An extract_from_stream_func is preferred, because it supports extracting from
+   stdin.  */
+typedef void (*extract_from_stream_func) (FILE *fp, const char *real_filename,
+                                          const char *logical_filename,
+                                          flag_context_list_table_ty *flag_table,
+                                          msgdomain_list_ty *mdlp);
+typedef void (*extract_from_file_func) (const char *real_filename,
+                                        const char *logical_filename,
+                                        flag_context_list_table_ty *flag_table,
+                                        msgdomain_list_ty *mdlp);
 
 typedef struct extractor_ty extractor_ty;
 struct extractor_ty
 {
-  extractor_func func;
+  extract_from_stream_func extract_from_stream;
+  extract_from_file_func extract_from_file;
   flag_context_list_table_ty *flag_table;
   struct formatstring_parser *formatstring_parser1;
   struct formatstring_parser *formatstring_parser2;
@@ -829,7 +837,7 @@ xgettext cannot work without keywords to look for"));
 
       filename = file_list->item[i];
 
-      if (extractor.func)
+      if (extractor.extract_from_stream || extractor.extract_from_file)
         this_file_extractor = extractor;
       else if (explicit_its_filename != NULL)
         {
@@ -1692,6 +1700,65 @@ savable_comment_to_xgettext_comment (refcounted_string_list_ty *rslp)
 }
 
 
+/* xgettext_find_file and xgettext_open look up a file, taking into account
+   the --directory options.
+   xgettext_find_file merely returns the file name.  This function is useful
+   for parsers implemented as separate programs.
+   xgettext_open returns the open file stream.  This function is useful for
+   built-in parsers.  */
+
+static void
+xgettext_find_file (const char *fn,
+                    char **logical_file_name_p, char **real_file_name_p)
+{
+  char *new_name;
+  char *logical_file_name;
+  struct stat statbuf;
+
+  /* We cannot handle "-" here.  "/dev/fd/0" is not portable, and it cannot
+     be opened multiple times.  */
+  if (IS_RELATIVE_FILE_NAME (fn))
+    {
+      int j;
+
+      for (j = 0; ; ++j)
+        {
+          const char *dir = dir_list_nth (j);
+
+          if (dir == NULL)
+            error (EXIT_FAILURE, ENOENT,
+                   _("error while opening \"%s\" for reading"), fn);
+
+          new_name = xconcatenated_filename (dir, fn, NULL);
+
+          if (stat (new_name, &statbuf) == 0)
+            break;
+
+          if (errno != ENOENT)
+            error (EXIT_FAILURE, errno,
+                   _("error while opening \"%s\" for reading"), new_name);
+          free (new_name);
+        }
+
+      /* Note that the NEW_NAME variable contains the actual file name
+         and the logical file name is what is reported by xgettext.  In
+         this case NEW_NAME is set to the file which was found along the
+         directory search path, and LOGICAL_FILE_NAME is is set to the
+         file name which was searched for.  */
+      logical_file_name = xstrdup (fn);
+    }
+  else
+    {
+      new_name = xstrdup (fn);
+      if (stat (fn, &statbuf) != 0)
+        error (EXIT_FAILURE, errno,
+               _("error while opening \"%s\" for reading"), fn);
+      logical_file_name = xstrdup (new_name);
+    }
+
+  *logical_file_name_p = logical_file_name;
+  *real_file_name_p = new_name;
+}
 
 static FILE *
 xgettext_open (const char *fn,
@@ -1767,25 +1834,37 @@ extract_from_file (const char *file_name, extractor_ty extractor,
 {
   char *logical_file_name;
   char *real_file_name;
-  FILE *fp = xgettext_open (file_name, &logical_file_name, &real_file_name);
-
-  /* Set the default for the source file encoding.  May be overridden by
-     the extractor function.  */
-  xgettext_current_source_encoding =
-    (xgettext_global_source_encoding != NULL ? xgettext_global_source_encoding :
-     po_charset_ascii);
-#if HAVE_ICONV
-  xgettext_current_source_iconv = xgettext_global_source_iconv;
-#endif
 
   current_formatstring_parser1 = extractor.formatstring_parser1;
   current_formatstring_parser2 = extractor.formatstring_parser2;
   current_formatstring_parser3 = extractor.formatstring_parser3;
-  extractor.func (fp, real_file_name, logical_file_name, extractor.flag_table,
-                  mdlp);
 
-  if (fp != stdin)
-    fclose (fp);
+  if (extractor.extract_from_stream)
+    {
+      FILE *fp = xgettext_open (file_name, &logical_file_name, &real_file_name);
+
+      /* Set the default for the source file encoding.  May be overridden by
+         the extractor function.  */
+      xgettext_current_source_encoding =
+        (xgettext_global_source_encoding != NULL ? xgettext_global_source_encoding :
+         po_charset_ascii);
+#if HAVE_ICONV
+      xgettext_current_source_iconv = xgettext_global_source_iconv;
+#endif
+
+      extractor.extract_from_stream (fp, real_file_name, logical_file_name,
+                                     extractor.flag_table, mdlp);
+
+      if (fp != stdin)
+        fclose (fp);
+    }
+  else
+    {
+      xgettext_find_file (file_name, &logical_file_name, &real_file_name);
+
+      extractor.extract_from_file (real_file_name, logical_file_name,
+                                   extractor.flag_table, mdlp);
+    }
   free (logical_file_name);
   free (real_file_name);
 }
@@ -2020,7 +2099,8 @@ language_to_extractor (const char *name)
   struct table_ty
   {
     const char *name;
-    extractor_func func;
+    extract_from_stream_func extract_from_stream;
+    extract_from_file_func extract_from_file;
     flag_context_list_table_ty *flag_table;
     struct formatstring_parser *formatstring_parser1;
     struct formatstring_parser *formatstring_parser2;
@@ -2066,7 +2146,8 @@ language_to_extractor (const char *name)
       {
         extractor_ty result;
 
-        result.func = tp->func;
+        result.extract_from_stream = tp->extract_from_stream;
+        result.extract_from_file = tp->extract_from_file;
         result.flag_table = tp->flag_table;
         result.formatstring_parser1 = tp->formatstring_parser1;
         result.formatstring_parser2 = tp->formatstring_parser2;