[newlib-cygwin] Use era_info_t and alt_digits_t on _WANT_C99_TIME_FORMATS targets only
Corinna Vinschen
corinna@sourceware.org
Tue Aug 16 13:26:00 GMT 2016
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=1ec81984d8bf97ef405d3b9332923d82fb1164de
commit 1ec81984d8bf97ef405d3b9332923d82fb1164de
Author: Corinna Vinschen <corinna@vinschen.de>
Date: Tue Aug 16 15:26:01 2016 +0200
Use era_info_t and alt_digits_t on _WANT_C99_TIME_FORMATS targets only
Using era_info_t and alt_digits_t indiscriminately in strftime and
strftime_l breaks targets not wanting C99 time formats.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diff:
---
newlib/libc/time/strftime.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/newlib/libc/time/strftime.c b/newlib/libc/time/strftime.c
index 9ff44f9..46c2d95 100644
--- a/newlib/libc/time/strftime.c
+++ b/newlib/libc/time/strftime.c
@@ -49,7 +49,8 @@ DESCRIPTION
no more than <[maxsize]> characters.
<<strftime_l>> is like <<strftime>> but creates a string in a format
-as expected in locale <[locale]>.
+as expected in locale <[locale]>. If <[locale]> is LC_GLOBAL_LOCALE or
+not a valid locale object, the behaviour is undefined.
You control the format of the output using the string at <[format]>.
<<*<[format]>>> can contain two kinds of specifications: text to be
@@ -678,7 +679,7 @@ static size_t
__strftime (CHAR *s, size_t maxsize, const CHAR *format,
const struct tm *tim_p, struct __locale_t *locale,
era_info_t **era_info, alt_digits_t **alt_digits)
-#else
+#else /* !_WANT_C99_TIME_FORMATS */
static size_t
__strftime (CHAR *s, size_t maxsize, const CHAR *format,
const struct tm *tim_p, struct __locale_t *locale)
@@ -1443,6 +1444,7 @@ _DEFUN (strftime, (s, maxsize, format, tim_p),
_CONST CHAR *__restrict format _AND
_CONST struct tm *__restrict tim_p)
{
+#ifdef _WANT_C99_TIME_FORMATS
era_info_t *era_info = NULL;
alt_digits_t *alt_digits = NULL;
size_t ret = __strftime (s, maxsize, format, tim_p, __get_current_locale (),
@@ -1452,6 +1454,10 @@ _DEFUN (strftime, (s, maxsize, format, tim_p),
if (alt_digits)
free_alt_digits (alt_digits);
return ret;
+#else /* !_WANT_C99_TIME_FORMATS */
+ return __strftime (s, maxsize, format, tim_p, __get_current_locale (),
+ NULL, NULL);
+#endif /* !_WANT_C99_TIME_FORMATS */
}
#if !defined(MAKE_WCSFTIME)
@@ -1459,6 +1465,7 @@ size_t
strftime_l (char *__restrict s, size_t maxsize, const char *__restrict format,
const struct tm *__restrict tim_p, struct __locale_t *locale)
{
+#ifdef _WANT_C99_TIME_FORMATS
era_info_t *era_info = NULL;
alt_digits_t *alt_digits = NULL;
size_t ret = __strftime (s, maxsize, format, tim_p, locale,
@@ -1468,6 +1475,9 @@ strftime_l (char *__restrict s, size_t maxsize, const char *__restrict format,
if (alt_digits)
free_alt_digits (alt_digits);
return ret;
+#else /* !_WANT_C99_TIME_FORMATS */
+ return __strftime (s, maxsize, format, tim_p, locale, NULL, NULL);
+#endif /* !_WANT_C99_TIME_FORMATS */
}
#endif
More information about the Newlib-cvs
mailing list