comparison src/editfns.c @ 257:65c19d2020f7 r20-5b27

Import from CVS: tag r20-5b27
author cvs
date Mon, 13 Aug 2007 10:22:03 +0200
parents 262b8bb4a523
children 727739f917cb
comparison
equal deleted inserted replaced
256:19076a51efde 257:65c19d2020f7
1163 } 1163 }
1164 else 1164 else
1165 return list2 (Qnil, Qnil); 1165 return list2 (Qnil, Qnil);
1166 } 1166 }
1167 1167
1168 #ifdef LOCALTIME_CACHE
1169
1170 /* These two values are known to load tz files in buggy implementations,
1171 i.e. Solaris 1 executables running under either Solaris 1 or Solaris 2.
1172 Their values shouldn't matter in non-buggy implementations.
1173 We don't use string literals for these strings,
1174 since if a string in the environment is in readonly
1175 storage, it runs afoul of bugs in SVR4 and Solaris 2.3.
1176 See Sun bugs 1113095 and 1114114, ``Timezone routines
1177 improperly modify environment''. */
1178
1179 static char set_time_zone_rule_tz1[] = "TZ=GMT+0";
1180 static char set_time_zone_rule_tz2[] = "TZ=GMT+1";
1181
1182 #endif
1183
1168 /* Set the local time zone rule to TZSTRING. 1184 /* Set the local time zone rule to TZSTRING.
1169 This allocates memory into `environ', which it is the caller's 1185 This allocates memory into `environ', which it is the caller's
1170 responsibility to free. */ 1186 responsibility to free. */
1171 static void 1187 static void
1172 set_time_zone_rule (char *tzstring) 1188 set_time_zone_rule (char *tzstring)
1193 *to = 0; 1209 *to = 0;
1194 1210
1195 environ = newenv; 1211 environ = newenv;
1196 1212
1197 #ifdef LOCALTIME_CACHE 1213 #ifdef LOCALTIME_CACHE
1214 {
1215 /* In SunOS 4.1.3_U1 and 4.1.4, if TZ has a value like
1216 "US/Pacific" that loads a tz file, then changes to a value like
1217 "XXX0" that does not load a tz file, and then changes back to
1218 its original value, the last change is (incorrectly) ignored.
1219 Also, if TZ changes twice in succession to values that do
1220 not load a tz file, tzset can dump core (see Sun bug#1225179).
1221 The following code works around these bugs. */
1222
1223 if (tzstring)
1224 {
1225 /* Temporarily set TZ to a value that loads a tz file
1226 and that differs from tzstring. */
1227 char *tz = *newenv;
1228 *newenv = (strcmp (tzstring, set_time_zone_rule_tz1 + 3) == 0
1229 ? set_time_zone_rule_tz2 : set_time_zone_rule_tz1);
1230 tzset ();
1231 *newenv = tz;
1232 }
1233 else
1234 {
1235 /* The implied tzstring is unknown, so temporarily set TZ to
1236 two different values that each load a tz file. */
1237 *to = set_time_zone_rule_tz1;
1238 to[1] = 0;
1239 tzset ();
1240 *to = set_time_zone_rule_tz2;
1241 tzset ();
1242 *to = 0;
1243 }
1244
1245 /* Now TZ has the desired value, and tzset can be invoked safely. */
1246 }
1247
1198 tzset (); 1248 tzset ();
1199 #endif 1249 #endif
1200 } 1250 }
1201 1251
1202 DEFUN ("set-time-zone-rule", Fset_time_zone_rule, 1, 1, 0, /* 1252 DEFUN ("set-time-zone-rule", Fset_time_zone_rule, 1, 1, 0, /*