* libc/time/strftime.c: Adapt for dual-purpose use so not only

defines strftime(), but can also define wcsftime(); add optional
	test package; speed up %Y handling.
	* libc/time/wcsftime.c:  New file, defining wcsftime() (albeit
	indirectly by including strftime.c) and its documentation.
	* libc/time/time.tex:  Enhance tm_isdst explanation, change strftime
	description to match modified description in strftime.c
	* libc/time/Makefile.am:  Add wcsftime.c and wcsftime.def.  Add a rule
	so that wcsftime.o gets rebuilt when strftime changes.
	* libc/time/Makefile.in:  Regenerate.
	* libc/include/wchar.h (wcsftime): Declare.
This commit is contained in:
Corinna Vinschen 2009-03-09 12:35:03 +00:00
parent f9f478ad80
commit 3c4becbe18
7 changed files with 778 additions and 278 deletions

View File

@ -1,3 +1,17 @@
2009-03-09 Craig Howland <howland@LGSInnovations.com>
* libc/time/strftime.c: Adapt for dual-purpose use so not only
defines strftime(), but can also define wcsftime(); add optional
test package; speed up %Y handling.
* libc/time/wcsftime.c: New file, defining wcsftime() (albeit
indirectly by including strftime.c) and its documentation.
* libc/time/time.tex: Enhance tm_isdst explanation, change strftime
description to match modified description in strftime.c
* libc/time/Makefile.am: Add wcsftime.c and wcsftime.def. Add a rule
so that wcsftime.o gets rebuilt when strftime changes.
* libc/time/Makefile.in: Regenerate.
* libc/include/wchar.h (wcsftime): Declare.
2009-03-06 Hans-Erik Floryd <hans-erik.floryd@rt-labs.com>,
Corinna Vinschen <corinna@vinschen.de>

View File

@ -72,6 +72,7 @@ int _EXFUN(wcscoll, (const wchar_t *, const wchar_t *));
wchar_t *_EXFUN(wcscpy, (wchar_t * , const wchar_t *));
wchar_t *_EXFUN(wcpcpy, (wchar_t * , const wchar_t *));
size_t _EXFUN(wcscspn, (const wchar_t *, const wchar_t *));
size_t _EXFUN(wcsftime, (wchar_t *, size_t, const wchar_t *, const struct tm *));
size_t _EXFUN(wcslcat, (wchar_t *, const wchar_t *, size_t));
size_t _EXFUN(wcslcpy, (wchar_t *, const wchar_t *, size_t));
size_t _EXFUN(wcslen, (const wchar_t *));

View File

@ -24,7 +24,8 @@ LIB_SOURCES = \
tzlock.c \
tzset.c \
tzset_r.c \
tzvars.c
tzvars.c \
wcsftime.c
libtime_la_LDFLAGS = -Xcompiler -nostdlib
@ -39,8 +40,11 @@ lib_a_CFLAGS = $(AM_CFLAGS)
noinst_DATA =
endif # USE_LIBTOOL
# This rule is needed so that wcsftime.o is rebuilt when strftime.c changes.
include $(srcdir)/../../Makefile.shared
$(lpfx)wcsftime.$(oext): strftime.c
CHEWOUT_FILES = \
asctime.def \
clock.def \
@ -52,7 +56,8 @@ CHEWOUT_FILES = \
strftime.def \
time.def \
tzlock.def \
tzset.def
tzset.def \
wcsftime.def
SUFFIXES = .def

View File

@ -66,7 +66,8 @@ am__objects_1 = lib_a-asctime.$(OBJEXT) lib_a-asctime_r.$(OBJEXT) \
lib_a-mktm_r.$(OBJEXT) lib_a-strftime.$(OBJEXT) \
lib_a-strptime.$(OBJEXT) lib_a-time.$(OBJEXT) \
lib_a-tzlock.$(OBJEXT) lib_a-tzset.$(OBJEXT) \
lib_a-tzset_r.$(OBJEXT) lib_a-tzvars.$(OBJEXT)
lib_a-tzset_r.$(OBJEXT) lib_a-tzvars.$(OBJEXT) \
lib_a-wcsftime.$(OBJEXT)
@USE_LIBTOOL_FALSE@am_lib_a_OBJECTS = $(am__objects_1)
lib_a_OBJECTS = $(am_lib_a_OBJECTS)
LTLIBRARIES = $(noinst_LTLIBRARIES)
@ -74,7 +75,7 @@ libtime_la_LIBADD =
am__objects_2 = asctime.lo asctime_r.lo clock.lo ctime.lo ctime_r.lo \
difftime.lo gettzinfo.lo gmtime.lo gmtime_r.lo lcltime.lo \
lcltime_r.lo mktime.lo mktm_r.lo strftime.lo strptime.lo \
time.lo tzlock.lo tzset.lo tzset_r.lo tzvars.lo
time.lo tzlock.lo tzset.lo tzset_r.lo tzvars.lo wcsftime.lo
@USE_LIBTOOL_TRUE@am_libtime_la_OBJECTS = $(am__objects_2)
libtime_la_OBJECTS = $(am_libtime_la_OBJECTS)
@USE_LIBTOOL_TRUE@am_libtime_la_rpath =
@ -283,7 +284,8 @@ LIB_SOURCES = \
tzlock.c \
tzset.c \
tzset_r.c \
tzvars.c
tzvars.c \
wcsftime.c
libtime_la_LDFLAGS = -Xcompiler -nostdlib
@USE_LIBTOOL_TRUE@noinst_LTLIBRARIES = libtime.la
@ -304,7 +306,8 @@ CHEWOUT_FILES = \
strftime.def \
time.def \
tzlock.def \
tzset.def
tzset.def \
wcsftime.def
SUFFIXES = .def
CHEW = ../../doc/makedoc -f $(srcdir)/../../doc/doc.str
@ -497,6 +500,12 @@ lib_a-tzvars.o: tzvars.c
lib_a-tzvars.obj: tzvars.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-tzvars.obj `if test -f 'tzvars.c'; then $(CYGPATH_W) 'tzvars.c'; else $(CYGPATH_W) '$(srcdir)/tzvars.c'; fi`
lib_a-wcsftime.o: wcsftime.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wcsftime.o `test -f 'wcsftime.c' || echo '$(srcdir)/'`wcsftime.c
lib_a-wcsftime.obj: wcsftime.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wcsftime.obj `if test -f 'wcsftime.c'; then $(CYGPATH_W) 'wcsftime.c'; else $(CYGPATH_W) '$(srcdir)/wcsftime.c'; fi`
mostlyclean-libtool:
-rm -f *.lo
@ -651,6 +660,9 @@ objectlist.awk.in: $(noinst_LTLIBRARIES)
echo $$i `pwd`/$$i >> objectlist.awk.in ; \
done
# This rule is needed so that wcsftime.o is rebuilt when strftime.c changes.
$(lpfx)wcsftime.$(oext): strftime.c
.c.def:
$(CHEW) < $< > $*.def 2> $*.ref
touch stmp-def

File diff suppressed because it is too large Load Diff

View File

@ -44,6 +44,8 @@ Number of days elapsed since last January 1, between 0 and 365 inclusive.
@item tm_isdst
Daylight Savings Time flag: positive means DST in effect, zero means DST
not in effect, negative means no information about DST is available.
Although for mktime(), negative means that it should decide if DST is in
effect or not.
@end table
@menu
@ -54,7 +56,7 @@ not in effect, negative means no information about DST is available.
* gmtime:: Convert time to UTC (GMT) traditional representation
* localtime:: Convert time to local representation
* mktime:: Convert time to arithmetic representation
* strftime:: Flexible calendar time formatter
* strftime:: Convert date and time to a user-formatted string
* time:: Get current calendar time (as single number)
* __tz_lock:: Lock time zone global variables
* tzset:: Set timezone info

View File

@ -0,0 +1,64 @@
/*
* wcsftime.c
* Original Author: Craig Howland, for Newlib
*
* Source actually uses strftime.c.
* Documentation for wcsftime() here, with minimal overlap.
*/
/*
FUNCTION
<<wcsftime>>--convert date and time to a formatted wide-character string
INDEX
wcsftime
ANSI_SYNOPSIS
#include <time.h>
#include <wchar.h>
size_t wcsftime(wchar_t *<[s]>, size_t <[maxsize]>,
const wchar_t *<[format]>, const struct tm *<[timp]>);
DESCRIPTION
<<strftime>> is equivalent to <<strftime>>, except that:
The argument s points to the initial element of an array of wide characters
into which the generated output is to be placed.
The argument maxsize indicates the limiting number of wide characters.
The argument format is a wide-character string and the conversion specifiers
are replaced by corresponding sequences of wide characters.
The return value indicates the number of wide characters.
See <<strftime>> for the details of the format specifiers.
RETURNS
When the formatted time takes up no more than <[maxsize]> wide characters,
the result is the length of the formatted wide string. Otherwise, if the
formatting operation was abandoned due to lack of room, the result is
<<0>>, and the wide-character string starting at <[s]> corresponds to just those
parts of <<*<[format]>>> that could be completely filled in within the
<[maxsize]> limit.
PORTABILITY
C99 and POSIX require <<wcsftime>>, but do not specify the contents of
<<*<[s]>>> when the formatted string would require more than
<[maxsize]> characters. Unrecognized specifiers and fields of
<<timp>> that are out of range cause undefined results. Since some
formats expand to 0 bytes, it is wise to set <<*<[s]>>> to a nonzero
value beforehand to distinguish between failure and an empty string.
This implementation does not support <<s>> being NULL, nor overlapping
<<s>> and <<format>>.
SEEALSO
<<strftime>>
<<wcsftime>> requires no supporting OS subroutines.
*/
#include <time.h>
#include <wchar.h>
#define MAKE_WCSFTIME
#include "../time/strftime.c"