about summary refs log tree commit diff
path: root/locale/programs/locfile.c
diff options
context:
space:
mode:
Diffstat (limited to 'locale/programs/locfile.c')
-rw-r--r--locale/programs/locfile.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/locale/programs/locfile.c b/locale/programs/locfile.c
index 4ab04253b9..aecc8913e2 100644
--- a/locale/programs/locfile.c
+++ b/locale/programs/locfile.c
@@ -26,6 +26,7 @@
 #include <locale.h>
 #include <malloc.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 #include <sys/stat.h>
@@ -76,10 +77,31 @@ locfile_read (const char *filename, struct charset_t *charset)
     {
       if (filename[0] != '/')
 	{
-	  char path[strlen (filename) + 1 + sizeof (LOCSRCDIR)];
+	  char *i18npath = __secure_getenv ("I18NPATH");
+	  if (i18npath != NULL && *i18npath != '\0')
+	    {
+	      char path[strlen (filename) + 1 + strlen (i18npath) + 1];
+	      char *next;
+	      i18npath = strdupa (i18npath);
+
+
+	      while (ldfile == NULL
+		     && (next = strsep (&i18npath, ":")) != NULL)
+		{
+		  stpcpy (stpcpy (stpcpy (path, next), "/"), filename);
+
+		  ldfile = lr_open (path, locfile_hash);
+		}
+	    }
 
-	  stpcpy (stpcpy (stpcpy (path, LOCSRCDIR), "/"), filename);
-	  ldfile = lr_open (path, locfile_hash);
+	  /* Test in the default directory.  */
+	  if (ldfile == NULL)
+	    {
+	      char path[strlen (filename) + 1 + sizeof (LOCSRCDIR)];
+
+	      stpcpy (stpcpy (stpcpy (path, LOCSRCDIR), "/"), filename);
+	      ldfile = lr_open (path, locfile_hash);
+	    }
 	}
 
       if (ldfile == NULL)