The strftime locale code attempts to read the locale cache even if the cache wasn't set up correctly. This leads to bogus output on your program's second (and subsequent) call to strftime(), if lookup failed. I discovered this because lookup failed for me on Solaris and FreeBSD -- on Solaris because locales are kept as .so's, and on FreeBSD because the "C" locale is left implicit and not stored on disk. This patch fixes this. --- tzcode2001c/strftime.c Tue Jun 5 13:49:50 2001 +++ tzcode2001c-Sun5/strftime.c Thu Jun 14 14:27:35 2001 @@ -604,6 +604,7 @@ static const char lc_time[] = "LC_TIME"; static char * locale_buf; static char locale_buf_C[] = "C"; + static int cache_good; int fd; int oldsun; /* "...ain't got nothin' to do..." */ @@ -629,7 +630,7 @@ ** If the locale name is the same as our cache, use the cache. */ lbuf = locale_buf; - if (lbuf != NULL && strcmp(name, lbuf) == 0) { + if (cache_good && lbuf != NULL && strcmp(name, lbuf) == 0) { p = lbuf; for (ap = (const char **) &localebuf; ap < (const char **) (&localebuf + 1); @@ -705,6 +706,7 @@ ** Record the successful parse in the cache. */ locale_buf = lbuf; + cache_good = 1; return &localebuf; @@ -715,6 +717,7 @@ no_locale: localebuf = C_time_locale; locale_buf = locale_buf_C; + cache_good = 0; return &localebuf; } #endif /* defined LOCALE_HOME */ -- Jonathan Lennox lennox@cs.columbia.edu