From: Daiki Ueno Date: Mon, 5 Aug 2013 10:48:09 +0000 (+0200) Subject: xgettext: allow file name extension with multiple dots X-Git-Tag: v0.19~183 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=534cd8f6a899a39c73d118e938ae3791003f4871;p=thirdparty%2Fgettext.git xgettext: allow file name extension with multiple dots To support extensions like ".gschema.xml", try possible extensions until matching language is found. --- diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index ff21d1be1..8541880ed 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,8 @@ +2013-08-05 Daiki Ueno + + * xgettext.c (main): Allow exntension with multiple + dots. e.g. .gschema.xml. + 2013-03-02 Miguel Angel Arruga Vivas Extract libexpat compatibility layer. diff --git a/gettext-tools/src/xgettext.c b/gettext-tools/src/xgettext.c index 702ceb072..2c7f35494 100644 --- a/gettext-tools/src/xgettext.c +++ b/gettext-tools/src/xgettext.c @@ -759,6 +759,7 @@ This version was built without iconv()."), char *reduced; const char *extension; const char *language; + const char *p; base = strrchr (filename, '/'); if (!base) @@ -771,17 +772,27 @@ This version was built without iconv()."), reduced[strlen (reduced) - 3] = '\0'; /* Work out what the file extension is. */ - extension = strrchr (reduced, '.'); - if (extension) - ++extension; - else - extension = ""; + language = NULL; + p = reduced + strlen (reduced); + for (; p > reduced && language == NULL; p--) + { + if (*p == '.') + { + extension = p + 1; + + /* Derive the language from the extension, and the extractor + function from the language. */ + language = extension_to_language (extension); + } + } - /* Derive the language from the extension, and the extractor - function from the language. */ - language = extension_to_language (extension); if (language == NULL) { + extension = strrchr (reduced, '.'); + if (extension == NULL) + extension = ""; + else + extension++; error (0, 0, _("\ warning: file '%s' extension '%s' is unknown; will try C"), filename, extension); language = "C"; @@ -3084,7 +3095,7 @@ SOME DESCRIPTIVE TITLE.\n\ Copyright (C) YEAR %s\n\ This file is distributed under the same license as the PACKAGE package.\n\ FIRST AUTHOR , YEAR.\n", - copyright_holder); + copyright_holder); else comment = xstrdup ("\ SOME DESCRIPTIVE TITLE.\n\