summaryrefslogtreecommitdiff
path: root/libc/misc/time
diff options
context:
space:
mode:
Diffstat (limited to 'libc/misc/time')
-rw-r--r--libc/misc/time/time.c126
1 files changed, 37 insertions, 89 deletions
diff --git a/libc/misc/time/time.c b/libc/misc/time/time.c
index 168655b00..05971389f 100644
--- a/libc/misc/time/time.c
+++ b/libc/misc/time/time.c
@@ -146,7 +146,6 @@
#include <bits/uClibc_uintmaxtostr.h>
#include <bits/uClibc_mutex.h>
-
#ifdef __UCLIBC_HAS_WCHAR__
#include <wchar.h>
#endif
@@ -154,39 +153,6 @@
#include <xlocale.h>
#endif
-/* libc_hidden_proto(asctime) */
-/* libc_hidden_proto(asctime_r) */
-/* libc_hidden_proto(ctime) */
-/* libc_hidden_proto(localtime) */
-/* libc_hidden_proto(localtime_r) */
-
-/* Experimentally off - libc_hidden_proto(memset) */
-/* Experimentally off - libc_hidden_proto(memcpy) */
-/* Experimentally off - libc_hidden_proto(strcmp) */
-/* Experimentally off - libc_hidden_proto(strcpy) */
-/* Experimentally off - libc_hidden_proto(strlen) */
-/* Experimentally off - libc_hidden_proto(strncpy) */
-/* libc_hidden_proto(sprintf) */
-/* libc_hidden_proto(open) */
-/* libc_hidden_proto(read) */
-/* libc_hidden_proto(close) */
-/* libc_hidden_proto(getenv) */
-/* libc_hidden_proto(tzset) */
-/* libc_hidden_proto(gettimeofday) */
-/* Experimentally off - libc_hidden_proto(strncasecmp) */
-/* libc_hidden_proto(strtol) */
-/* libc_hidden_proto(strtoul) */
-/* libc_hidden_proto(nl_langinfo) */
-
-#ifdef __UCLIBC_HAS_XLOCALE__
-/* Experimentally off - libc_hidden_proto(strncasecmp_l) */
-/* libc_hidden_proto(strtol_l) */
-/* libc_hidden_proto(strtoul_l) */
-/* libc_hidden_proto(nl_langinfo_l) */
-/* libc_hidden_proto(__ctype_b_loc) */
-#elif defined __UCLIBC_HAS_CTYPE_TABLES__
-/* libc_hidden_proto(__ctype_b) */
-#endif
#ifndef __isleap
#define __isleap(y) ( !((y) % 4) && ( ((y) % 100) || !((y) % 400) ) )
@@ -406,16 +372,16 @@ char *asctime_r(register const struct tm *__restrict ptm,
if (((unsigned int) tmp) >= 100) { /* Just check 2 digit non-neg. */
buffer[-1] = *buffer = '?';
} else
-#else /* SAFE_ASCTIME_R */
+#else
assert(((unsigned int) tmp) < 100); /* Just check 2 digit non-neg. */
-#endif /* SAFE_ASCTIME_R */
+#endif
{
*buffer = '0' + (tmp % 10);
#ifdef __BCC__
buffer[-1] = '0' + (tmp/10);
-#else /* __BCC__ */
+#else
buffer[-1] += (tmp/10);
-#endif /* __BCC__ */
+#endif
}
} while ((buffer -= 2)[-2] == '0');
@@ -433,8 +399,6 @@ libc_hidden_def(asctime_r)
#include <sys/times.h>
-/* libc_hidden_proto(times) */
-
#ifndef __BCC__
#if CLOCKS_PER_SEC != 1000000L
#error unexpected value for CLOCKS_PER_SEC!
@@ -814,10 +778,6 @@ time_t timegm(struct tm *timeptr)
#if defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE)
-/* libc_hidden_proto(strftime) */
-
-/* libc_hidden_proto(strftime_l) */
-
size_t strftime(char *__restrict s, size_t maxsize,
const char *__restrict format,
const struct tm *__restrict timeptr)
@@ -1100,18 +1060,18 @@ LOOP:
#ifdef ENABLE_ERA_CODE
if ((mod & NO_E_MOD) /* Actually, this means E modifier present. */
&& (*(o = __XL_NPP(nl_langinfo)(_NL_ITEM(LC_TIME,
- (int)(((unsigned char *)p)[4]))
- __LOCALE_ARG
- )))
+ (int)(((unsigned char *)p)[4]))
+ __LOCALE_ARG
+ )))
) {
p = o;
goto LOOP;
}
#endif
p = __XL_NPP(nl_langinfo)(_NL_ITEM(LC_TIME,
- (int)(*((unsigned char *)p)))
- __LOCALE_ARG
- );
+ (int)(*((unsigned char *)p)))
+ __LOCALE_ARG
+ );
goto LOOP;
}
@@ -1185,7 +1145,7 @@ LOOP:
* tm_gmtoff value. What we'll do instead is treat the
* timezone name as unknown/invalid and return "???". */
if (!o) {
- o = "???";
+ o = "???";
}
#endif
assert(o != NULL);
@@ -1239,7 +1199,7 @@ LOOP:
--field_val;
}
} else { /* ((*p == 'g') || (*p == 'G') || (*p == 'V')) */
- ISO_LOOP:
+ISO_LOOP:
isofm = (((x[1] - x[0]) + 11) % 7) - 3; /* [-3,3] */
if (x[1] < isofm) { /* belongs to previous year */
@@ -1250,7 +1210,7 @@ LOOP:
field_val = ((x[1] - isofm) / 7) + 1; /* week # */
days = 365 + __isleap(x[2]);
- isofm = ((isofm + 7*53 + 3 - days)) %7 + days - 3; /* next year */
+ isofm = ((isofm + 7*53 + 3 - days)) % 7 + days - 3; /* next year */
if (x[1] >= isofm) { /* next year */
x[1] -= days;
++x[2];
@@ -1269,7 +1229,7 @@ LOOP:
}
} else {
i = TP_OFFSETS + (code & 0x1f);
- if ((field_val = load_field(spec[i],timeptr)) < 0) {
+ if ((field_val = load_field(spec[i], timeptr)) < 0) {
goto OUTPUT;
}
@@ -1281,7 +1241,7 @@ LOOP:
}
if (i & 32) {
field_val %= j;
- if (((i&128) + field_val) == 0) { /* mod 12? == 0 */
+ if (((i & 128) + field_val) == 0) { /* mod 12? == 0 */
field_val = j; /* set to 12 */
}
}
@@ -1294,7 +1254,7 @@ LOOP:
if ((code & MASK_SPEC) == STRING_SPEC) {
o_count = SIZE_MAX;
field_val += spec[STRINGS_NL_ITEM_START + (code & 0xf)];
- o = __XL_NPP(nl_langinfo)(_NL_ITEM(LC_TIME, field_val) __LOCALE_ARG );
+ o = __XL_NPP(nl_langinfo)(_NL_ITEM(LC_TIME, field_val) __LOCALE_ARG);
} else {
o_count = ((i >> 1) & 3) + 1;
o = buf + o_count;
@@ -1335,10 +1295,6 @@ libc_hidden_def(__XL_NPP(strftime))
#if defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE)
-/* libc_hidden_proto(strptime) */
-
-/* libc_hidden_proto(strptime_l) */
-
char *strptime(const char *__restrict buf, const char *__restrict format,
struct tm *__restrict tm)
{
@@ -1560,17 +1516,18 @@ LOOP:
#ifdef ENABLE_ERA_CODE
if ((mod & NO_E_MOD) /* Actually, this means E modifier present. */
&& (*(o = __XL_NPP(nl_langinfo)(_NL_ITEM(LC_TIME,
- (int)(((unsigned char *)p)[4]))
- __LOCALE_ARG
- )))
+ (int)(((unsigned char *)p)[4]))
+ __LOCALE_ARG
+ )))
) {
p = o;
goto LOOP;
}
#endif
p = __XL_NPP(nl_langinfo)(_NL_ITEM(LC_TIME,
- (int)(*((unsigned char *)p)))
- __LOCALE_ARG );
+ (int)(*((unsigned char *)p)))
+ __LOCALE_ARG
+ );
goto LOOP;
}
@@ -1584,7 +1541,7 @@ LOOP:
do {
--j;
o = __XL_NPP(nl_langinfo)(i+j __LOCALE_ARG);
- if (!__XL_NPP(strncasecmp)(buf,o,strlen(o) __LOCALE_ARG) && *o) {
+ if (!__XL_NPP(strncasecmp)(buf, o, strlen(o) __LOCALE_ARG) && *o) {
do { /* Found a match. */
++buf;
} while (*++o);
@@ -1674,7 +1631,7 @@ LOOP:
fields[(*x) >> 3] = i;
- if (((unsigned char)(*x - (10<< 3) + 0 + 0)) <= 8) { /* %C or %y */
+ if (((unsigned char)(*x - (10 << 3) + 0 + 0)) <= 8) { /* %C or %y */
if ((j = fields[10]) < 0) { /* No %C, so i must be %y data. */
if (i <= 68) { /* Map [0-68] to 2000+i */
i += 100;
@@ -1830,7 +1787,7 @@ static const char *getnumber(register const char *e, int *pn)
#ifndef __UCLIBC_HAS_TZ_FILE_READ_MANY__
static smallint TZ_file_read; /* Let BSS initialization set this to 0. */
-#endif /* __UCLIBC_HAS_TZ_FILE_READ_MANY__ */
+#endif
static char *read_TZ_file(char *buf)
{
@@ -1883,13 +1840,9 @@ ERROR:
#endif /* __UCLIBC_HAS_TZ_FILE__ */
-#ifndef __UCLIBC_HAS_CTYPE_TABLES__
-/* libc_hidden_proto(isascii) */
-#endif
-
void tzset(void)
{
- _time_tzset((time(NULL)) < new_rule_starts);
+ _time_tzset((time(NULL)) < new_rule_starts);
}
void _time_tzset(int use_old_rules)
@@ -1903,10 +1856,10 @@ void _time_tzset(int use_old_rules)
char c;
#ifdef __UCLIBC_HAS_TZ_FILE__
char buf[TZ_BUFLEN];
-#endif /* __UCLIBC_HAS_TZ_FILE__ */
+#endif
#ifdef __UCLIBC_HAS_TZ_CACHING__
static char oldval[TZ_BUFLEN]; /* BSS-zero'd. */
-#endif /* __UCLIBC_HAS_TZ_CACHING__ */
+#endif
__UCLIBC_MUTEX_LOCK(_time_tzlock);
@@ -1931,12 +1884,12 @@ void _time_tzset(int use_old_rules)
if ((!e /* TZ env var not set... */
#ifdef __UCLIBC_HAS_TZ_FILE__
&& !(e = read_TZ_file(buf)) /* and no file or invalid file */
-#endif /* __UCLIBC_HAS_TZ_FILE__ */
+#endif
) || !*e) { /* or set to empty string. */
ILLEGAL: /* TODO: Clean up the following... */
#ifdef __UCLIBC_HAS_TZ_CACHING__
*oldval = 0; /* Set oldval to an empty string. */
-#endif /* __UCLIBC_HAS_TZ_CACHING__ */
+#endif
memset(_time_tzinfo, 0, 2*sizeof(rule_struct));
strcpy(_time_tzinfo[0].tzname, UTC);
goto DONE;
@@ -1954,7 +1907,7 @@ ILLEGAL: /* TODO: Clean up the following... */
* it is too long, but it that case it will be illegal and will be reset
* to the empty string anyway. */
strncpy(oldval, e, TZ_BUFLEN);
-#endif /* __UCLIBC_HAS_TZ_CACHING__ */
+#endif
count = 0;
new_rules[1].tzname[0] = 0;
@@ -2016,15 +1969,15 @@ SKIP_OFFSET:
} else { /* OK, we have dst, so get some rules. */
count = 0;
if (!*e) { /* No rules so default to US rules. */
- e = use_old_rules ? DEFAULT_RULES : DEFAULT_2007_RULES;
+ e = use_old_rules ? DEFAULT_RULES : DEFAULT_2007_RULES;
#ifdef DEBUG_TZSET
if (e == DEFAULT_RULES)
- printf("tzset: Using old rules.\n");
+ printf("tzset: Using old rules.\n");
else if (e == DEFAULT_2007_RULES)
- printf("tzset: Using new rules\n");
+ printf("tzset: Using new rules\n");
else
- printf("tzset: Using undefined rules\n");
-#endif /* DEBUG_TZSET */
+ printf("tzset: Using undefined rules\n");
+#endif
}
do {
@@ -2228,7 +2181,6 @@ struct tm attribute_hidden *_time_t2tm(const time_t *__restrict timer,
t = 365;
}
-
*p += ((int) t); /* result[7] .. tm_yday */
p -= 2; /* at result[5] */
@@ -2404,7 +2356,7 @@ DST_CORRECT:
__time_localtime_tzi(&t, (struct tm *)p, tzi);
if (t == ((time_t)(-1))) { /* Remember, time_t can be unsigned. */
- goto DONE;
+ goto DONE;
}
if ((d < 0) && (((struct tm *)p)->tm_isdst != default_dst)) {
@@ -2432,10 +2384,6 @@ DONE:
#if defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE)
-/* libc_hidden_proto(wcsftime) */
-
-/* libc_hidden_proto(wcsftime_l) */
-
size_t wcsftime(wchar_t *__restrict s, size_t maxsize,
const wchar_t *__restrict format,
const struct tm *__restrict timeptr)