From: Bruno Haible Date: Mon, 28 Apr 2003 13:10:17 +0000 (+0000) Subject: Use po_scan instead of po_scan_file. X-Git-Tag: v0.12~64 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b6d32da76eb3a2aebea75850c5696c0122cfa385;p=thirdparty%2Fgettext.git Use po_scan instead of po_scan_file. --- diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index 587013fa9..7fde60e23 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,13 @@ +2003-04-21 Bruno Haible + + * read-po-abstract.h (po_scan_file): Remove declaration. + * read-po-abstract.c (po_scan_file): Remove function. + * read-po.c (read_po_file): Call read_po. + * msgfmt.c (read_po_file_msgfmt): Call open_po_file. Invoke po_scan + instead of po_scan_file. + * xgettext.c (read_exclusion_file): Call open_po_file. Invoke po_scan + instead of po_scan_file. + 2003-04-20 Bruno Haible * open-po.h (open_po_file): Add argument 'exit_on_error'. diff --git a/gettext-tools/src/msgfmt.c b/gettext-tools/src/msgfmt.c index 91d9c1cc9..7a1fbe20b 100644 --- a/gettext-tools/src/msgfmt.c +++ b/gettext-tools/src/msgfmt.c @@ -50,6 +50,7 @@ #include "gettext.h" #include "message.h" +#include "open-po.h" #include "read-po.h" #define _(str) gettext (str) @@ -1538,6 +1539,8 @@ static default_po_reader_class_ty msgfmt_methods = static void read_po_file_msgfmt (char *filename) { + char *real_filename; + FILE *fp = open_po_file (filename, &real_filename, true); default_po_reader_ty *pop; pop = default_po_reader_alloc (&msgfmt_methods); @@ -1555,6 +1558,9 @@ read_po_file_msgfmt (char *filename) pop->mlp = current_domain->mlp; } po_lex_pass_obsolete_entries (true); - po_scan_file ((abstract_po_reader_ty *) pop, filename); + po_scan ((abstract_po_reader_ty *) pop, fp, real_filename, filename); po_reader_free ((abstract_po_reader_ty *) pop); + + if (fp != stdin) + fclose (fp); } diff --git a/gettext-tools/src/read-po-abstract.c b/gettext-tools/src/read-po-abstract.c index 2e5be2e8d..4805fd75f 100644 --- a/gettext-tools/src/read-po-abstract.c +++ b/gettext-tools/src/read-po-abstract.c @@ -31,7 +31,6 @@ #include "po-charset.h" #include "po-gram.h" #include "po-hash.h" -#include "open-po.h" #include "xmalloc.h" /* Local variables. */ @@ -169,20 +168,6 @@ po_scan (abstract_po_reader_ty *pop, FILE *fp, } -void -po_scan_file (abstract_po_reader_ty *pop, const char *filename) -{ - /* Open the file and parse it. */ - char *real_filename; - FILE *fp = open_po_file (filename, &real_filename, true); - - po_scan (pop, fp, real_filename, filename); - - if (fp != stdin) - fclose (fp); -} - - /* ========================================================================= */ /* Callbacks used by po-gram.y or po-hash.y or po-lex.c, indirectly from po_scan. */ diff --git a/gettext-tools/src/read-po-abstract.h b/gettext-tools/src/read-po-abstract.h index c7bb0cb57..87590a672 100644 --- a/gettext-tools/src/read-po-abstract.h +++ b/gettext-tools/src/read-po-abstract.h @@ -137,11 +137,6 @@ extern void po_scan (abstract_po_reader_ty *pop, FILE *fp, const char *real_filename, const char *logical_filename); -/* Locate a PO file, open it, read it, dispatching to the various - abstract_po_reader_class_ty methods, and close it. */ -extern void - po_scan_file (abstract_po_reader_ty *pop, const char *filename); - /* Call the destructor and deallocate a abstract_po_reader_ty (or derived class) instance. */ extern void diff --git a/gettext-tools/src/read-po.c b/gettext-tools/src/read-po.c index 17e52594e..e4aec2089 100644 --- a/gettext-tools/src/read-po.c +++ b/gettext-tools/src/read-po.c @@ -27,6 +27,7 @@ #include #include +#include "open-po.h" #include "xmalloc.h" #include "gettext.h" @@ -453,20 +454,14 @@ read_po (FILE *fp, const char *real_filename, const char *logical_filename) msgdomain_list_ty * read_po_file (const char *filename) { - default_po_reader_ty *pop; - msgdomain_list_ty *mdlp; + char *real_filename; + FILE *fp = open_po_file (filename, &real_filename, true); + msgdomain_list_ty *result; - pop = default_po_reader_alloc (&default_methods); - pop->handle_comments = true; - pop->handle_filepos_comments = (line_comment != 0); - pop->allow_domain_directives = true; - pop->allow_duplicates = allow_duplicates; - pop->allow_duplicates_if_same_msgstr = false; - pop->mdlp = msgdomain_list_alloc (!pop->allow_duplicates); - pop->mlp = msgdomain_list_sublist (pop->mdlp, pop->domain, true); - po_lex_pass_obsolete_entries (true); - po_scan_file ((abstract_po_reader_ty *) pop, filename); - mdlp = pop->mdlp; - po_reader_free ((abstract_po_reader_ty *) pop); - return mdlp; + result = read_po (fp, real_filename, filename); + + if (fp != stdin) + fclose (fp); + + return result; } diff --git a/gettext-tools/src/xgettext.c b/gettext-tools/src/xgettext.c index 5a74a7262..b89e6a61f 100644 --- a/gettext-tools/src/xgettext.c +++ b/gettext-tools/src/xgettext.c @@ -47,6 +47,7 @@ #include "pathname.h" #include "strcase.h" #include "stpcpy.h" +#include "open-po.h" #include "read-po-abstract.h" #include "message.h" #include "po-charset.h" @@ -794,13 +795,18 @@ static abstract_po_reader_class_ty exclude_methods = static void -read_exclusion_file (char *file_name) +read_exclusion_file (char *filename) { + char *real_filename; + FILE *fp = open_po_file (filename, &real_filename, true); abstract_po_reader_ty *pop; pop = po_reader_alloc (&exclude_methods); - po_scan_file (pop, file_name); + po_scan (pop, fp, real_filename, filename); po_reader_free (pop); + + if (fp != stdin) + fclose (fp); }