summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1995-10-23 19:52:43 +0000
committerache <ache@FreeBSD.org>1995-10-23 19:52:43 +0000
commit14ac5aba33457166a17bbba2619b9c2f85531cda (patch)
tree943e735df1cfcce2b550d66aa9d12bca0d7d3fcf /lib
parenta982c41bec8ce0e10f33d1f789a22397351d9ef4 (diff)
downloadFreeBSD-src-14ac5aba33457166a17bbba2619b9c2f85531cda.zip
FreeBSD-src-14ac5aba33457166a17bbba2619b9c2f85531cda.tar.gz
Don't reset LC_TIME to C when it isn't neccessary
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/stdtime/strftime.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/lib/libc/stdtime/strftime.c b/lib/libc/stdtime/strftime.c
index ca6acf9..0ad723e 100644
--- a/lib/libc/stdtime/strftime.c
+++ b/lib/libc/stdtime/strftime.c
@@ -17,7 +17,7 @@
#ifdef LIBC_RCS
static const char rcsid[] =
- "$Id: strftime.c,v 1.4 1995/08/06 11:48:16 ache Exp $";
+ "$Id: strftime.c,v 1.5 1995/08/07 23:35:41 ache Exp $";
#endif
#ifndef lint
@@ -483,15 +483,17 @@ __time_load_locale(const char *name)
struct stat st;
size_t namesize;
size_t bufsize;
+ int save_using_locale;
+ save_using_locale = using_locale;
using_locale = 0;
- if (!strcmp(name, "C") || !strcmp(name, "POSIX"))
+ if (name == NULL)
+ goto no_locale;
+
+ if (!*name || !strcmp(name, "C") || !strcmp(name, "POSIX"))
return 0;
- if (name == NULL || *name == '\0') {
- goto no_locale;
- }
/*
** If the locale name is the same as our cache, use the cache.
*/
@@ -514,9 +516,8 @@ __time_load_locale(const char *name)
"%s/%s/%s",
_PathLocale, name, lc_time);
fd = open(filename, O_RDONLY);
- if (fd < 0) {
+ if (fd < 0)
goto no_locale;
- }
if (fstat(fd, &st) != 0)
goto bad_locale;
if (st.st_size <= 0)
@@ -543,7 +544,7 @@ __time_load_locale(const char *name)
ap < (const char **) (&localebuf + 1);
++ap) {
if (p == plim)
- goto bad_lbuf;
+ goto reset_locale;
*ap = p;
while (*p != '\n')
++p;
@@ -557,16 +558,19 @@ __time_load_locale(const char *name)
using_locale = 1;
return 0;
-bad_lbuf:
- free(lbuf);
-bad_locale:
- (void) close(fd);
-no_locale:
+reset_locale:
/*
* XXX - This may not be the correct thing to do in this case.
* setlocale() assumes that we left the old locale alone.
*/
locale_buf = locale_buf_C;
localebuf = C_time_locale;
+ save_using_locale = 0;
+bad_lbuf:
+ free(lbuf);
+bad_locale:
+ (void) close(fd);
+no_locale:
+ using_locale = save_using_locale;
return -1;
}
OpenPOWER on IntegriCloud