Date: Tue, 15 Apr 1997 17:20:40 +0300 (IDT) From: Eli Zaretskii To: djgpp-workers AT delorie DOT com Subject: Patch for ctime.c Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Here's the patch that corrects the bug in Emacs (reported today) whereby the zoneinfo directory is cached at dump time and reused at run time without consulting the environment on the target machine. While at that, I also fixed the too-unixy assumptions about how the pathnames look (e.g., try set TZDIR=c:/djgpp/zoneinfo and watch the fun). *** src/libc/ansi/time/ctime.c~0 Tue Apr 15 13:57:30 1997 --- src/libc/ansi/time/ctime.c Tue Apr 15 15:58:32 1997 *************** *** 1,3 **** --- 1,4 ---- + /* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ /* This file has been modified by DJ Delorie. These modifications are ** Copyright (C) 1995 DJ Delorie, 24 Kirsten Ave, Rochester NH, *************** static char sccsid[] = "@(#)ctime.c 5.23 *** 47,52 **** --- 48,54 ---- #include #include + #include #include "posixrul.h" *************** settzname(void) *** 232,238 **** static char * tzdir(void) { ! static char dir[80]={0}, *cp; if (dir[0] == 0) { if ((cp = getenv("TZDIR"))) --- 234,248 ---- static char * tzdir(void) { ! static char dir[FILENAME_MAX + 1]={0}, *cp; ! static int tzdir_bss_count = -1; ! ! /* Force recomputation of cached values (Emacs). */ ! if (tzdir_bss_count != __bss_count) ! { ! tzdir_bss_count = __bss_count; ! dir[0] = 0; ! } if (dir[0] == 0) { if ((cp = getenv("TZDIR"))) *************** tzload(const char *name, struct state * *** 266,272 **** if (name[0] == ':') ++name; ! if (name[0] != '/') { if ((p = tzdir()) == NULL) return -1; --- 276,282 ---- if (name[0] == ':') ++name; ! if (name[0] && name[0] != '/' && name[0] != '\\' && name[1] != ':') { if ((p = tzdir()) == NULL) return -1; *************** tzload(const char *name, struct state * *** 281,286 **** --- 291,301 ---- if ((fid = open(name, OPEN_MODE)) == -1) { const char *base = strrchr(name, '/'); + const char *bslash = strrchr(name, '\\'); + if (bslash && (!base || bslash > base)) + base = bslash; + if (!base && name[1] == ':') + base = name + 1; if (base) base++; else