Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/locale previous change was not complete enough, so ...



details:   https://anonhg.NetBSD.org/src/rev/4435e534d813
branches:  trunk
changeset: 501034:4435e534d813
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Fri Dec 22 16:50:08 2000 +0000

description:
previous change was not complete enough, so finish and make more correct:
for LC_ALL, return success if at least on of categories was loaded
successfully, error if no category was loaded; in the latter case, we don't
need to back off locale changes, since none happened

diffstat:

 lib/libc/locale/setlocale.c |  26 ++++++++++++++------------
 1 files changed, 14 insertions(+), 12 deletions(-)

diffs (58 lines):

diff -r 79869d957957 -r 4435e534d813 lib/libc/locale/setlocale.c
--- a/lib/libc/locale/setlocale.c       Fri Dec 22 16:48:36 2000 +0000
+++ b/lib/libc/locale/setlocale.c       Fri Dec 22 16:50:08 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: setlocale.c,v 1.26 2000/12/22 15:25:11 jdolecek Exp $  */
+/*     $NetBSD: setlocale.c,v 1.27 2000/12/22 16:50:08 jdolecek Exp $  */
 
 /*
  * Copyright (c) 1991, 1993
@@ -41,7 +41,7 @@
 #if 0
 static char sccsid[] = "@(#)setlocale.c        8.1 (Berkeley) 7/4/93";
 #else
-__RCSID("$NetBSD: setlocale.c,v 1.26 2000/12/22 15:25:11 jdolecek Exp $");
+__RCSID("$NetBSD: setlocale.c,v 1.27 2000/12/22 16:50:08 jdolecek Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -120,7 +120,7 @@
        int category;
        const char *locale;
 {
-       int i, j;
+       int i, loadlocale_success;
        size_t len;
        char *env, *r;
 
@@ -203,19 +203,21 @@
        if (category)
                return (loadlocale(category));
 
+       loadlocale_success = 0;
        for (i = 1; i < _LC_LAST; ++i) {
                (void)strlcpy(saved_categories[i], current_categories[i],
                    sizeof(saved_categories[i]));
-               if (loadlocale(i) == NULL) {
-                       for (j = 1; j < i; j++) {
-                               (void)strlcpy(new_categories[j],
-                                    saved_categories[j],
-                                    sizeof(new_categories[j]));
-                               /* XXX can fail too */
-                               (void)loadlocale(j);
-                       }
-               }
+               if (loadlocale(i) != NULL)
+                       loadlocale_success = 1;
        }
+
+       /*
+        * If all categories failed, return NULL; we don't need to back
+        * changes off, since none happened.
+        */
+       if (!loadlocale_success)
+               return NULL;
+
        return (currentlocale());
 }
 



Home | Main Index | Thread Index | Old Index