GNU gettext behaves strangely when given an empty string, so make sure
authorDan Fandrich <dan@coneharvesters.com>
Thu, 31 Jan 2008 08:25:34 +0000 (00:25 -0800)
committerDan Fandrich <dan@coneharvesters.com>
Thu, 31 Jan 2008 08:25:34 +0000 (00:25 -0800)
not to do that.

libexif/canon/mnote-canon-tag.c
libexif/exif-entry.c
libexif/exif-tag.c
libexif/fuji/mnote-fuji-tag.c
libexif/olympus/mnote-olympus-tag.c
libexif/pentax/mnote-pentax-tag.c

index 2c8b4e2..e4278a1 100644 (file)
@@ -192,6 +192,10 @@ mnote_canon_tag_get_description (MnoteCanonTag t)
 
        bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
        for (i = 0; i < sizeof (table) / sizeof (table[0]); i++)
-               if (table[i].tag == t) return (_(table[i].description));
+               if (table[i].tag == t) {
+                       if (!*table[i].description)
+                               return "";
+                       return (_(table[i].description));
+               }
        return NULL;
 }
index 97a837d..46073c2 100644 (file)
@@ -976,6 +976,8 @@ exif_entry_get_value (ExifEntry *e, char *val, unsigned int maxlen)
                for (j = 0; list[i].strings[j] && (j < v_short); j++);
                if (!list[i].strings[j])
                        snprintf (val, maxlen, "%i", v_short);
+               else if (!*list[i].strings[j])
+                       val[0] = 0;
                else
                        strncpy (val, _(list[i].strings[j]), maxlen);
                break;
index edc222c..9d69847 100644 (file)
@@ -760,8 +760,13 @@ exif_tag_get_description_in_ifd (ExifTag tag, ExifIfd ifd)
 
        if (ifd >= EXIF_IFD_COUNT) return NULL;
        for (i = 0; ExifTagTable[i].description; i++)
-               if ((ExifTagTable[i].tag == tag) && RECORDED) break;
-       return _(ExifTagTable[i].description);
+               if ((ExifTagTable[i].tag == tag) && RECORDED) {
+                       /* GNU gettext acts strangely when given an empty string */
+                       if (!*ExifTagTable[i].description)
+                               return "";
+                       return _(ExifTagTable[i].description);
+               }
+       return NULL;
 }
 
 
index cd39da4..8fe9a8f 100644 (file)
@@ -96,6 +96,10 @@ mnote_fuji_tag_get_description (MnoteFujiTag t)
 
        bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
        for (i = 0; i < sizeof (table) / sizeof (table[0]); i++)
-               if (table[i].tag == t) return (_(table[i].description));
+               if (table[i].tag == t) {
+                       if (!*table[i].description)
+                               return "";
+                       return (_(table[i].description));
+               }
        return NULL;
 }
index 2eb76eb..028c1dc 100644 (file)
@@ -214,6 +214,10 @@ mnote_olympus_tag_get_description (MnoteOlympusTag t)
 
        bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
        for (i = 0; i < sizeof (table) / sizeof (table[0]); i++)
-               if (table[i].tag == t) return (_(table[i].description));
+               if (table[i].tag == t) {
+                       if (!*table[i].description)
+                               return "";
+                       return (_(table[i].description));
+               }
        return NULL;
 }
index 9a02293..6243286 100644 (file)
@@ -103,6 +103,10 @@ mnote_pentax_tag_get_description (MnotePentaxTag t)
 
        bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
        for (i = 0; i < sizeof (table) / sizeof (table[0]); i++)
-               if (table[i].tag == t) return (_(table[i].description));
+               if (table[i].tag == t) {
+                       if (!*table[i].description)
+                               return "";
+                       return (_(table[i].description));
+               }
        return NULL;
 }