|
@@ -1912,38 +1912,36 @@ void _time_tzset(int use_old_rules)
|
|
|
static char oldval[TZ_BUFLEN];
|
|
|
#endif
|
|
|
|
|
|
+
|
|
|
+ * timezones being used in a threaded app. */
|
|
|
__UCLIBC_MUTEX_LOCK(_time_tzlock);
|
|
|
|
|
|
e = getenv(TZ);
|
|
|
|
|
|
#if defined(__UCLIBC_HAS_TZ_FILE__) && !defined(__UCLIBC_HAS_TZ_FILE_READ_MANY__)
|
|
|
-
|
|
|
- * timezones being used in a threaded app. */
|
|
|
-
|
|
|
- if (e != NULL) {
|
|
|
- TZ_file_read = 0;
|
|
|
- } else if (TZ_file_read) {
|
|
|
+ if (e) {
|
|
|
+
|
|
|
+ TZ_file_read = 0;
|
|
|
+ }
|
|
|
+ if (TZ_file_read) {
|
|
|
+
|
|
|
goto FAST_DONE;
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif
|
|
|
|
|
|
|
|
|
* potentially unsafe in a multi-threaded program since it is remotely
|
|
|
* possible that another thread could call setenv() for TZ and overwrite
|
|
|
* the string being parsed. So, don't do that... */
|
|
|
|
|
|
- if ((!e
|
|
|
#ifdef __UCLIBC_HAS_TZ_FILE__
|
|
|
- && !(e = read_TZ_file(buf))
|
|
|
-#endif
|
|
|
- ) || !*e) {
|
|
|
-ILLEGAL:
|
|
|
-#ifdef __UCLIBC_HAS_TZ_CACHING__
|
|
|
- *oldval = 0;
|
|
|
+ if (!e)
|
|
|
+ e = read_TZ_file(buf);
|
|
|
#endif
|
|
|
- memset(_time_tzinfo, 0, 2*sizeof(rule_struct));
|
|
|
- strcpy(_time_tzinfo[0].tzname, UTC);
|
|
|
- goto DONE;
|
|
|
+ if (!e
|
|
|
+ || !*e
|
|
|
+ ) {
|
|
|
+ goto ILLEGAL;
|
|
|
}
|
|
|
|
|
|
if (*e == ':') {
|
|
@@ -1951,8 +1949,9 @@ ILLEGAL:
|
|
|
}
|
|
|
|
|
|
#ifdef __UCLIBC_HAS_TZ_CACHING__
|
|
|
- if (strcmp(e, oldval) == 0) {
|
|
|
- goto FAST_DONE;
|
|
|
+ if (strcmp(e, oldval) == 0) {
|
|
|
+
|
|
|
+ goto FAST_DONE;
|
|
|
}
|
|
|
|
|
|
* it is too long, but it that case it will be illegal and will be reset
|
|
@@ -1973,10 +1972,11 @@ LOOP:
|
|
|
s = new_rules[count].tzname;
|
|
|
n = 0;
|
|
|
while (*e
|
|
|
- && isascii(*e)
|
|
|
- && (isalpha(*e)
|
|
|
- || (c && (isalnum(*e) || (*e == '+') || (*e == '-'))))
|
|
|
- ) {
|
|
|
+ && isascii(*e)
|
|
|
+ && (isalpha(*e)
|
|
|
+ || (c && (isalnum(*e) || (*e == '+') || (*e == '-')))
|
|
|
+ )
|
|
|
+ ) {
|
|
|
*s++ = *e++;
|
|
|
if (++n > TZNAME_MAX) {
|
|
|
goto ILLEGAL;
|
|
@@ -1985,8 +1985,8 @@ LOOP:
|
|
|
*s = 0;
|
|
|
|
|
|
if ((n < 3)
|
|
|
- || (c && (*e++ != c))
|
|
|
- ) {
|
|
|
+ || (c && (*e++ != c))
|
|
|
+ ) {
|
|
|
goto ILLEGAL;
|
|
|
}
|
|
|
|
|
@@ -2001,7 +2001,8 @@ LOOP:
|
|
|
}
|
|
|
|
|
|
++e;
|
|
|
- if (!(e = getoffset(e, &off))) {
|
|
|
+ e = getoffset(e, &off);
|
|
|
+ if (!e) {
|
|
|
goto ILLEGAL;
|
|
|
}
|
|
|
|
|
@@ -2038,7 +2039,8 @@ SKIP_OFFSET:
|
|
|
|
|
|
n = 365;
|
|
|
s = (char *) RULE;
|
|
|
- if ((c = *e++) == 'M') {
|
|
|
+ c = *e++;
|
|
|
+ if (c == 'M') {
|
|
|
n = 12;
|
|
|
} else if (c == 'J') {
|
|
|
s += 8;
|
|
@@ -2048,26 +2050,31 @@ SKIP_OFFSET:
|
|
|
s += 6;
|
|
|
}
|
|
|
|
|
|
- *(p = &new_rules[count].rule_type) = c;
|
|
|
+ p = &new_rules[count].rule_type;
|
|
|
+ *p = c;
|
|
|
if (c != 'M') {
|
|
|
p -= 2;
|
|
|
}
|
|
|
|
|
|
do {
|
|
|
++s;
|
|
|
- if (!(e = getnumber(e, &f))
|
|
|
- || (((unsigned int)(f - s[1])) > n)
|
|
|
- || (*s && (*e++ != *s))
|
|
|
- ) {
|
|
|
+ e = getnumber(e, &f);
|
|
|
+ if (!e
|
|
|
+ || ((unsigned int)(f - s[1]) > n)
|
|
|
+ || (*s && (*e++ != *s))
|
|
|
+ ) {
|
|
|
goto ILLEGAL;
|
|
|
}
|
|
|
*--p = f;
|
|
|
- } while ((n = *(s += 2)) > 0);
|
|
|
+ s += 2;
|
|
|
+ n = *s;
|
|
|
+ } while (n > 0);
|
|
|
|
|
|
off = 2 * 60 * 60;
|
|
|
if (*e == '/') {
|
|
|
++e;
|
|
|
- if (!(e = getoffset(e, &off))) {
|
|
|
+ e = getoffset(e, &off);
|
|
|
+ if (!e) {
|
|
|
goto ILLEGAL;
|
|
|
}
|
|
|
}
|
|
@@ -2075,7 +2082,13 @@ SKIP_OFFSET:
|
|
|
} while (++count < 2);
|
|
|
|
|
|
if (*e) {
|
|
|
- goto ILLEGAL;
|
|
|
+ILLEGAL:
|
|
|
+#ifdef __UCLIBC_HAS_TZ_CACHING__
|
|
|
+ oldval[0] = 0;
|
|
|
+#endif
|
|
|
+ memset(_time_tzinfo, 0, sizeof(_time_tzinfo));
|
|
|
+ strcpy(_time_tzinfo[0].tzname, UTC);
|
|
|
+ goto DONE;
|
|
|
}
|
|
|
}
|
|
|
|