]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
xgettext: allow file name extension with multiple dots
authorDaiki Ueno <ueno@gnu.org>
Mon, 5 Aug 2013 10:48:09 +0000 (12:48 +0200)
committerDaiki Ueno <ueno@gnu.org>
Tue, 6 Aug 2013 13:32:16 +0000 (15:32 +0200)
To support extensions like ".gschema.xml", try possible extensions
until matching language is found.

gettext-tools/src/ChangeLog
gettext-tools/src/xgettext.c

index ff21d1be151c4047062667f0683a695fa9ec9eee..8541880edbea30ced0cd109941f83ee11b9fc386 100644 (file)
@@ -1,3 +1,8 @@
+2013-08-05  Daiki Ueno  <ueno@gnu.org>
+
+       * xgettext.c (main): Allow exntension with multiple
+       dots. e.g. .gschema.xml.
+
 2013-03-02  Miguel Angel Arruga Vivas  <rosen644385@gmail.com>
 
        Extract libexpat compatibility layer.
index 702ceb0726e6aff57813da0f038bc53ff0a75f0c..2c7f35494fe3bec52308877b5615f4bd18a5a2e3 100644 (file)
@@ -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 <EMAIL@ADDRESS>, YEAR.\n",
-                        copyright_holder);
+                         copyright_holder);
   else
     comment = xstrdup ("\
 SOME DESCRIPTIVE TITLE.\n\