]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
When named file not found and not absolute use path in I18NPATH.
authorUlrich Drepper <drepper@redhat.com>
Mon, 17 Mar 1997 03:49:00 +0000 (03:49 +0000)
committerUlrich Drepper <drepper@redhat.com>
Mon, 17 Mar 1997 03:49:00 +0000 (03:49 +0000)
locale/programs/locfile.c

index 09d987a14e7e87b95818aa81431e611f2b103e3f..aecc8913e2581aa66300016c51be2806b7de75a6 100644 (file)
@@ -1,6 +1,6 @@
 /* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>.
+   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
 
    The GNU C Library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public License as
@@ -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)