URL
https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk
Subversion Repositories openrisc_2011-10-31
Compare Revisions
- This comparison shows the changes necessary to convert path
/openrisc/tags/gnu-src/newlib-1.18.0/newlib-1.18.0-or32-1.0rc1/newlib/libc/time
- from Rev 207 to Rev 345
- ↔ Reverse comparison
Rev 207 → Rev 345
/time.c
0,0 → 1,53
/* |
FUNCTION |
<<time>>---get current calendar time (as single number) |
|
INDEX |
time |
|
ANSI_SYNOPSIS |
#include <time.h> |
time_t time(time_t *<[t]>); |
|
TRAD_SYNOPSIS |
#include <time.h> |
time_t time(<[t]>) |
time_t *<[t]>; |
|
DESCRIPTION |
<<time>> looks up the best available representation of the current |
time and returns it, encoded as a <<time_t>>. It stores the same |
value at <[t]> unless the argument is <<NULL>>. |
|
RETURNS |
A <<-1>> result means the current time is not available; otherwise the |
result represents the current time. |
|
PORTABILITY |
ANSI C requires <<time>>. |
|
Supporting OS subroutine required: Some implementations require |
<<gettimeofday>>. |
*/ |
|
/* Most times we have a system call in newlib/libc/sys/.. to do this job */ |
|
#include <_ansi.h> |
#include <reent.h> |
#include <sys/types.h> |
#include <sys/time.h> |
|
time_t |
_DEFUN (time, (t), |
time_t * t) |
{ |
struct timeval now; |
|
if (_gettimeofday_r (_REENT, &now, NULL) >= 0) |
{ |
if (t) |
*t = now.tv_sec; |
return now.tv_sec; |
} |
return -1; |
} |
time.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: local.h
===================================================================
--- local.h (nonexistent)
+++ local.h (revision 345)
@@ -0,0 +1,36 @@
+/* local header used by libc/time routines */
+#include <_ansi.h>
+#include
+
+#define SECSPERMIN 60L
+#define MINSPERHOUR 60L
+#define HOURSPERDAY 24L
+#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR)
+#define SECSPERDAY (SECSPERHOUR * HOURSPERDAY)
+#define DAYSPERWEEK 7
+#define MONSPERYEAR 12
+
+#define YEAR_BASE 1900
+#define EPOCH_YEAR 1970
+#define EPOCH_WDAY 4
+#define EPOCH_YEARS_SINCE_LEAP 2
+#define EPOCH_YEARS_SINCE_CENTURY 70
+#define EPOCH_YEARS_SINCE_LEAP_CENTURY 370
+
+#define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0)
+
+struct tm * _EXFUN (_mktm_r, (_CONST time_t *, struct tm *, int __is_gmtime));
+int _EXFUN (__tzcalc_limits, (int __year));
+
+/* locks for multi-threading */
+#ifdef __SINGLE_THREAD__
+#define TZ_LOCK
+#define TZ_UNLOCK
+#else
+#define TZ_LOCK __tz_lock()
+#define TZ_UNLOCK __tz_unlock()
+#endif
+
+void _EXFUN(__tz_lock,(_VOID));
+void _EXFUN(__tz_unlock,(_VOID));
+
local.h
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: Makefile.in
===================================================================
--- Makefile.in (nonexistent)
+++ Makefile.in (revision 345)
@@ -0,0 +1,676 @@
+# Makefile.in generated by automake 1.11 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+DIST_COMMON = $(srcdir)/../../Makefile.shared $(srcdir)/Makefile.in \
+ $(srcdir)/Makefile.am
+subdir = time
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/../../libtool.m4 \
+ $(top_srcdir)/../../ltoptions.m4 \
+ $(top_srcdir)/../../ltsugar.m4 \
+ $(top_srcdir)/../../ltversion.m4 \
+ $(top_srcdir)/../../lt~obsolete.m4 \
+ $(top_srcdir)/../acinclude.m4 $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/../../mkinstalldirs
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+ARFLAGS = cru
+lib_a_AR = $(AR) $(ARFLAGS)
+lib_a_LIBADD =
+am__objects_1 = lib_a-asctime.$(OBJEXT) lib_a-asctime_r.$(OBJEXT) \
+ lib_a-clock.$(OBJEXT) lib_a-ctime.$(OBJEXT) \
+ lib_a-ctime_r.$(OBJEXT) lib_a-difftime.$(OBJEXT) \
+ lib_a-gettzinfo.$(OBJEXT) lib_a-gmtime.$(OBJEXT) \
+ lib_a-gmtime_r.$(OBJEXT) lib_a-lcltime.$(OBJEXT) \
+ lib_a-lcltime_r.$(OBJEXT) lib_a-mktime.$(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-wcsftime.$(OBJEXT)
+@USE_LIBTOOL_FALSE@am_lib_a_OBJECTS = $(am__objects_1)
+lib_a_OBJECTS = $(am_lib_a_OBJECTS)
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+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 wcsftime.lo
+@USE_LIBTOOL_TRUE@am_libtime_la_OBJECTS = $(am__objects_2)
+libtime_la_OBJECTS = $(am_libtime_la_OBJECTS)
+libtime_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(libtime_la_LDFLAGS) $(LDFLAGS) -o $@
+@USE_LIBTOOL_TRUE@am_libtime_la_rpath =
+DEFAULT_INCLUDES = -I.@am__isrc@
+depcomp =
+am__depfiles_maybe =
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(lib_a_SOURCES) $(libtime_la_SOURCES)
+DATA = $(noinst_DATA)
+ETAGS = etags
+CTAGS = ctags
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCAS = @CCAS@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CRT0 = @CRT0@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBC_EXTRA_DEF = @LIBC_EXTRA_DEF@
+LIBC_EXTRA_LIB = @LIBC_EXTRA_LIB@
+LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@
+LIBC_POSIX_LIB = @LIBC_POSIX_LIB@
+LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@
+LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@
+LIBC_STDIO64_DEF = @LIBC_STDIO64_DEF@
+LIBC_STDIO64_LIB = @LIBC_STDIO64_LIB@
+LIBC_STDIO_DEF = @LIBC_STDIO_DEF@
+LIBC_STDIO_LIB = @LIBC_STDIO_LIB@
+LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
+LIBC_SYS_LIB = @LIBC_SYS_LIB@
+LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NEWLIB_CFLAGS = @NEWLIB_CFLAGS@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+RANLIB = @RANLIB@
+READELF = @READELF@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+aext = @aext@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+extra_dir = @extra_dir@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+libm_machine_dir = @libm_machine_dir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lpfx = @lpfx@
+lt_ECHO = @lt_ECHO@
+machine_dir = @machine_dir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+newlib_basedir = @newlib_basedir@
+oext = @oext@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+subdirs = @subdirs@
+sys_dir = @sys_dir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = cygnus
+INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
+LIB_SOURCES = \
+ asctime.c \
+ asctime_r.c \
+ clock.c \
+ ctime.c \
+ ctime_r.c \
+ difftime.c \
+ gettzinfo.c \
+ gmtime.c \
+ gmtime_r.c \
+ lcltime.c \
+ lcltime_r.c \
+ mktime.c \
+ mktm_r.c \
+ strftime.c \
+ strptime.c \
+ time.c \
+ tzlock.c \
+ tzset.c \
+ tzset_r.c \
+ tzvars.c \
+ wcsftime.c
+
+libtime_la_LDFLAGS = -Xcompiler -nostdlib
+@USE_LIBTOOL_TRUE@noinst_LTLIBRARIES = libtime.la
+@USE_LIBTOOL_TRUE@libtime_la_SOURCES = $(LIB_SOURCES)
+@USE_LIBTOOL_FALSE@noinst_DATA =
+@USE_LIBTOOL_TRUE@noinst_DATA = objectlist.awk.in
+@USE_LIBTOOL_FALSE@noinst_LIBRARIES = lib.a
+@USE_LIBTOOL_FALSE@lib_a_SOURCES = $(LIB_SOURCES)
+@USE_LIBTOOL_FALSE@lib_a_CFLAGS = $(AM_CFLAGS)
+CHEWOUT_FILES = \
+ asctime.def \
+ clock.def \
+ ctime.def \
+ difftime.def \
+ gmtime.def \
+ lcltime.def \
+ mktime.def \
+ strftime.def \
+ time.def \
+ tzlock.def \
+ tzset.def \
+ wcsftime.def
+
+SUFFIXES = .def
+CHEW = ../../doc/makedoc -f $(srcdir)/../../doc/doc.str
+TARGETDOC = ../tmp.texi
+CLEANFILES = $(CHEWOUT_FILES) *.ref
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .def .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/../../Makefile.shared $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --cygnus time/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --cygnus time/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLIBRARIES:
+ -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+lib.a: $(lib_a_OBJECTS) $(lib_a_DEPENDENCIES)
+ -rm -f lib.a
+ $(lib_a_AR) lib.a $(lib_a_OBJECTS) $(lib_a_LIBADD)
+ $(RANLIB) lib.a
+
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libtime.la: $(libtime_la_OBJECTS) $(libtime_la_DEPENDENCIES)
+ $(libtime_la_LINK) $(am_libtime_la_rpath) $(libtime_la_OBJECTS) $(libtime_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+.c.o:
+ $(COMPILE) -c $<
+
+.c.obj:
+ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+ $(LTCOMPILE) -c -o $@ $<
+
+lib_a-asctime.o: asctime.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-asctime.o `test -f 'asctime.c' || echo '$(srcdir)/'`asctime.c
+
+lib_a-asctime.obj: asctime.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-asctime.obj `if test -f 'asctime.c'; then $(CYGPATH_W) 'asctime.c'; else $(CYGPATH_W) '$(srcdir)/asctime.c'; fi`
+
+lib_a-asctime_r.o: asctime_r.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-asctime_r.o `test -f 'asctime_r.c' || echo '$(srcdir)/'`asctime_r.c
+
+lib_a-asctime_r.obj: asctime_r.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-asctime_r.obj `if test -f 'asctime_r.c'; then $(CYGPATH_W) 'asctime_r.c'; else $(CYGPATH_W) '$(srcdir)/asctime_r.c'; fi`
+
+lib_a-clock.o: clock.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-clock.o `test -f 'clock.c' || echo '$(srcdir)/'`clock.c
+
+lib_a-clock.obj: clock.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-clock.obj `if test -f 'clock.c'; then $(CYGPATH_W) 'clock.c'; else $(CYGPATH_W) '$(srcdir)/clock.c'; fi`
+
+lib_a-ctime.o: ctime.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-ctime.o `test -f 'ctime.c' || echo '$(srcdir)/'`ctime.c
+
+lib_a-ctime.obj: ctime.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-ctime.obj `if test -f 'ctime.c'; then $(CYGPATH_W) 'ctime.c'; else $(CYGPATH_W) '$(srcdir)/ctime.c'; fi`
+
+lib_a-ctime_r.o: ctime_r.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-ctime_r.o `test -f 'ctime_r.c' || echo '$(srcdir)/'`ctime_r.c
+
+lib_a-ctime_r.obj: ctime_r.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-ctime_r.obj `if test -f 'ctime_r.c'; then $(CYGPATH_W) 'ctime_r.c'; else $(CYGPATH_W) '$(srcdir)/ctime_r.c'; fi`
+
+lib_a-difftime.o: difftime.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-difftime.o `test -f 'difftime.c' || echo '$(srcdir)/'`difftime.c
+
+lib_a-difftime.obj: difftime.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-difftime.obj `if test -f 'difftime.c'; then $(CYGPATH_W) 'difftime.c'; else $(CYGPATH_W) '$(srcdir)/difftime.c'; fi`
+
+lib_a-gettzinfo.o: gettzinfo.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-gettzinfo.o `test -f 'gettzinfo.c' || echo '$(srcdir)/'`gettzinfo.c
+
+lib_a-gettzinfo.obj: gettzinfo.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-gettzinfo.obj `if test -f 'gettzinfo.c'; then $(CYGPATH_W) 'gettzinfo.c'; else $(CYGPATH_W) '$(srcdir)/gettzinfo.c'; fi`
+
+lib_a-gmtime.o: gmtime.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-gmtime.o `test -f 'gmtime.c' || echo '$(srcdir)/'`gmtime.c
+
+lib_a-gmtime.obj: gmtime.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-gmtime.obj `if test -f 'gmtime.c'; then $(CYGPATH_W) 'gmtime.c'; else $(CYGPATH_W) '$(srcdir)/gmtime.c'; fi`
+
+lib_a-gmtime_r.o: gmtime_r.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-gmtime_r.o `test -f 'gmtime_r.c' || echo '$(srcdir)/'`gmtime_r.c
+
+lib_a-gmtime_r.obj: gmtime_r.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-gmtime_r.obj `if test -f 'gmtime_r.c'; then $(CYGPATH_W) 'gmtime_r.c'; else $(CYGPATH_W) '$(srcdir)/gmtime_r.c'; fi`
+
+lib_a-lcltime.o: lcltime.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-lcltime.o `test -f 'lcltime.c' || echo '$(srcdir)/'`lcltime.c
+
+lib_a-lcltime.obj: lcltime.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-lcltime.obj `if test -f 'lcltime.c'; then $(CYGPATH_W) 'lcltime.c'; else $(CYGPATH_W) '$(srcdir)/lcltime.c'; fi`
+
+lib_a-lcltime_r.o: lcltime_r.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-lcltime_r.o `test -f 'lcltime_r.c' || echo '$(srcdir)/'`lcltime_r.c
+
+lib_a-lcltime_r.obj: lcltime_r.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-lcltime_r.obj `if test -f 'lcltime_r.c'; then $(CYGPATH_W) 'lcltime_r.c'; else $(CYGPATH_W) '$(srcdir)/lcltime_r.c'; fi`
+
+lib_a-mktime.o: mktime.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mktime.o `test -f 'mktime.c' || echo '$(srcdir)/'`mktime.c
+
+lib_a-mktime.obj: mktime.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mktime.obj `if test -f 'mktime.c'; then $(CYGPATH_W) 'mktime.c'; else $(CYGPATH_W) '$(srcdir)/mktime.c'; fi`
+
+lib_a-mktm_r.o: mktm_r.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mktm_r.o `test -f 'mktm_r.c' || echo '$(srcdir)/'`mktm_r.c
+
+lib_a-mktm_r.obj: mktm_r.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mktm_r.obj `if test -f 'mktm_r.c'; then $(CYGPATH_W) 'mktm_r.c'; else $(CYGPATH_W) '$(srcdir)/mktm_r.c'; fi`
+
+lib_a-strftime.o: strftime.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strftime.o `test -f 'strftime.c' || echo '$(srcdir)/'`strftime.c
+
+lib_a-strftime.obj: strftime.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strftime.obj `if test -f 'strftime.c'; then $(CYGPATH_W) 'strftime.c'; else $(CYGPATH_W) '$(srcdir)/strftime.c'; fi`
+
+lib_a-strptime.o: strptime.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strptime.o `test -f 'strptime.c' || echo '$(srcdir)/'`strptime.c
+
+lib_a-strptime.obj: strptime.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strptime.obj `if test -f 'strptime.c'; then $(CYGPATH_W) 'strptime.c'; else $(CYGPATH_W) '$(srcdir)/strptime.c'; fi`
+
+lib_a-time.o: time.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-time.o `test -f 'time.c' || echo '$(srcdir)/'`time.c
+
+lib_a-time.obj: time.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-time.obj `if test -f 'time.c'; then $(CYGPATH_W) 'time.c'; else $(CYGPATH_W) '$(srcdir)/time.c'; fi`
+
+lib_a-tzlock.o: tzlock.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-tzlock.o `test -f 'tzlock.c' || echo '$(srcdir)/'`tzlock.c
+
+lib_a-tzlock.obj: tzlock.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-tzlock.obj `if test -f 'tzlock.c'; then $(CYGPATH_W) 'tzlock.c'; else $(CYGPATH_W) '$(srcdir)/tzlock.c'; fi`
+
+lib_a-tzset.o: tzset.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-tzset.o `test -f 'tzset.c' || echo '$(srcdir)/'`tzset.c
+
+lib_a-tzset.obj: tzset.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-tzset.obj `if test -f 'tzset.c'; then $(CYGPATH_W) 'tzset.c'; else $(CYGPATH_W) '$(srcdir)/tzset.c'; fi`
+
+lib_a-tzset_r.o: tzset_r.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-tzset_r.o `test -f 'tzset_r.c' || echo '$(srcdir)/'`tzset_r.c
+
+lib_a-tzset_r.obj: tzset_r.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-tzset_r.obj `if test -f 'tzset_r.c'; then $(CYGPATH_W) 'tzset_r.c'; else $(CYGPATH_W) '$(srcdir)/tzset_r.c'; fi`
+
+lib_a-tzvars.o: tzvars.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-tzvars.o `test -f 'tzvars.c' || echo '$(srcdir)/'`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
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+check-am:
+check: check-am
+all-am: Makefile $(LIBRARIES) $(LTLIBRARIES) $(DATA)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \
+ clean-noinstLTLIBRARIES mostlyclean-am
+
+distclean: distclean-am
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-noinstLIBRARIES clean-noinstLTLIBRARIES \
+ ctags distclean distclean-compile distclean-generic \
+ distclean-libtool distclean-tags dvi dvi-am html html-am info \
+ info-am install install-am install-data install-data-am \
+ install-dvi install-dvi-am install-exec install-exec-am \
+ install-html install-html-am install-info install-info-am \
+ install-man install-pdf install-pdf-am install-ps \
+ install-ps-am install-strip installcheck installcheck-am \
+ installdirs maintainer-clean maintainer-clean-generic \
+ mostlyclean mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \
+ uninstall-am
+
+objectlist.awk.in: $(noinst_LTLIBRARIES)
+ -rm -f objectlist.awk.in
+ for i in `ls *.lo` ; \
+ do \
+ 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
+
+doc: $(CHEWOUT_FILES)
+ cat $(srcdir)/time.tex >> $(TARGETDOC)
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
Index: ctime.c
===================================================================
--- ctime.c (nonexistent)
+++ ctime.c (revision 345)
@@ -0,0 +1,55 @@
+/*
+ * ctime.c
+ * Original Author: G. Haley
+ */
+
+/*
+FUNCTION
+<>---convert time to local and format as string
+
+INDEX
+ ctime
+INDEX
+ ctime_r
+
+ANSI_SYNOPSIS
+ #include
+ char *ctime(const time_t *<[clock]>);
+ char *ctime_r(const time_t *<[clock]>, char *<[buf]>);
+
+TRAD_SYNOPSIS
+ #include
+ char *ctime(<[clock]>)
+ time_t *<[clock]>;
+
+ char *ctime_r(<[clock]>, <[buf]>)
+ time_t *<[clock]>;
+ char *<[buf]>;
+
+DESCRIPTION
+Convert the time value at <[clock]> to local time (like <>)
+and format it into a string of the form
+. Wed Jun 15 11:38:07 1988\n\0
+(like <>).
+
+RETURNS
+A pointer to the string containing a formatted timestamp.
+
+PORTABILITY
+ANSI C requires <>.
+
+<> requires no supporting OS subroutines.
+*/
+
+#include
+
+#ifndef _REENT_ONLY
+
+char *
+_DEFUN (ctime, (tim_p),
+ _CONST time_t * tim_p)
+{
+ return asctime (localtime (tim_p));
+}
+
+#endif
ctime.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: gmtime_r.c
===================================================================
--- gmtime_r.c (nonexistent)
+++ gmtime_r.c (revision 345)
@@ -0,0 +1,14 @@
+/*
+ * gmtime_r.c
+ */
+
+#include
+#include "local.h"
+
+struct tm *
+_DEFUN (gmtime_r, (tim_p, res),
+ _CONST time_t * tim_p _AND
+ struct tm *res)
+{
+ return (_mktm_r (tim_p, res, 1));
+}
gmtime_r.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: tzlock.c
===================================================================
--- tzlock.c (nonexistent)
+++ tzlock.c (revision 345)
@@ -0,0 +1,56 @@
+/*
+FUNCTION
+<<__tz_lock>>, <<__tz_unlock>>---lock time zone global variables
+
+INDEX
+ __tz_lock
+INDEX
+ __tz_unlock
+
+ANSI_SYNOPSIS
+ #include "local.h"
+ void __tz_lock (void);
+ void __tz_unlock (void);
+
+TRAD_SYNOPSIS
+ void __tz_lock();
+ void __tz_unlock();
+
+DESCRIPTION
+The <> facility functions call these functions when they need to
+ensure the values of global variables. The version of these routines
+supplied in the library use the lock API defined in sys/lock.h. If multiple
+threads of execution can call the time functions and give up scheduling in
+the middle, then you you need to define your own versions of these functions
+in order to safely lock the time zone variables during a call. If you do
+not, the results of <>, <>, <>, and <>
+are undefined.
+
+The lock <<__tz_lock>> may not be called recursively; that is,
+a call <<__tz_lock>> will always lock all subsequent <<__tz_lock>> calls
+until the corresponding <<__tz_unlock>> call on the same thread is made.
+*/
+
+#include <_ansi.h>
+#include "local.h"
+#include
+
+#ifndef __SINGLE_THREAD__
+__LOCK_INIT(static, __tz_lock_object);
+#endif
+
+_VOID
+_DEFUN_VOID (__tz_lock)
+{
+#ifndef __SINGLE_THREAD__
+ __lock_acquire(__tz_lock_object);
+#endif
+}
+
+_VOID
+_DEFUN_VOID (__tz_unlock)
+{
+#ifndef __SINGLE_THREAD__
+ __lock_release(__tz_lock_object);
+#endif
+}
tzlock.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: asctime_r.c
===================================================================
--- asctime_r.c (nonexistent)
+++ asctime_r.c (revision 345)
@@ -0,0 +1,27 @@
+/*
+ * asctime_r.c
+ */
+
+#include
+#include
+
+char *
+_DEFUN (asctime_r, (tim_p, result),
+ _CONST struct tm *tim_p _AND
+ char *result)
+{
+ static _CONST char day_name[7][3] = {
+ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
+ };
+ static _CONST char mon_name[12][3] = {
+ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
+ };
+
+ sprintf (result, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
+ day_name[tim_p->tm_wday],
+ mon_name[tim_p->tm_mon],
+ tim_p->tm_mday, tim_p->tm_hour, tim_p->tm_min,
+ tim_p->tm_sec, 1900 + tim_p->tm_year);
+ return result;
+}
asctime_r.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: strptime.c
===================================================================
--- strptime.c (nonexistent)
+++ strptime.c (revision 345)
@@ -0,0 +1,446 @@
+/*
+ * Copyright (c) 1999 Kungliga Tekniska Högskolan
+ * (Royal Institute of Technology, Stockholm, Sweden).
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of KTH nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY KTH AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KTH OR ITS CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+static const char *abb_weekdays[] = {
+ "Sun",
+ "Mon",
+ "Tue",
+ "Wed",
+ "Thu",
+ "Fri",
+ "Sat",
+ NULL
+};
+
+static const char *full_weekdays[] = {
+ "Sunday",
+ "Monday",
+ "Tuesday",
+ "Wednesday",
+ "Thursday",
+ "Friday",
+ "Saturday",
+ NULL
+};
+
+static const char *abb_month[] = {
+ "Jan",
+ "Feb",
+ "Mar",
+ "Apr",
+ "May",
+ "Jun",
+ "Jul",
+ "Aug",
+ "Sep",
+ "Oct",
+ "Nov",
+ "Dec",
+ NULL
+};
+
+static const char *full_month[] = {
+ "January",
+ "February",
+ "March",
+ "April",
+ "May",
+ "June",
+ "July",
+ "August",
+ "September",
+ "October",
+ "November",
+ "December",
+ NULL,
+};
+
+static const char *ampm[] = {
+ "am",
+ "pm",
+ NULL
+};
+
+/*
+ * tm_year is relative this year
+ */
+const int tm_year_base = 1900;
+
+/*
+ * Return TRUE iff `year' was a leap year.
+ * Needed for strptime.
+ */
+static int
+is_leap_year (int year)
+{
+ return (year % 4) == 0 && ((year % 100) != 0 || (year % 400) == 0);
+}
+
+/* Needed for strptime. */
+static int
+match_string (const char **buf, const char **strs)
+{
+ int i = 0;
+
+ for (i = 0; strs[i] != NULL; ++i) {
+ int len = strlen (strs[i]);
+
+ if (strncasecmp (*buf, strs[i], len) == 0) {
+ *buf += len;
+ return i;
+ }
+ }
+ return -1;
+}
+
+/* Needed for strptime. */
+static int
+first_day (int year)
+{
+ int ret = 4;
+
+ for (; year > 1970; --year)
+ ret = (ret + 365 + is_leap_year (year) ? 1 : 0) % 7;
+ return ret;
+}
+
+/*
+ * Set `timeptr' given `wnum' (week number [0, 53])
+ * Needed for strptime
+ */
+
+static void
+set_week_number_sun (struct tm *timeptr, int wnum)
+{
+ int fday = first_day (timeptr->tm_year + tm_year_base);
+
+ timeptr->tm_yday = wnum * 7 + timeptr->tm_wday - fday;
+ if (timeptr->tm_yday < 0) {
+ timeptr->tm_wday = fday;
+ timeptr->tm_yday = 0;
+ }
+}
+
+/*
+ * Set `timeptr' given `wnum' (week number [0, 53])
+ * Needed for strptime
+ */
+
+static void
+set_week_number_mon (struct tm *timeptr, int wnum)
+{
+ int fday = (first_day (timeptr->tm_year + tm_year_base) + 6) % 7;
+
+ timeptr->tm_yday = wnum * 7 + (timeptr->tm_wday + 6) % 7 - fday;
+ if (timeptr->tm_yday < 0) {
+ timeptr->tm_wday = (fday + 1) % 7;
+ timeptr->tm_yday = 0;
+ }
+}
+
+/*
+ * Set `timeptr' given `wnum' (week number [0, 53])
+ * Needed for strptime
+ */
+static void
+set_week_number_mon4 (struct tm *timeptr, int wnum)
+{
+ int fday = (first_day (timeptr->tm_year + tm_year_base) + 6) % 7;
+ int offset = 0;
+
+ if (fday < 4)
+ offset += 7;
+
+ timeptr->tm_yday = offset + (wnum - 1) * 7 + timeptr->tm_wday - fday;
+ if (timeptr->tm_yday < 0) {
+ timeptr->tm_wday = fday;
+ timeptr->tm_yday = 0;
+ }
+}
+
+/* strptime: roken */
+//extern "C"
+char *
+//strptime (const char *buf, const char *format, struct tm *timeptr)
+_DEFUN (strptime, (buf, format, timeptr),
+ _CONST char *buf _AND
+ _CONST char *format _AND
+ struct tm *timeptr)
+{
+ char c;
+
+ for (; (c = *format) != '\0'; ++format) {
+ char *s;
+ int ret;
+
+ if (isspace (c)) {
+ while (isspace (*buf))
+ ++buf;
+ } else if (c == '%' && format[1] != '\0') {
+ c = *++format;
+ if (c == 'E' || c == 'O')
+ c = *++format;
+ switch (c) {
+ case 'A' :
+ ret = match_string (&buf, full_weekdays);
+ if (ret < 0)
+ return NULL;
+ timeptr->tm_wday = ret;
+ break;
+ case 'a' :
+ ret = match_string (&buf, abb_weekdays);
+ if (ret < 0)
+ return NULL;
+ timeptr->tm_wday = ret;
+ break;
+ case 'B' :
+ ret = match_string (&buf, full_month);
+ if (ret < 0)
+ return NULL;
+ timeptr->tm_mon = ret;
+ break;
+ case 'b' :
+ case 'h' :
+ ret = match_string (&buf, abb_month);
+ if (ret < 0)
+ return NULL;
+ timeptr->tm_mon = ret;
+ break;
+ case 'C' :
+ ret = strtol (buf, &s, 10);
+ if (s == buf)
+ return NULL;
+ timeptr->tm_year = (ret * 100) - tm_year_base;
+ buf = s;
+ break;
+ case 'c' : /* %a %b %e %H:%M:%S %Y */
+ s = strptime (buf, "%a %b %e %H:%M:%S %Y", timeptr);
+ if (s == NULL)
+ return NULL;
+ buf = s;
+ break;
+ case 'D' : /* %m/%d/%y */
+ s = strptime (buf, "%m/%d/%y", timeptr);
+ if (s == NULL)
+ return NULL;
+ buf = s;
+ break;
+ case 'd' :
+ case 'e' :
+ ret = strtol (buf, &s, 10);
+ if (s == buf)
+ return NULL;
+ timeptr->tm_mday = ret;
+ buf = s;
+ break;
+ case 'H' :
+ case 'k' :
+ ret = strtol (buf, &s, 10);
+ if (s == buf)
+ return NULL;
+ timeptr->tm_hour = ret;
+ buf = s;
+ break;
+ case 'I' :
+ case 'l' :
+ ret = strtol (buf, &s, 10);
+ if (s == buf)
+ return NULL;
+ if (ret == 12)
+ timeptr->tm_hour = 0;
+ else
+ timeptr->tm_hour = ret;
+ buf = s;
+ break;
+ case 'j' :
+ ret = strtol (buf, &s, 10);
+ if (s == buf)
+ return NULL;
+ timeptr->tm_yday = ret - 1;
+ buf = s;
+ break;
+ case 'm' :
+ ret = strtol (buf, &s, 10);
+ if (s == buf)
+ return NULL;
+ timeptr->tm_mon = ret - 1;
+ buf = s;
+ break;
+ case 'M' :
+ ret = strtol (buf, &s, 10);
+ if (s == buf)
+ return NULL;
+ timeptr->tm_min = ret;
+ buf = s;
+ break;
+ case 'n' :
+ if (*buf == '\n')
+ ++buf;
+ else
+ return NULL;
+ break;
+ case 'p' :
+ ret = match_string (&buf, ampm);
+ if (ret < 0)
+ return NULL;
+ if (timeptr->tm_hour == 0) {
+ if (ret == 1)
+ timeptr->tm_hour = 12;
+ } else
+ timeptr->tm_hour += 12;
+ break;
+ case 'r' : /* %I:%M:%S %p */
+ s = strptime (buf, "%I:%M:%S %p", timeptr);
+ if (s == NULL)
+ return NULL;
+ buf = s;
+ break;
+ case 'R' : /* %H:%M */
+ s = strptime (buf, "%H:%M", timeptr);
+ if (s == NULL)
+ return NULL;
+ buf = s;
+ break;
+ case 'S' :
+ ret = strtol (buf, &s, 10);
+ if (s == buf)
+ return NULL;
+ timeptr->tm_sec = ret;
+ buf = s;
+ break;
+ case 't' :
+ if (*buf == '\t')
+ ++buf;
+ else
+ return NULL;
+ break;
+ case 'T' : /* %H:%M:%S */
+ case 'X' :
+ s = strptime (buf, "%H:%M:%S", timeptr);
+ if (s == NULL)
+ return NULL;
+ buf = s;
+ break;
+ case 'u' :
+ ret = strtol (buf, &s, 10);
+ if (s == buf)
+ return NULL;
+ timeptr->tm_wday = ret - 1;
+ buf = s;
+ break;
+ case 'w' :
+ ret = strtol (buf, &s, 10);
+ if (s == buf)
+ return NULL;
+ timeptr->tm_wday = ret;
+ buf = s;
+ break;
+ case 'U' :
+ ret = strtol (buf, &s, 10);
+ if (s == buf)
+ return NULL;
+ set_week_number_sun (timeptr, ret);
+ buf = s;
+ break;
+ case 'V' :
+ ret = strtol (buf, &s, 10);
+ if (s == buf)
+ return NULL;
+ set_week_number_mon4 (timeptr, ret);
+ buf = s;
+ break;
+ case 'W' :
+ ret = strtol (buf, &s, 10);
+ if (s == buf)
+ return NULL;
+ set_week_number_mon (timeptr, ret);
+ buf = s;
+ break;
+ case 'x' :
+ s = strptime (buf, "%Y:%m:%d", timeptr);
+ if (s == NULL)
+ return NULL;
+ buf = s;
+ break;
+ case 'y' :
+ ret = strtol (buf, &s, 10);
+ if (s == buf)
+ return NULL;
+ if (ret < 70)
+ timeptr->tm_year = 100 + ret;
+ else
+ timeptr->tm_year = ret;
+ buf = s;
+ break;
+ case 'Y' :
+ ret = strtol (buf, &s, 10);
+ if (s == buf)
+ return NULL;
+ timeptr->tm_year = ret - tm_year_base;
+ buf = s;
+ break;
+ case 'Z' :
+ /* Unsupported. Just ignore. */
+ break;
+ case '\0' :
+ --format;
+ /* FALLTHROUGH */
+ case '%' :
+ if (*buf == '%')
+ ++buf;
+ else
+ return NULL;
+ break;
+ default :
+ if (*buf == '%' || *++buf == c)
+ ++buf;
+ else
+ return NULL;
+ break;
+ }
+ } else {
+ if (*buf == c)
+ ++buf;
+ else
+ return NULL;
+ }
+ }
+ return (char *)buf;
+}
+
strptime.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: tzset.c
===================================================================
--- tzset.c (nonexistent)
+++ tzset.c (revision 345)
@@ -0,0 +1,74 @@
+/*
+FUNCTION
+<>---set timezone characteristics from TZ environment variable
+
+INDEX
+ tzset
+INDEX
+ _tzset_r
+
+ANSI_SYNOPSIS
+ #include
+ void tzset(void);
+ void _tzset_r (struct _reent *);
+
+TRAD_SYNOPSIS
+ #include
+ void tzset();
+ void _tzset_r (reent_ptr)
+ struct _reent *reent_ptr;
+
+DESCRIPTION
+<> examines the TZ environment variable and sets up the three
+external variables: <<_timezone>>, <<_daylight>>, and <>. The
+value of <<_timezone>> shall be the offset from the current time zone
+to GMT. The value of <<_daylight>> shall be 0 if there is no daylight
+savings time for the current time zone, otherwise it will be non-zero.
+The <> array has two entries: the first is the name of the
+standard time zone, the second is the name of the daylight-savings time
+zone.
+
+The TZ environment variable is expected to be in the following POSIX
+format:
+
+ stdoffset1[dst[offset2][,start[/time1],end[/time2]]]
+
+where: std is the name of the standard time-zone (minimum 3 chars)
+ offset1 is the value to add to local time to arrive at Universal time
+ it has the form: hh[:mm[:ss]]
+ dst is the name of the alternate (daylight-savings) time-zone (min 3 chars)
+ offset2 is the value to add to local time to arrive at Universal time
+ it has the same format as the std offset
+ start is the day that the alternate time-zone starts
+ time1 is the optional time that the alternate time-zone starts
+ (this is in local time and defaults to 02:00:00 if not specified)
+ end is the day that the alternate time-zone ends
+ time2 is the time that the alternate time-zone ends
+ (it is in local time and defaults to 02:00:00 if not specified)
+
+Note that there is no white-space padding between fields. Also note that
+if TZ is null, the default is Universal GMT which has no daylight-savings
+time. If TZ is empty, the default EST5EDT is used.
+
+The function <<_tzset_r>> is identical to <> only it is reentrant
+and is used for applications that use multiple threads.
+
+RETURNS
+There is no return value.
+
+PORTABILITY
+<> is part of the POSIX standard.
+
+Supporting OS subroutine required: None
+*/
+
+#include <_ansi.h>
+#include
+#include
+#include "local.h"
+
+_VOID
+_DEFUN_VOID (tzset)
+{
+ _tzset_r (_REENT);
+}
tzset.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: gettzinfo.c
===================================================================
--- gettzinfo.c (nonexistent)
+++ gettzinfo.c (revision 345)
@@ -0,0 +1,15 @@
+#include
+#include
+
+/* Shared timezone information for libc/time functions. */
+static __tzinfo_type tzinfo = {1, 0,
+ { {'J', 0, 0, 0, 0, (time_t)0, 0L },
+ {'J', 0, 0, 0, 0, (time_t)0, 0L }
+ }
+};
+
+__tzinfo_type *
+__gettzinfo (void)
+{
+ return &tzinfo;
+}
gettzinfo.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: lcltime_r.c
===================================================================
--- lcltime_r.c (nonexistent)
+++ lcltime_r.c (revision 345)
@@ -0,0 +1,18 @@
+/*
+ * localtime_r.c
+ *
+ * Converts the calendar time pointed to by tim_p into a broken-down time
+ * expressed as local time. Returns a pointer to a structure containing the
+ * broken-down time.
+ */
+
+#include
+#include "local.h"
+
+struct tm *
+_DEFUN (localtime_r, (tim_p, res),
+ _CONST time_t * tim_p _AND
+ struct tm *res)
+{
+ return _mktm_r (tim_p, res, 0);
+}
lcltime_r.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: time.tex
===================================================================
--- time.tex (nonexistent)
+++ time.tex (revision 345)
@@ -0,0 +1,96 @@
+@node Timefns
+@chapter Time Functions (@file{time.h})
+
+This chapter groups functions used either for reporting on time
+(elapsed, current, or compute time) or to perform calculations based
+on time.
+
+The header file @file{time.h} defines three types. @code{clock_t} and
+@code{time_t} are both used for representations of time particularly
+suitable for arithmetic. (In this implementation, quantities of type
+@code{clock_t} have the highest resolution possible on your machine,
+and quantities of type @code{time_t} resolve to seconds.) @code{size_t}
+is also defined if necessary for quantities representing sizes.
+
+@file{time.h} also defines the structure @code{tm} for the traditional
+representation of Gregorian calendar time as a series of numbers, with
+the following fields:
+
+@table @code
+@item tm_sec
+Seconds, between 0 and 60 inclusive (60 allows for leap seconds).
+
+@item tm_min
+Minutes, between 0 and 59 inclusive.
+
+@item tm_hour
+Hours, between 0 and 23 inclusive.
+
+@item tm_mday
+Day of the month, between 1 and 31 inclusive.
+
+@item tm_mon
+Month, between 0 (January) and 11 (December).
+
+@item tm_year
+Year (since 1900), can be negative for earlier years.
+
+@item tm_wday
+Day of week, between 0 (Sunday) and 6 (Saturday).
+
+@item tm_yday
+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
+* asctime:: Format time as string
+* clock:: Cumulative processor time
+* ctime:: Convert time to local and format as string
+* difftime:: Subtract two times
+* gmtime:: Convert time to UTC (GMT) traditional representation
+* localtime:: Convert time to local representation
+* mktime:: Convert time to arithmetic representation
+* 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
+@end menu
+
+@page
+@include time/asctime.def
+
+@page
+@include time/clock.def
+
+@page
+@include time/ctime.def
+
+@page
+@include time/difftime.def
+
+@page
+@include time/gmtime.def
+
+@page
+@include time/lcltime.def
+
+@page
+@include time/mktime.def
+
+@page
+@include time/strftime.def
+
+@page
+@include time/time.def
+
+@page
+@include time/tzlock.def
+
+@page
+@include time/tzset.def
Index: wcsftime.c
===================================================================
--- wcsftime.c (nonexistent)
+++ wcsftime.c (revision 345)
@@ -0,0 +1,68 @@
+/*
+ * wcsftime.c
+ * Original Author: Craig Howland, for Newlib
+ *
+ * Source actually uses strftime.c.
+ * Documentation for wcsftime() here, with minimal overlap.
+ */
+
+/*
+FUNCTION
+<>--convert date and time to a formatted wide-character string
+
+INDEX
+ wcsftime
+
+ANSI_SYNOPSIS
+ #include
+ #include
+ size_t wcsftime(wchar_t *<[s]>, size_t <[maxsize]>,
+ const wchar_t *<[format]>, const struct tm *<[timp]>);
+
+DESCRIPTION
+<> is equivalent to <>, except that:
+
+O+
+o The argument s points to the initial element of an array of wide characters
+into which the generated output is to be placed.
+
+o The argument maxsize indicates the limiting number of wide characters.
+
+o The argument format is a wide-character string and the conversion specifiers
+are replaced by corresponding sequences of wide characters.
+
+o The return value indicates the number of wide characters.
+O-
+(The difference in all of the above being wide characters versus regular
+characters.)
+
+See <> 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 <>, but do not specify the contents of
+<<*<[s]>>> when the formatted string would require more than
+<[maxsize]> characters. Unrecognized specifiers and fields of
+<> 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 <> being NULL, nor overlapping
+<> and <>.
+
+<> requires no supporting OS subroutines.
+
+SEEALSO
+<>
+*/
+
+#include
+#include
+#define MAKE_WCSFTIME
+#include "../time/strftime.c"
wcsftime.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: ctime_r.c
===================================================================
--- ctime_r.c (nonexistent)
+++ ctime_r.c (revision 345)
@@ -0,0 +1,15 @@
+/*
+ * ctime_r.c
+ */
+
+#include
+
+char *
+_DEFUN (ctime_r, (tim_p, result),
+ _CONST time_t * tim_p _AND
+ char * result)
+
+{
+ struct tm tm;
+ return asctime_r (localtime_r (tim_p, &tm), result);
+}
ctime_r.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: gmtime.c
===================================================================
--- gmtime.c (nonexistent)
+++ gmtime.c (revision 345)
@@ -0,0 +1,68 @@
+/*
+ * gmtime.c
+ * Original Author: G. Haley
+ *
+ * Converts the calendar time pointed to by tim_p into a broken-down time
+ * expressed as Greenwich Mean Time (GMT). Returns a pointer to a structure
+ * containing the broken-down time, or a null pointer if GMT is not
+ * available.
+ */
+
+/*
+FUNCTION
+<>---convert time to UTC traditional form
+
+INDEX
+ gmtime
+INDEX
+ gmtime_r
+
+ANSI_SYNOPSIS
+ #include
+ struct tm *gmtime(const time_t *<[clock]>);
+ struct tm *gmtime_r(const time_t *<[clock]>, struct tm *<[res]>);
+
+TRAD_SYNOPSIS
+ #include
+ struct tm *gmtime(<[clock]>)
+ const time_t *<[clock]>;
+ struct tm *gmtime_r(<[clock]>, <[res]>)
+ const time_t *<[clock]>;
+ struct tm *<[res]>;
+
+DESCRIPTION
+<> takes the time at <[clock]> representing the number
+of elapsed seconds since 00:00:00 on January 1, 1970, Universal
+Coordinated Time (UTC, also known in some countries as GMT,
+Greenwich Mean time) and converts it to a <>
+representation.
+
+<> constructs the traditional time representation in static
+storage; each call to <> or <> will overwrite the
+information generated by previous calls to either function.
+
+RETURNS
+A pointer to the traditional time representation (<>).
+
+PORTABILITY
+ANSI C requires <>.
+
+<> requires no supporting OS subroutines.
+*/
+
+#include
+#include
+
+#define _GMT_OFFSET 0
+
+#ifndef _REENT_ONLY
+
+struct tm *
+_DEFUN (gmtime, (tim_p),
+ _CONST time_t * tim_p)
+{
+ _REENT_CHECK_TM(_REENT);
+ return gmtime_r (tim_p, (struct tm *)_REENT_TM(_REENT));
+}
+
+#endif
gmtime.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: asctime.c
===================================================================
--- asctime.c (nonexistent)
+++ asctime.c (revision 345)
@@ -0,0 +1,64 @@
+/*
+ * asctime.c
+ * Original Author: G. Haley
+ *
+ * Converts the broken down time in the structure pointed to by tim_p into a
+ * string of the form
+ *
+ * Wed Jun 15 11:38:07 1988\n\0
+ *
+ * Returns a pointer to the string.
+ */
+
+/*
+FUNCTION
+<>---format time as string
+
+INDEX
+ asctime
+INDEX
+ _asctime_r
+
+ANSI_SYNOPSIS
+ #include
+ char *asctime(const struct tm *<[clock]>);
+ char *_asctime_r(const struct tm *<[clock]>, char *<[buf]>);
+
+TRAD_SYNOPSIS
+ #include
+ char *asctime(<[clock]>)
+ struct tm *<[clock]>;
+ char *asctime_r(<[clock]>)
+ struct tm *<[clock]>;
+ char *<[buf]>;
+
+DESCRIPTION
+Format the time value at <[clock]> into a string of the form
+. Wed Jun 15 11:38:07 1988\n\0
+The string is generated in a static buffer; each call to <>
+overwrites the string generated by previous calls.
+
+RETURNS
+A pointer to the string containing a formatted timestamp.
+
+PORTABILITY
+ANSI C requires <>.
+
+<> requires no supporting OS subroutines.
+*/
+
+#include
+#include <_ansi.h>
+#include
+
+#ifndef _REENT_ONLY
+
+char *
+_DEFUN (asctime, (tim_p),
+ _CONST struct tm *tim_p)
+{
+ _REENT_CHECK_ASCTIME_BUF(_REENT);
+ return asctime_r (tim_p, _REENT_ASCTIME_BUF(_REENT));
+}
+
+#endif
asctime.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: mktime.c
===================================================================
--- mktime.c (nonexistent)
+++ mktime.c (revision 345)
@@ -0,0 +1,264 @@
+/*
+ * mktime.c
+ * Original Author: G. Haley
+ *
+ * Converts the broken-down time, expressed as local time, in the structure
+ * pointed to by tim_p into a calendar time value. The original values of the
+ * tm_wday and tm_yday fields of the structure are ignored, and the original
+ * values of the other fields have no restrictions. On successful completion
+ * the fields of the structure are set to represent the specified calendar
+ * time. Returns the specified calendar time. If the calendar time can not be
+ * represented, returns the value (time_t) -1.
+ *
+ * Modifications: Fixed tm_isdst usage - 27 August 2008 Craig Howland.
+ */
+
+/*
+FUNCTION
+<>---convert time to arithmetic representation
+
+INDEX
+ mktime
+
+ANSI_SYNOPSIS
+ #include
+ time_t mktime(struct tm *<[timp]>);
+
+TRAD_SYNOPSIS
+ #include
+ time_t mktime(<[timp]>)
+ struct tm *<[timp]>;
+
+DESCRIPTION
+<> assumes the time at <[timp]> is a local time, and converts
+its representation from the traditional representation defined by
+<> into a representation suitable for arithmetic.
+
+<> is the inverse of <>.
+
+RETURNS
+If the contents of the structure at <[timp]> do not form a valid
+calendar time representation, the result is <<-1>>. Otherwise, the
+result is the time, converted to a <> value.
+
+PORTABILITY
+ANSI C requires <>.
+
+<> requires no supporting OS subroutines.
+*/
+
+#include
+#include
+#include "local.h"
+
+#define _SEC_IN_MINUTE 60L
+#define _SEC_IN_HOUR 3600L
+#define _SEC_IN_DAY 86400L
+
+static _CONST int DAYS_IN_MONTH[12] =
+{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
+
+#define _DAYS_IN_MONTH(x) ((x == 1) ? days_in_feb : DAYS_IN_MONTH[x])
+
+static _CONST int _DAYS_BEFORE_MONTH[12] =
+{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
+
+#define _ISLEAP(y) (((y) % 4) == 0 && (((y) % 100) != 0 || (((y)+1900) % 400) == 0))
+#define _DAYS_IN_YEAR(year) (_ISLEAP(year) ? 366 : 365)
+
+static void
+_DEFUN(validate_structure, (tim_p),
+ struct tm *tim_p)
+{
+ div_t res;
+ int days_in_feb = 28;
+
+ /* calculate time & date to account for out of range values */
+ if (tim_p->tm_sec < 0 || tim_p->tm_sec > 59)
+ {
+ res = div (tim_p->tm_sec, 60);
+ tim_p->tm_min += res.quot;
+ if ((tim_p->tm_sec = res.rem) < 0)
+ {
+ tim_p->tm_sec += 60;
+ --tim_p->tm_min;
+ }
+ }
+
+ if (tim_p->tm_min < 0 || tim_p->tm_min > 59)
+ {
+ res = div (tim_p->tm_min, 60);
+ tim_p->tm_hour += res.quot;
+ if ((tim_p->tm_min = res.rem) < 0)
+ {
+ tim_p->tm_min += 60;
+ --tim_p->tm_hour;
+ }
+ }
+
+ if (tim_p->tm_hour < 0 || tim_p->tm_hour > 23)
+ {
+ res = div (tim_p->tm_hour, 24);
+ tim_p->tm_mday += res.quot;
+ if ((tim_p->tm_hour = res.rem) < 0)
+ {
+ tim_p->tm_hour += 24;
+ --tim_p->tm_mday;
+ }
+ }
+
+ if (tim_p->tm_mon > 11)
+ {
+ res = div (tim_p->tm_mon, 12);
+ tim_p->tm_year += res.quot;
+ if ((tim_p->tm_mon = res.rem) < 0)
+ {
+ tim_p->tm_mon += 12;
+ --tim_p->tm_year;
+ }
+ }
+
+ if (_DAYS_IN_YEAR (tim_p->tm_year) == 366)
+ days_in_feb = 29;
+
+ if (tim_p->tm_mday <= 0)
+ {
+ while (tim_p->tm_mday <= 0)
+ {
+ if (--tim_p->tm_mon == -1)
+ {
+ tim_p->tm_year--;
+ tim_p->tm_mon = 11;
+ days_in_feb =
+ ((_DAYS_IN_YEAR (tim_p->tm_year) == 366) ?
+ 29 : 28);
+ }
+ tim_p->tm_mday += _DAYS_IN_MONTH (tim_p->tm_mon);
+ }
+ }
+ else
+ {
+ while (tim_p->tm_mday > _DAYS_IN_MONTH (tim_p->tm_mon))
+ {
+ tim_p->tm_mday -= _DAYS_IN_MONTH (tim_p->tm_mon);
+ if (++tim_p->tm_mon == 12)
+ {
+ tim_p->tm_year++;
+ tim_p->tm_mon = 0;
+ days_in_feb =
+ ((_DAYS_IN_YEAR (tim_p->tm_year) == 366) ?
+ 29 : 28);
+ }
+ }
+ }
+}
+
+time_t
+_DEFUN(mktime, (tim_p),
+ struct tm *tim_p)
+{
+ time_t tim = 0;
+ long days = 0;
+ int year, isdst, tm_isdst;
+ __tzinfo_type *tz = __gettzinfo ();
+
+ /* validate structure */
+ validate_structure (tim_p);
+
+ /* compute hours, minutes, seconds */
+ tim += tim_p->tm_sec + (tim_p->tm_min * _SEC_IN_MINUTE) +
+ (tim_p->tm_hour * _SEC_IN_HOUR);
+
+ /* compute days in year */
+ days += tim_p->tm_mday - 1;
+ days += _DAYS_BEFORE_MONTH[tim_p->tm_mon];
+ if (tim_p->tm_mon > 1 && _DAYS_IN_YEAR (tim_p->tm_year) == 366)
+ days++;
+
+ /* compute day of the year */
+ tim_p->tm_yday = days;
+
+ if (tim_p->tm_year > 10000
+ || tim_p->tm_year < -10000)
+ {
+ return (time_t) -1;
+ }
+
+ /* compute days in other years */
+ if (tim_p->tm_year > 70)
+ {
+ for (year = 70; year < tim_p->tm_year; year++)
+ days += _DAYS_IN_YEAR (year);
+ }
+ else if (tim_p->tm_year < 70)
+ {
+ for (year = 69; year > tim_p->tm_year; year--)
+ days -= _DAYS_IN_YEAR (year);
+ days -= _DAYS_IN_YEAR (year);
+ }
+
+ /* compute day of the week */
+ if ((tim_p->tm_wday = (days + 4) % 7) < 0)
+ tim_p->tm_wday += 7;
+
+ /* compute total seconds */
+ tim += (days * _SEC_IN_DAY);
+
+ /* Convert user positive into 1 */
+ tm_isdst = tim_p->tm_isdst > 0 ? 1 : tim_p->tm_isdst;
+ isdst = tm_isdst;
+
+ if (_daylight)
+ {
+ int y = tim_p->tm_year + YEAR_BASE;
+ if (y == tz->__tzyear || __tzcalc_limits (y))
+ {
+ /* calculate start of dst in dst local time and
+ start of std in both std local time and dst local time */
+ time_t startdst_dst = tz->__tzrule[0].change
+ - (time_t) tz->__tzrule[1].offset;
+ time_t startstd_dst = tz->__tzrule[1].change
+ - (time_t) tz->__tzrule[1].offset;
+ time_t startstd_std = tz->__tzrule[1].change
+ - (time_t) tz->__tzrule[0].offset;
+ /* if the time is in the overlap between dst and std local times */
+ if (tim >= startstd_std && tim < startstd_dst)
+ ; /* we let user decide or leave as -1 */
+ else
+ {
+ isdst = (tz->__tznorth
+ ? (tim >= startdst_dst && tim < startstd_std)
+ : (tim >= startdst_dst || tim < startstd_std));
+ /* if user committed and was wrong, perform correction, but not
+ * if the user has given a negative value (which
+ * asks mktime() to determine if DST is in effect or not) */
+ if (tm_isdst >= 0 && (isdst ^ tm_isdst) == 1)
+ {
+ /* we either subtract or add the difference between
+ time zone offsets, depending on which way the user got it
+ wrong. The diff is typically one hour, or 3600 seconds,
+ and should fit in a 16-bit int, even though offset
+ is a long to accomodate 12 hours. */
+ int diff = (int) (tz->__tzrule[0].offset
+ - tz->__tzrule[1].offset);
+ if (!isdst)
+ diff = -diff;
+ tim_p->tm_sec += diff;
+ validate_structure (tim_p);
+ tim += diff; /* we also need to correct our current time calculation */
+ }
+ }
+ }
+ }
+
+ /* add appropriate offset to put time in gmt format */
+ if (isdst == 1)
+ tim += (time_t) tz->__tzrule[1].offset;
+ else /* otherwise assume std time */
+ tim += (time_t) tz->__tzrule[0].offset;
+
+ /* reset isdst flag to what we have calculated */
+ tim_p->tm_isdst = isdst;
+
+ return tim;
+}
mktime.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: difftime.c
===================================================================
--- difftime.c (nonexistent)
+++ difftime.c (revision 345)
@@ -0,0 +1,44 @@
+/*
+ * difftime.c
+ * Original Author: G. Haley
+ */
+
+/*
+FUNCTION
+<>---subtract two times
+
+INDEX
+ difftime
+
+ANSI_SYNOPSIS
+ #include
+ double difftime(time_t <[tim1]>, time_t <[tim2]>);
+
+TRAD_SYNOPSIS
+ #include
+ double difftime(<[tim1]>, <[tim2]>)
+ time_t <[tim1]>;
+ time_t <[tim2]>;
+
+DESCRIPTION
+Subtracts the two times in the arguments: `<<<[tim1]> - <[tim2]>>>'.
+
+RETURNS
+The difference (in seconds) between <[tim2]> and <[tim1]>, as a <>.
+
+PORTABILITY
+ANSI C requires <>, and defines its result to be in seconds
+in all implementations.
+
+<> requires no supporting OS subroutines.
+*/
+
+#include
+
+double
+_DEFUN (difftime, (tim1, tim2),
+ time_t tim1 _AND
+ time_t tim2)
+{
+ return (double)(tim1 - tim2);
+}
difftime.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: Makefile.am
===================================================================
--- Makefile.am (nonexistent)
+++ Makefile.am (revision 345)
@@ -0,0 +1,75 @@
+## Process this file with automake to generate Makefile.in
+
+AUTOMAKE_OPTIONS = cygnus
+
+INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
+
+LIB_SOURCES = \
+ asctime.c \
+ asctime_r.c \
+ clock.c \
+ ctime.c \
+ ctime_r.c \
+ difftime.c \
+ gettzinfo.c \
+ gmtime.c \
+ gmtime_r.c \
+ lcltime.c \
+ lcltime_r.c \
+ mktime.c \
+ mktm_r.c \
+ strftime.c \
+ strptime.c \
+ time.c \
+ tzlock.c \
+ tzset.c \
+ tzset_r.c \
+ tzvars.c \
+ wcsftime.c
+
+libtime_la_LDFLAGS = -Xcompiler -nostdlib
+
+if USE_LIBTOOL
+noinst_LTLIBRARIES = libtime.la
+libtime_la_SOURCES = $(LIB_SOURCES)
+noinst_DATA = objectlist.awk.in
+else
+noinst_LIBRARIES = lib.a
+lib_a_SOURCES = $(LIB_SOURCES)
+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 \
+ ctime.def \
+ difftime.def \
+ gmtime.def \
+ lcltime.def \
+ mktime.def \
+ strftime.def \
+ time.def \
+ tzlock.def \
+ tzset.def \
+ wcsftime.def
+
+SUFFIXES = .def
+
+CHEW = ../../doc/makedoc -f $(srcdir)/../../doc/doc.str
+
+.c.def:
+ $(CHEW) < $< > $*.def 2> $*.ref
+ touch stmp-def
+
+TARGETDOC = ../tmp.texi
+
+doc: $(CHEWOUT_FILES)
+ cat $(srcdir)/time.tex >> $(TARGETDOC)
+
+CLEANFILES = $(CHEWOUT_FILES) *.ref
Makefile.am
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: mktm_r.c
===================================================================
--- mktm_r.c (nonexistent)
+++ mktm_r.c (revision 345)
@@ -0,0 +1,257 @@
+/*
+ * mktm_r.c
+ * Original Author: Adapted from tzcode maintained by Arthur David Olson.
+ * Modifications: Changed to mktm_r and added __tzcalc_limits - 04/10/02, Jeff Johnston
+ * Fixed bug in mday computations - 08/12/04, Alex Mogilnikov
+ * Fixed bug in __tzcalc_limits - 08/12/04, Alex Mogilnikov
+ *
+ * Converts the calendar time pointed to by tim_p into a broken-down time
+ * expressed as local time. Returns a pointer to a structure containing the
+ * broken-down time.
+ */
+
+#include
+#include
+#include "local.h"
+
+static _CONST int mon_lengths[2][MONSPERYEAR] = {
+ {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
+ {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
+} ;
+
+static _CONST int year_lengths[2] = {
+ 365,
+ 366
+} ;
+
+struct tm *
+_DEFUN (_mktm_r, (tim_p, res, is_gmtime),
+ _CONST time_t * tim_p _AND
+ struct tm *res _AND
+ int is_gmtime)
+{
+ long days, rem;
+ time_t lcltime;
+ int y;
+ int yleap;
+ _CONST int *ip;
+ __tzinfo_type *tz = __gettzinfo ();
+
+ /* base decision about std/dst time on current time */
+ lcltime = *tim_p;
+
+ days = ((long)lcltime) / SECSPERDAY;
+ rem = ((long)lcltime) % SECSPERDAY;
+ while (rem < 0)
+ {
+ rem += SECSPERDAY;
+ --days;
+ }
+ while (rem >= SECSPERDAY)
+ {
+ rem -= SECSPERDAY;
+ ++days;
+ }
+
+ /* compute hour, min, and sec */
+ res->tm_hour = (int) (rem / SECSPERHOUR);
+ rem %= SECSPERHOUR;
+ res->tm_min = (int) (rem / SECSPERMIN);
+ res->tm_sec = (int) (rem % SECSPERMIN);
+
+ /* compute day of week */
+ if ((res->tm_wday = ((EPOCH_WDAY + days) % DAYSPERWEEK)) < 0)
+ res->tm_wday += DAYSPERWEEK;
+
+ /* compute year & day of year */
+ y = EPOCH_YEAR;
+ if (days >= 0)
+ {
+ for (;;)
+ {
+ yleap = isleap(y);
+ if (days < year_lengths[yleap])
+ break;
+ y++;
+ days -= year_lengths[yleap];
+ }
+ }
+ else
+ {
+ do
+ {
+ --y;
+ yleap = isleap(y);
+ days += year_lengths[yleap];
+ } while (days < 0);
+ }
+
+ res->tm_year = y - YEAR_BASE;
+ res->tm_yday = days;
+ ip = mon_lengths[yleap];
+ for (res->tm_mon = 0; days >= ip[res->tm_mon]; ++res->tm_mon)
+ days -= ip[res->tm_mon];
+ res->tm_mday = days + 1;
+
+ if (!is_gmtime)
+ {
+ long offset;
+ int hours, mins, secs;
+
+ TZ_LOCK;
+ if (_daylight)
+ {
+ if (y == tz->__tzyear || __tzcalc_limits (y))
+ res->tm_isdst = (tz->__tznorth
+ ? (*tim_p >= tz->__tzrule[0].change
+ && *tim_p < tz->__tzrule[1].change)
+ : (*tim_p >= tz->__tzrule[0].change
+ || *tim_p < tz->__tzrule[1].change));
+ else
+ res->tm_isdst = -1;
+ }
+ else
+ res->tm_isdst = 0;
+
+ offset = (res->tm_isdst == 1
+ ? tz->__tzrule[1].offset
+ : tz->__tzrule[0].offset);
+
+ hours = (int) (offset / SECSPERHOUR);
+ offset = offset % SECSPERHOUR;
+
+ mins = (int) (offset / SECSPERMIN);
+ secs = (int) (offset % SECSPERMIN);
+
+ res->tm_sec -= secs;
+ res->tm_min -= mins;
+ res->tm_hour -= hours;
+
+ if (res->tm_sec >= SECSPERMIN)
+ {
+ res->tm_min += 1;
+ res->tm_sec -= SECSPERMIN;
+ }
+ else if (res->tm_sec < 0)
+ {
+ res->tm_min -= 1;
+ res->tm_sec += SECSPERMIN;
+ }
+ if (res->tm_min >= MINSPERHOUR)
+ {
+ res->tm_hour += 1;
+ res->tm_min -= MINSPERHOUR;
+ }
+ else if (res->tm_min < 0)
+ {
+ res->tm_hour -= 1;
+ res->tm_min += MINSPERHOUR;
+ }
+ if (res->tm_hour >= HOURSPERDAY)
+ {
+ ++res->tm_yday;
+ ++res->tm_wday;
+ if (res->tm_wday > 6)
+ res->tm_wday = 0;
+ ++res->tm_mday;
+ res->tm_hour -= HOURSPERDAY;
+ if (res->tm_mday > ip[res->tm_mon])
+ {
+ res->tm_mday -= ip[res->tm_mon];
+ res->tm_mon += 1;
+ if (res->tm_mon == 12)
+ {
+ res->tm_mon = 0;
+ res->tm_year += 1;
+ res->tm_yday = 0;
+ }
+ }
+ }
+ else if (res->tm_hour < 0)
+ {
+ res->tm_yday -= 1;
+ res->tm_wday -= 1;
+ if (res->tm_wday < 0)
+ res->tm_wday = 6;
+ res->tm_mday -= 1;
+ res->tm_hour += 24;
+ if (res->tm_mday == 0)
+ {
+ res->tm_mon -= 1;
+ if (res->tm_mon < 0)
+ {
+ res->tm_mon = 11;
+ res->tm_year -= 1;
+ res->tm_yday = 365 + isleap(res->tm_year);
+ }
+ res->tm_mday = ip[res->tm_mon];
+ }
+ }
+ TZ_UNLOCK;
+ }
+ else
+ res->tm_isdst = 0;
+
+ return (res);
+}
+
+int
+_DEFUN (__tzcalc_limits, (year),
+ int year)
+{
+ int days, year_days, years;
+ int i, j;
+ __tzinfo_type *tz = __gettzinfo ();
+
+ if (year < EPOCH_YEAR)
+ return 0;
+
+ tz->__tzyear = year;
+
+ years = (year - EPOCH_YEAR);
+
+ year_days = years * 365 +
+ (years - 1 + EPOCH_YEARS_SINCE_LEAP) / 4 - (years - 1 + EPOCH_YEARS_SINCE_CENTURY) / 100 +
+ (years - 1 + EPOCH_YEARS_SINCE_LEAP_CENTURY) / 400;
+
+ for (i = 0; i < 2; ++i)
+ {
+ if (tz->__tzrule[i].ch == 'J')
+ days = year_days + tz->__tzrule[i].d +
+ (isleap(year) && tz->__tzrule[i].d >= 60);
+ else if (tz->__tzrule[i].ch == 'D')
+ days = year_days + tz->__tzrule[i].d;
+ else
+ {
+ int yleap = isleap(year);
+ int m_day, m_wday, wday_diff;
+ _CONST int *ip = mon_lengths[yleap];
+
+ days = year_days;
+
+ for (j = 1; j < tz->__tzrule[i].m; ++j)
+ days += ip[j-1];
+
+ m_wday = (EPOCH_WDAY + days) % DAYSPERWEEK;
+
+ wday_diff = tz->__tzrule[i].d - m_wday;
+ if (wday_diff < 0)
+ wday_diff += DAYSPERWEEK;
+ m_day = (tz->__tzrule[i].n - 1) * DAYSPERWEEK + wday_diff;
+
+ while (m_day >= ip[j-1])
+ m_day -= DAYSPERWEEK;
+
+ days += m_day;
+ }
+
+ /* store the change-over time in GMT form by adding offset */
+ tz->__tzrule[i].change = days * SECSPERDAY +
+ tz->__tzrule[i].s + tz->__tzrule[i].offset;
+ }
+
+ tz->__tznorth = (tz->__tzrule[0].change < tz->__tzrule[1].change);
+
+ return 1;
+}
+
mktm_r.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: lcltime.c
===================================================================
--- lcltime.c (nonexistent)
+++ lcltime.c (revision 345)
@@ -0,0 +1,60 @@
+/*
+ * localtime.c
+ */
+
+/*
+FUNCTION
+<>---convert time to local representation
+
+INDEX
+ localtime
+INDEX
+ localtime_r
+
+ANSI_SYNOPSIS
+ #include
+ struct tm *localtime(time_t *<[clock]>);
+ struct tm *localtime_r(time_t *<[clock]>, struct tm *<[res]>);
+
+TRAD_SYNOPSIS
+ #include
+ struct tm *localtime(<[clock]>)
+ time_t *<[clock]>;
+ struct tm *localtime(<[clock]>, <[res]>)
+ time_t *<[clock]>;
+ struct tm *<[res]>;
+
+DESCRIPTION
+<> converts the time at <[clock]> into local time, then
+converts its representation from the arithmetic representation to the
+traditional representation defined by <>.
+
+<> constructs the traditional time representation in static
+storage; each call to <> or <> will overwrite the
+information generated by previous calls to either function.
+
+<> is the inverse of <>.
+
+RETURNS
+A pointer to the traditional time representation (<>).
+
+PORTABILITY
+ANSI C requires <>.
+
+<> requires no supporting OS subroutines.
+*/
+
+#include
+#include
+
+#ifndef _REENT_ONLY
+
+struct tm *
+_DEFUN (localtime, (tim_p),
+ _CONST time_t * tim_p)
+{
+ _REENT_CHECK_TM(_REENT);
+ return localtime_r (tim_p, (struct tm *)_REENT_TM(_REENT));
+}
+
+#endif
lcltime.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: tzvars.c
===================================================================
--- tzvars.c (nonexistent)
+++ tzvars.c (revision 345)
@@ -0,0 +1,10 @@
+#include
+
+/* Global timezone variables. */
+
+/* Default timezone to GMT */
+char *_tzname[2] = {"GMT", "GMT"};
+int _daylight = 0;
+long _timezone = 0;
+
+
tzvars.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: tzset_r.c
===================================================================
--- tzset_r.c (nonexistent)
+++ tzset_r.c (revision 345)
@@ -0,0 +1,197 @@
+#include <_ansi.h>
+#include
+#include
+#include
+#include
+#include
+#include
+#include "local.h"
+
+static char __tzname_std[11];
+static char __tzname_dst[11];
+static char *prev_tzenv = NULL;
+
+_VOID
+_DEFUN (_tzset_r, (reent_ptr),
+ struct _reent *reent_ptr)
+{
+ char *tzenv;
+ unsigned short hh, mm, ss, m, w, d;
+ int sign, n;
+ int i, ch;
+ __tzinfo_type *tz = __gettzinfo ();
+
+ if ((tzenv = _getenv_r (reent_ptr, "TZ")) == NULL)
+ {
+ TZ_LOCK;
+ _timezone = 0;
+ _daylight = 0;
+ _tzname[0] = "GMT";
+ _tzname[1] = "GMT";
+ TZ_UNLOCK;
+ return;
+ }
+
+ TZ_LOCK;
+
+ if (prev_tzenv != NULL && strcmp(tzenv, prev_tzenv) == 0)
+ {
+ TZ_UNLOCK;
+ return;
+ }
+
+ free(prev_tzenv);
+ prev_tzenv = _malloc_r (reent_ptr, strlen(tzenv) + 1);
+ if (prev_tzenv != NULL)
+ strcpy (prev_tzenv, tzenv);
+
+ /* ignore implementation-specific format specifier */
+ if (*tzenv == ':')
+ ++tzenv;
+
+ if (sscanf (tzenv, "%10[^0-9,+-]%n", __tzname_std, &n) <= 0)
+ {
+ TZ_UNLOCK;
+ return;
+ }
+
+ tzenv += n;
+
+ sign = 1;
+ if (*tzenv == '-')
+ {
+ sign = -1;
+ ++tzenv;
+ }
+ else if (*tzenv == '+')
+ ++tzenv;
+
+ mm = 0;
+ ss = 0;
+
+ if (sscanf (tzenv, "%hu%n:%hu%n:%hu%n", &hh, &n, &mm, &n, &ss, &n) < 1)
+ {
+ TZ_UNLOCK;
+ return;
+ }
+
+ tz->__tzrule[0].offset = sign * (ss + SECSPERMIN * mm + SECSPERHOUR * hh);
+ _tzname[0] = __tzname_std;
+ tzenv += n;
+
+ if (sscanf (tzenv, "%10[^0-9,+-]%n", __tzname_dst, &n) <= 0)
+ {
+ _tzname[1] = _tzname[0];
+ TZ_UNLOCK;
+ return;
+ }
+ else
+ _tzname[1] = __tzname_dst;
+
+ tzenv += n;
+
+ /* otherwise we have a dst name, look for the offset */
+ sign = 1;
+ if (*tzenv == '-')
+ {
+ sign = -1;
+ ++tzenv;
+ }
+ else if (*tzenv == '+')
+ ++tzenv;
+
+ hh = 0;
+ mm = 0;
+ ss = 0;
+
+ n = 0;
+ if (sscanf (tzenv, "%hu%n:%hu%n:%hu%n", &hh, &n, &mm, &n, &ss, &n) <= 0)
+ tz->__tzrule[1].offset = tz->__tzrule[0].offset - 3600;
+ else
+ tz->__tzrule[1].offset = sign * (ss + SECSPERMIN * mm + SECSPERHOUR * hh);
+
+ tzenv += n;
+
+ for (i = 0; i < 2; ++i)
+ {
+ if (*tzenv == ',')
+ ++tzenv;
+
+ if (*tzenv == 'M')
+ {
+ if (sscanf (tzenv, "M%hu%n.%hu%n.%hu%n", &m, &n, &w, &n, &d, &n) != 3 ||
+ m < 1 || m > 12 || w < 1 || w > 5 || d > 6)
+ {
+ TZ_UNLOCK;
+ return;
+ }
+
+ tz->__tzrule[i].ch = 'M';
+ tz->__tzrule[i].m = m;
+ tz->__tzrule[i].n = w;
+ tz->__tzrule[i].d = d;
+
+ tzenv += n;
+ }
+ else
+ {
+ char *end;
+ if (*tzenv == 'J')
+ {
+ ch = 'J';
+ ++tzenv;
+ }
+ else
+ ch = 'D';
+
+ d = strtoul (tzenv, &end, 10);
+
+ /* if unspecified, default to US settings */
+ /* From 1987-2006, US was M4.1.0,M10.5.0, but starting in 2007 is
+ * M3.2.0,M11.1.0 (2nd Sunday March through 1st Sunday November) */
+ if (end == tzenv)
+ {
+ if (i == 0)
+ {
+ tz->__tzrule[0].ch = 'M';
+ tz->__tzrule[0].m = 3;
+ tz->__tzrule[0].n = 2;
+ tz->__tzrule[0].d = 0;
+ }
+ else
+ {
+ tz->__tzrule[1].ch = 'M';
+ tz->__tzrule[1].m = 11;
+ tz->__tzrule[1].n = 1;
+ tz->__tzrule[1].d = 0;
+ }
+ }
+ else
+ {
+ tz->__tzrule[i].ch = ch;
+ tz->__tzrule[i].d = d;
+ }
+
+ tzenv = end;
+ }
+
+ /* default time is 02:00:00 am */
+ hh = 2;
+ mm = 0;
+ ss = 0;
+ n = 0;
+
+ if (*tzenv == '/')
+ sscanf (tzenv, "/%hu%n:%hu%n:%hu%n", &hh, &n, &mm, &n, &ss, &n);
+
+ tz->__tzrule[i].s = ss + SECSPERMIN * mm + SECSPERHOUR * hh;
+
+ tzenv += n;
+ }
+
+ __tzcalc_limits (tz->__tzyear);
+ _timezone = tz->__tzrule[0].offset;
+ _daylight = tz->__tzrule[0].offset != tz->__tzrule[1].offset;
+
+ TZ_UNLOCK;
+}
tzset_r.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: clock.c
===================================================================
--- clock.c (nonexistent)
+++ clock.c (revision 345)
@@ -0,0 +1,69 @@
+/* NetWare can not use this implementation of clock, since it does not
+ have times or any similar function. It provides its own version of
+ clock in clib.nlm. If we can not use clib.nlm, then we must write
+ clock in sys/netware. */
+
+#ifdef CLOCK_PROVIDED
+
+int _dummy_clock = 1;
+
+#else
+
+/*
+ * clock.c
+ * Original Author: G. Haley
+ *
+ * Determines the processor time used by the program since invocation. The time
+ * in seconds is the value returned divided by the value of the macro CLK_TCK.
+ * If the processor time used is not available, (clock_t) -1 is returned.
+ */
+
+/*
+FUNCTION
+<>---cumulative processor time
+
+INDEX
+ clock
+
+ANSI_SYNOPSIS
+ #include
+ clock_t clock(void);
+
+TRAD_SYNOPSIS
+ #include
+ clock_t clock();
+
+DESCRIPTION
+Calculates the best available approximation of the cumulative amount
+of time used by your program since it started. To convert the result
+into seconds, divide by the macro <>.
+
+RETURNS
+The amount of processor time used so far by your program, in units
+defined by the machine-dependent macro <>. If no
+measurement is available, the result is (clock_t)<<-1>>.
+
+PORTABILITY
+ANSI C requires <> and <>.
+
+Supporting OS subroutine required: <>.
+*/
+
+#include
+#include
+#include
+
+clock_t
+clock ()
+{
+ struct tms tim_s;
+ clock_t res;
+
+ if ((res = (clock_t) _times_r (_REENT, &tim_s)) != -1)
+ res = (clock_t) (tim_s.tms_utime + tim_s.tms_stime +
+ tim_s.tms_cutime + tim_s.tms_cstime);
+
+ return res;
+}
+
+#endif /* CLOCK_PROVIDED */
clock.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: strftime.c
===================================================================
--- strftime.c (nonexistent)
+++ strftime.c (revision 345)
@@ -0,0 +1,1218 @@
+/* NOTE: This file defines both strftime() and wcsftime(). Take care when
+ * making changes. See also wcsftime.c, and note the (small) overlap in the
+ * manual description, taking care to edit both as needed. */
+/*
+ * strftime.c
+ * Original Author: G. Haley
+ * Additions from: Eric Blake
+ * Changes to allow dual use as wcstime, also: Craig Howland
+ *
+ * Places characters into the array pointed to by s as controlled by the string
+ * pointed to by format. If the total number of resulting characters including
+ * the terminating null character is not more than maxsize, returns the number
+ * of characters placed into the array pointed to by s (not including the
+ * terminating null character); otherwise zero is returned and the contents of
+ * the array indeterminate.
+ */
+
+/*
+FUNCTION
+<>---convert date and time to a formatted string
+
+INDEX
+ strftime
+
+ANSI_SYNOPSIS
+ #include
+ size_t strftime(char *<[s]>, size_t <[maxsize]>,
+ const char *<[format]>, const struct tm *<[timp]>);
+
+TRAD_SYNOPSIS
+ #include
+ size_t strftime(<[s]>, <[maxsize]>, <[format]>, <[timp]>)
+ char *<[s]>;
+ size_t <[maxsize]>;
+ char *<[format]>;
+ struct tm *<[timp]>;
+
+DESCRIPTION
+<> converts a <> representation of the time (at
+<[timp]>) into a null-terminated string, starting at <[s]> and occupying
+no more than <[maxsize]> characters.
+
+You control the format of the output using the string at <[format]>.
+<<*<[format]>>> can contain two kinds of specifications: text to be
+copied literally into the formatted string, and time conversion
+specifications. Time conversion specifications are two- and
+three-character sequences beginning with `<<%>>' (use `<<%%>>' to
+include a percent sign in the output). Each defined conversion
+specification selects only the specified field(s) of calendar time
+data from <<*<[timp]>>>, and converts it to a string in one of the
+following ways:
+
+o+
+o %a
+A three-letter abbreviation for the day of the week. [tm_wday]
+
+o %A
+The full name for the day of the week, one of `<>',
+`<>', `<>', `<>', `<>',
+`<>', or `<>'. [tm_wday]
+
+o %b
+A three-letter abbreviation for the month name. [tm_mon]
+
+o %B
+The full name of the month, one of `<>', `<>',
+`<>', `<>', `<>', `<>', `<>',
+`<>', `<>', `<>', `<>',
+`<>'. [tm_mon]
+
+o %c
+A string representing the complete date and time, in the form
+`<<"%a %b %e %H:%M:%S %Y">>' (example "Mon Apr 01 13:13:13
+1992"). [tm_sec, tm_min, tm_hour, tm_mday, tm_mon, tm_year, tm_wday]
+
+o %C
+The century, that is, the year divided by 100 then truncated. For
+4-digit years, the result is zero-padded and exactly two characters;
+but for other years, there may a negative sign or more digits. In
+this way, `<<%C%y>>' is equivalent to `<<%Y>>'. [tm_year]
+
+o %d
+The day of the month, formatted with two digits (from `<<01>>' to
+`<<31>>'). [tm_mday]
+
+o %D
+A string representing the date, in the form `<<"%m/%d/%y">>'.
+[tm_mday, tm_mon, tm_year]
+
+o %e
+The day of the month, formatted with leading space if single digit
+(from `<<1>>' to `<<31>>'). [tm_mday]
+
+o %E<>
+In some locales, the E modifier selects alternative representations of
+certain modifiers <>. But in the "C" locale supported by newlib,
+it is ignored, and treated as %<>.
+
+o %F
+A string representing the ISO 8601:2000 date format, in the form
+`<<"%Y-%m-%d">>'. [tm_mday, tm_mon, tm_year]
+
+o %g
+The last two digits of the week-based year, see specifier %G (from
+`<<00>>' to `<<99>>'). [tm_year, tm_wday, tm_yday]
+
+o %G
+The week-based year. In the ISO 8601:2000 calendar, week 1 of the year
+includes January 4th, and begin on Mondays. Therefore, if January 1st,
+2nd, or 3rd falls on a Sunday, that day and earlier belong to the last
+week of the previous year; and if December 29th, 30th, or 31st falls
+on Monday, that day and later belong to week 1 of the next year. For
+consistency with %Y, it always has at least four characters.
+Example: "%G" for Saturday 2nd January 1999 gives "1998", and for
+Tuesday 30th December 1997 gives "1998". [tm_year, tm_wday, tm_yday]
+
+o %h
+A three-letter abbreviation for the month name (synonym for
+"%b"). [tm_mon]
+
+o %H
+The hour (on a 24-hour clock), formatted with two digits (from
+`<<00>>' to `<<23>>'). [tm_hour]
+
+o %I
+The hour (on a 12-hour clock), formatted with two digits (from
+`<<01>>' to `<<12>>'). [tm_hour]
+
+o %j
+The count of days in the year, formatted with three digits
+(from `<<001>>' to `<<366>>'). [tm_yday]
+
+o %k
+The hour (on a 24-hour clock), formatted with leading space if single
+digit (from `<<0>>' to `<<23>>'). Non-POSIX extension (c.p. %I). [tm_hour]
+
+o %l
+The hour (on a 12-hour clock), formatted with leading space if single
+digit (from `<<1>>' to `<<12>>'). Non-POSIX extension (c.p. %H). [tm_hour]
+
+o %m
+The month number, formatted with two digits (from `<<01>>' to `<<12>>').
+[tm_mon]
+
+o %M
+The minute, formatted with two digits (from `<<00>>' to `<<59>>'). [tm_min]
+
+o %n
+A newline character (`<<\n>>').
+
+o %O<>
+In some locales, the O modifier selects alternative digit characters
+for certain modifiers <>. But in the "C" locale supported by newlib, it
+is ignored, and treated as %<>.
+
+o %p
+Either `<>' or `<>' as appropriate. [tm_hour]
+
+o %r
+The 12-hour time, to the second. Equivalent to "%I:%M:%S %p". [tm_sec,
+tm_min, tm_hour]
+
+o %R
+The 24-hour time, to the minute. Equivalent to "%H:%M". [tm_min, tm_hour]
+
+o %S
+The second, formatted with two digits (from `<<00>>' to `<<60>>'). The
+value 60 accounts for the occasional leap second. [tm_sec]
+
+o %t
+A tab character (`<<\t>>').
+
+o %T
+The 24-hour time, to the second. Equivalent to "%H:%M:%S". [tm_sec,
+tm_min, tm_hour]
+
+o %u
+The weekday as a number, 1-based from Monday (from `<<1>>' to
+`<<7>>'). [tm_wday]
+
+o %U
+The week number, where weeks start on Sunday, week 1 contains the first
+Sunday in a year, and earlier days are in week 0. Formatted with two
+digits (from `<<00>>' to `<<53>>'). See also <<%W>>. [tm_wday, tm_yday]
+
+o %V
+The week number, where weeks start on Monday, week 1 contains January 4th,
+and earlier days are in the previous year. Formatted with two digits
+(from `<<01>>' to `<<53>>'). See also <<%G>>. [tm_year, tm_wday, tm_yday]
+
+o %w
+The weekday as a number, 0-based from Sunday (from `<<0>>' to `<<6>>').
+[tm_wday]
+
+o %W
+The week number, where weeks start on Monday, week 1 contains the first
+Monday in a year, and earlier days are in week 0. Formatted with two
+digits (from `<<00>>' to `<<53>>'). [tm_wday, tm_yday]
+
+o %x
+A string representing the complete date, equivalent to "%m/%d/%y".
+[tm_mon, tm_mday, tm_year]
+
+o %X
+A string representing the full time of day (hours, minutes, and
+seconds), equivalent to "%H:%M:%S". [tm_sec, tm_min, tm_hour]
+
+o %y
+The last two digits of the year (from `<<00>>' to `<<99>>'). [tm_year]
+(Implementation interpretation: always positive, even for negative years.)
+
+o %Y
+The full year, equivalent to <<%C%y>>. It will always have at least four
+characters, but may have more. The year is accurate even when tm_year
+added to the offset of 1900 overflows an int. [tm_year]
+
+o %z
+The offset from UTC. The format consists of a sign (negative is west of
+Greewich), two characters for hour, then two characters for minutes
+(-hhmm or +hhmm). If tm_isdst is negative, the offset is unknown and no
+output is generated; if it is zero, the offset is the standard offset for
+the current time zone; and if it is positive, the offset is the daylight
+savings offset for the current timezone. The offset is determined from
+the TZ environment variable, as if by calling tzset(). [tm_isdst]
+
+o %Z
+The time zone name. If tm_isdst is negative, no output is generated.
+Otherwise, the time zone name is based on the TZ environment variable,
+as if by calling tzset(). [tm_isdst]
+
+o %%
+A single character, `<<%>>'.
+o-
+
+RETURNS
+When the formatted time takes up no more than <[maxsize]> characters,
+the result is the length of the formatted string. Otherwise, if the
+formatting operation was abandoned due to lack of room, the result is
+<<0>>, and the string starting at <[s]> corresponds to just those
+parts of <<*<[format]>>> that could be completely filled in within the
+<[maxsize]> limit.
+
+PORTABILITY
+ANSI C requires <>, but does not specify the contents of
+<<*<[s]>>> when the formatted string would require more than
+<[maxsize]> characters. Unrecognized specifiers and fields of
+<> 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 <> being NULL, nor overlapping
+<> and <>.
+
+<> requires no supporting OS subroutines.
+
+BUGS
+<> ignores the LC_TIME category of the current locale, hard-coding
+the "C" locale settings.
+*/
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include "local.h"
+
+/* Defines to make the file dual use for either strftime() or wcsftime().
+ * To get wcsftime, define MAKE_WCSFTIME.
+ * To get strftime, do not define MAKE_WCSFTIME.
+ * Names are kept friendly to strftime() usage. The biggest ugliness is the
+ * use of the CQ() macro to make either regular character constants and
+ * string literals or wide-character constants and wide-character-string
+ * literals, as appropriate. */
+#if !defined(MAKE_WCSFTIME)
+# define CHAR char /* string type basis */
+# define CQ(a) a /* character constant qualifier */
+# define SFLG /* %s flag (null for normal char) */
+# else
+# define strftime wcsftime /* Alternate function name */
+# define CHAR wchar_t /* string type basis */
+# define CQ(a) L##a /* character constant qualifier */
+# define snprintf swprintf /* wide-char equivalent function name */
+# define strncmp wcsncmp /* wide-char equivalent function name */
+# define SFLG "l" /* %s flag (l for wide char) */
+#endif /* MAKE_WCSFTIME */
+
+/* Enforce the coding assumptions that YEAR_BASE is positive. (%C, %Y, etc.) */
+#if YEAR_BASE < 0
+# error "YEAR_BASE < 0"
+#endif
+
+static _CONST int dname_len[7] =
+{6, 6, 7, 9, 8, 6, 8};
+
+static _CONST CHAR *_CONST dname[7] =
+{CQ("Sunday"), CQ("Monday"), CQ("Tuesday"), CQ("Wednesday"),
+ CQ("Thursday"), CQ("Friday"), CQ("Saturday")};
+
+static _CONST int mname_len[12] =
+{7, 8, 5, 5, 3, 4, 4, 6, 9, 7, 8, 8};
+
+static _CONST CHAR *_CONST mname[12] =
+{CQ("January"), CQ("February"), CQ("March"), CQ("April"),
+ CQ("May"), CQ("June"), CQ("July"), CQ("August"),
+ CQ("September"), CQ("October"), CQ("November"), CQ("December")};
+
+/* Using the tm_year, tm_wday, and tm_yday components of TIM_P, return
+ -1, 0, or 1 as the adjustment to add to the year for the ISO week
+ numbering used in "%g%G%V", avoiding overflow. */
+static int
+_DEFUN (iso_year_adjust, (tim_p),
+ _CONST struct tm *tim_p)
+{
+ /* Account for fact that tm_year==0 is year 1900. */
+ int leap = isleap (tim_p->tm_year + (YEAR_BASE
+ - (tim_p->tm_year < 0 ? 0 : 2000)));
+
+ /* Pack the yday, wday, and leap year into a single int since there are so
+ many disparate cases. */
+#define PACK(yd, wd, lp) (((yd) << 4) + (wd << 1) + (lp))
+ switch (PACK (tim_p->tm_yday, tim_p->tm_wday, leap))
+ {
+ case PACK (0, 5, 0): /* Jan 1 is Fri, not leap. */
+ case PACK (0, 6, 0): /* Jan 1 is Sat, not leap. */
+ case PACK (0, 0, 0): /* Jan 1 is Sun, not leap. */
+ case PACK (0, 5, 1): /* Jan 1 is Fri, leap year. */
+ case PACK (0, 6, 1): /* Jan 1 is Sat, leap year. */
+ case PACK (0, 0, 1): /* Jan 1 is Sun, leap year. */
+ case PACK (1, 6, 0): /* Jan 2 is Sat, not leap. */
+ case PACK (1, 0, 0): /* Jan 2 is Sun, not leap. */
+ case PACK (1, 6, 1): /* Jan 2 is Sat, leap year. */
+ case PACK (1, 0, 1): /* Jan 2 is Sun, leap year. */
+ case PACK (2, 0, 0): /* Jan 3 is Sun, not leap. */
+ case PACK (2, 0, 1): /* Jan 3 is Sun, leap year. */
+ return -1; /* Belongs to last week of previous year. */
+ case PACK (362, 1, 0): /* Dec 29 is Mon, not leap. */
+ case PACK (363, 1, 1): /* Dec 29 is Mon, leap year. */
+ case PACK (363, 1, 0): /* Dec 30 is Mon, not leap. */
+ case PACK (363, 2, 0): /* Dec 30 is Tue, not leap. */
+ case PACK (364, 1, 1): /* Dec 30 is Mon, leap year. */
+ case PACK (364, 2, 1): /* Dec 30 is Tue, leap year. */
+ case PACK (364, 1, 0): /* Dec 31 is Mon, not leap. */
+ case PACK (364, 2, 0): /* Dec 31 is Tue, not leap. */
+ case PACK (364, 3, 0): /* Dec 31 is Wed, not leap. */
+ case PACK (365, 1, 1): /* Dec 31 is Mon, leap year. */
+ case PACK (365, 2, 1): /* Dec 31 is Tue, leap year. */
+ case PACK (365, 3, 1): /* Dec 31 is Wed, leap year. */
+ return 1; /* Belongs to first week of next year. */
+ }
+ return 0; /* Belongs to specified year. */
+#undef PACK
+}
+
+size_t
+_DEFUN (strftime, (s, maxsize, format, tim_p),
+ CHAR *s _AND
+ size_t maxsize _AND
+ _CONST CHAR *format _AND
+ _CONST struct tm *tim_p)
+{
+ size_t count = 0;
+ int i, len;
+
+ for (;;)
+ {
+ while (*format && *format != CQ('%'))
+ {
+ if (count < maxsize - 1)
+ s[count++] = *format++;
+ else
+ return 0;
+ }
+
+ if (*format == CQ('\0'))
+ break;
+
+ format++;
+ if (*format == CQ('E') || *format == CQ('O'))
+ format++;
+
+ switch (*format)
+ {
+ case CQ('a'):
+ for (i = 0; i < 3; i++)
+ {
+ if (count < maxsize - 1)
+ s[count++] =
+ dname[tim_p->tm_wday][i];
+ else
+ return 0;
+ }
+ break;
+ case CQ('A'):
+ for (i = 0; i < dname_len[tim_p->tm_wday]; i++)
+ {
+ if (count < maxsize - 1)
+ s[count++] =
+ dname[tim_p->tm_wday][i];
+ else
+ return 0;
+ }
+ break;
+ case CQ('b'):
+ case CQ('h'):
+ for (i = 0; i < 3; i++)
+ {
+ if (count < maxsize - 1)
+ s[count++] =
+ mname[tim_p->tm_mon][i];
+ else
+ return 0;
+ }
+ break;
+ case CQ('B'):
+ for (i = 0; i < mname_len[tim_p->tm_mon]; i++)
+ {
+ if (count < maxsize - 1)
+ s[count++] =
+ mname[tim_p->tm_mon][i];
+ else
+ return 0;
+ }
+ break;
+ case CQ('c'):
+ {
+ /* Recurse to avoid need to replicate %Y formation. */
+ size_t adjust = strftime (&s[count], maxsize - count,
+ CQ("%a %b %e %H:%M:%S %Y"), tim_p);
+ if (adjust > 0)
+ count += adjust;
+ else
+ return 0;
+ }
+ break;
+ case CQ('C'):
+ {
+ /* Examples of (tm_year + YEAR_BASE) that show how %Y == %C%y
+ with 32-bit int.
+ %Y %C %y
+ 2147485547 21474855 47
+ 10000 100 00
+ 9999 99 99
+ 0999 09 99
+ 0099 00 99
+ 0001 00 01
+ 0000 00 00
+ -001 -0 01
+ -099 -0 99
+ -999 -9 99
+ -1000 -10 00
+ -10000 -100 00
+ -2147481748 -21474817 48
+
+ Be careful of both overflow and sign adjustment due to the
+ asymmetric range of years.
+ */
+ int neg = tim_p->tm_year < -YEAR_BASE;
+ int century = tim_p->tm_year >= 0
+ ? tim_p->tm_year / 100 + YEAR_BASE / 100
+ : abs (tim_p->tm_year + YEAR_BASE) / 100;
+ len = snprintf (&s[count], maxsize - count, CQ("%s%.*d"),
+ neg ? CQ("-") : CQ(""), 2 - neg, century);
+ if (len < 0 || (count+=len) >= maxsize) return 0;
+ }
+ break;
+ case CQ('d'):
+ case CQ('e'):
+ len = snprintf (&s[count], maxsize - count,
+ *format == CQ('d') ? CQ("%.2d") : CQ("%2d"),
+ tim_p->tm_mday);
+ if (len < 0 || (count+=len) >= maxsize) return 0;
+ break;
+ case CQ('D'):
+ case CQ('x'):
+ /* %m/%d/%y */
+ len = snprintf (&s[count], maxsize - count,
+ CQ("%.2d/%.2d/%.2d"),
+ tim_p->tm_mon + 1, tim_p->tm_mday,
+ tim_p->tm_year >= 0 ? tim_p->tm_year % 100
+ : abs (tim_p->tm_year + YEAR_BASE) % 100);
+ if (len < 0 || (count+=len) >= maxsize) return 0;
+ break;
+ case CQ('F'):
+ { /* %F is equivalent to "%Y-%m-%d" */
+ /* Recurse to avoid need to replicate %Y formation. */
+ size_t adjust = strftime (&s[count], maxsize - count,
+ CQ("%Y-%m-%d"), tim_p);
+ if (adjust > 0)
+ count += adjust;
+ else
+ return 0;
+ }
+ break;
+ case CQ('g'):
+ /* Be careful of both overflow and negative years, thanks to
+ the asymmetric range of years. */
+ {
+ int adjust = iso_year_adjust (tim_p);
+ int year = tim_p->tm_year >= 0 ? tim_p->tm_year % 100
+ : abs (tim_p->tm_year + YEAR_BASE) % 100;
+ if (adjust < 0 && tim_p->tm_year <= -YEAR_BASE)
+ adjust = 1;
+ else if (adjust > 0 && tim_p->tm_year < -YEAR_BASE)
+ adjust = -1;
+ len = snprintf (&s[count], maxsize - count, CQ("%.2d"),
+ ((year + adjust) % 100 + 100) % 100);
+ if (len < 0 || (count+=len) >= maxsize) return 0;
+ }
+ break;
+ case CQ('G'):
+ {
+ /* See the comments for 'C' and 'Y'; this is a variable length
+ field. Although there is no requirement for a minimum number
+ of digits, we use 4 for consistency with 'Y'. */
+ int neg = tim_p->tm_year < -YEAR_BASE;
+ int adjust = iso_year_adjust (tim_p);
+ int century = tim_p->tm_year >= 0
+ ? tim_p->tm_year / 100 + YEAR_BASE / 100
+ : abs (tim_p->tm_year + YEAR_BASE) / 100;
+ int year = tim_p->tm_year >= 0 ? tim_p->tm_year % 100
+ : abs (tim_p->tm_year + YEAR_BASE) % 100;
+ if (adjust < 0 && tim_p->tm_year <= -YEAR_BASE)
+ neg = adjust = 1;
+ else if (adjust > 0 && neg)
+ adjust = -1;
+ year += adjust;
+ if (year == -1)
+ {
+ year = 99;
+ --century;
+ }
+ else if (year == 100)
+ {
+ year = 0;
+ ++century;
+ }
+ len = snprintf (&s[count], maxsize - count, CQ("%s%.*d%.2d"),
+ neg ? CQ("-") : CQ(""), 2 - neg, century, year);
+ if (len < 0 || (count+=len) >= maxsize)
+ return 0;
+ }
+ break;
+ case CQ('H'):
+ case CQ('k'): /* newlib extension */
+ len = snprintf (&s[count], maxsize - count,
+ *format == CQ('k') ? CQ("%2d") : CQ("%.2d"),
+ tim_p->tm_hour);
+ if (len < 0 || (count+=len) >= maxsize) return 0;
+ break;
+ case CQ('I'):
+ case CQ('l'): /* newlib extension */
+ {
+ register int h12;
+ h12 = (tim_p->tm_hour == 0 || tim_p->tm_hour == 12) ?
+ 12 : tim_p->tm_hour % 12;
+ len = snprintf (&s[count], maxsize - count,
+ *format == CQ('I') ? CQ("%.2d") : CQ("%2d"),
+ h12);
+ if (len < 0 || (count+=len) >= maxsize) return 0;
+ }
+ break;
+ case CQ('j'):
+ len = snprintf (&s[count], maxsize - count, CQ("%.3d"),
+ tim_p->tm_yday + 1);
+ if (len < 0 || (count+=len) >= maxsize) return 0;
+ break;
+ case CQ('m'):
+ len = snprintf (&s[count], maxsize - count, CQ("%.2d"),
+ tim_p->tm_mon + 1);
+ if (len < 0 || (count+=len) >= maxsize) return 0;
+ break;
+ case CQ('M'):
+ len = snprintf (&s[count], maxsize - count, CQ("%.2d"),
+ tim_p->tm_min);
+ if (len < 0 || (count+=len) >= maxsize) return 0;
+ break;
+ case CQ('n'):
+ if (count < maxsize - 1)
+ s[count++] = CQ('\n');
+ else
+ return 0;
+ break;
+ case CQ('p'):
+ if (count < maxsize - 1)
+ {
+ if (tim_p->tm_hour < 12)
+ s[count++] = CQ('A');
+ else
+ s[count++] = CQ('P');
+ }
+ if (count < maxsize - 1)
+ {
+ s[count++] = CQ('M');
+ }
+ else
+ return 0;
+ break;
+ case CQ('r'):
+ {
+ register int h12;
+ h12 = (tim_p->tm_hour == 0 || tim_p->tm_hour == 12) ?
+ 12 : tim_p->tm_hour % 12;
+ len = snprintf (&s[count], maxsize - count,
+ CQ("%.2d:%.2d:%.2d %cM"),
+ h12,
+ tim_p->tm_min,
+ tim_p->tm_sec,
+ (tim_p->tm_hour < 12) ? CQ('A') : CQ('P'));
+ if (len < 0 || (count+=len) >= maxsize) return 0;
+ }
+ break;
+ case CQ('R'):
+ len = snprintf (&s[count], maxsize - count, CQ("%.2d:%.2d"),
+ tim_p->tm_hour, tim_p->tm_min);
+ if (len < 0 || (count+=len) >= maxsize) return 0;
+ break;
+ case CQ('S'):
+ len = snprintf (&s[count], maxsize - count, CQ("%.2d"),
+ tim_p->tm_sec);
+ if (len < 0 || (count+=len) >= maxsize) return 0;
+ break;
+ case CQ('t'):
+ if (count < maxsize - 1)
+ s[count++] = CQ('\t');
+ else
+ return 0;
+ break;
+ case CQ('T'):
+ case CQ('X'):
+ len = snprintf (&s[count], maxsize - count, CQ("%.2d:%.2d:%.2d"),
+ tim_p->tm_hour, tim_p->tm_min, tim_p->tm_sec);
+ if (len < 0 || (count+=len) >= maxsize) return 0;
+ break;
+ case CQ('u'):
+ if (count < maxsize - 1)
+ {
+ if (tim_p->tm_wday == 0)
+ s[count++] = CQ('7');
+ else
+ s[count++] = CQ('0') + tim_p->tm_wday;
+ }
+ else
+ return 0;
+ break;
+ case CQ('U'):
+ len = snprintf (&s[count], maxsize - count, CQ("%.2d"),
+ (tim_p->tm_yday + 7 -
+ tim_p->tm_wday) / 7);
+ if (len < 0 || (count+=len) >= maxsize) return 0;
+ break;
+ case CQ('V'):
+ {
+ int adjust = iso_year_adjust (tim_p);
+ int wday = (tim_p->tm_wday) ? tim_p->tm_wday - 1 : 6;
+ int week = (tim_p->tm_yday + 10 - wday) / 7;
+ if (adjust > 0)
+ week = 1;
+ else if (adjust < 0)
+ /* Previous year has 53 weeks if current year starts on
+ Fri, and also if current year starts on Sat and
+ previous year was leap year. */
+ week = 52 + (4 >= (wday - tim_p->tm_yday
+ - isleap (tim_p->tm_year
+ + (YEAR_BASE - 1
+ - (tim_p->tm_year < 0
+ ? 0 : 2000)))));
+ len = snprintf (&s[count], maxsize - count, CQ("%.2d"), week);
+ if (len < 0 || (count+=len) >= maxsize) return 0;
+ }
+ break;
+ case CQ('w'):
+ if (count < maxsize - 1)
+ s[count++] = CQ('0') + tim_p->tm_wday;
+ else
+ return 0;
+ break;
+ case CQ('W'):
+ {
+ int wday = (tim_p->tm_wday) ? tim_p->tm_wday - 1 : 6;
+ len = snprintf (&s[count], maxsize - count, CQ("%.2d"),
+ (tim_p->tm_yday + 7 - wday) / 7);
+ if (len < 0 || (count+=len) >= maxsize) return 0;
+ }
+ break;
+ case CQ('y'):
+ {
+ /* Be careful of both overflow and negative years, thanks to
+ the asymmetric range of years. */
+ int year = tim_p->tm_year >= 0 ? tim_p->tm_year % 100
+ : abs (tim_p->tm_year + YEAR_BASE) % 100;
+ len = snprintf (&s[count], maxsize - count, CQ("%.2d"), year);
+ if (len < 0 || (count+=len) >= maxsize) return 0;
+ }
+ break;
+ case CQ('Y'):
+ /* An implementation choice is to have %Y match %C%y, so that it
+ * gives at least 4 digits, with leading zeros as needed. */
+ if(tim_p->tm_year <= INT_MAX-YEAR_BASE) {
+ /* For normal, non-overflow case. */
+ len = snprintf (&s[count], maxsize - count, CQ("%04d"),
+ tim_p->tm_year + YEAR_BASE);
+ }
+ else {
+ /* int would overflow, so use unsigned instead. */
+ register unsigned year;
+ year = (unsigned) tim_p->tm_year + (unsigned) YEAR_BASE;
+ len = snprintf (&s[count], maxsize - count, CQ("%04u"),
+ tim_p->tm_year + YEAR_BASE);
+ }
+ if (len < 0 || (count+=len) >= maxsize) return 0;
+ break;
+ case CQ('z'):
+ if (tim_p->tm_isdst >= 0)
+ {
+ long offset;
+ __tzinfo_type *tz = __gettzinfo ();
+ TZ_LOCK;
+ /* The sign of this is exactly opposite the envvar TZ. We
+ could directly use the global _timezone for tm_isdst==0,
+ but have to use __tzrule for daylight savings. */
+ offset = -tz->__tzrule[tim_p->tm_isdst > 0].offset;
+ TZ_UNLOCK;
+ len = snprintf (&s[count], maxsize - count, CQ("%+03ld%.2ld"),
+ offset / SECSPERHOUR,
+ labs (offset / SECSPERMIN) % 60L);
+ if (len < 0 || (count+=len) >= maxsize) return 0;
+ }
+ break;
+ case CQ('Z'):
+ if (tim_p->tm_isdst >= 0)
+ {
+ int size;
+ TZ_LOCK;
+ size = strlen(_tzname[tim_p->tm_isdst > 0]);
+ for (i = 0; i < size; i++)
+ {
+ if (count < maxsize - 1)
+ s[count++] = _tzname[tim_p->tm_isdst > 0][i];
+ else
+ {
+ TZ_UNLOCK;
+ return 0;
+ }
+ }
+ TZ_UNLOCK;
+ }
+ break;
+ case CQ('%'):
+ if (count < maxsize - 1)
+ s[count++] = CQ('%');
+ else
+ return 0;
+ break;
+ }
+ if (*format)
+ format++;
+ else
+ break;
+ }
+ if (maxsize)
+ s[count] = CQ('\0');
+
+ return count;
+}
+
+/* The remainder of this file can serve as a regression test. Compile
+ * with -D_REGRESSION_TEST. */
+#if defined(_REGRESSION_TEST) /* [Test code: */
+
+/* This test code relies on ANSI C features, in particular on the ability
+ * of adjacent strings to be pasted together into one string. */
+
+/* Test output buffer size (should be larger than all expected results) */
+#define OUTSIZE 256
+
+struct test {
+ CHAR *fmt; /* Testing format */
+ size_t max; /* Testing maxsize */
+ size_t ret; /* Expected return value */
+ CHAR *out; /* Expected output string */
+ };
+struct list {
+ const struct tm *tms; /* Time used for these vectors */
+ const struct test *vec; /* Test vectors */
+ int cnt; /* Number of vectors */
+ };
+
+const char TZ[]="TZ=EST5EDT";
+
+/* Define list of test inputs and expected outputs, for the given time zone
+ * and time. */
+const struct tm tm0 = {
+ /* Tue Dec 30 10:53:47 EST 2008 (time_t=1230648827) */
+ .tm_sec = 47,
+ .tm_min = 53,
+ .tm_hour = 9,
+ .tm_mday = 30,
+ .tm_mon = 11,
+ .tm_year = 108,
+ .tm_wday = 2,
+ .tm_yday = 364,
+ .tm_isdst = 0
+ };
+const struct test Vec0[] = {
+ /* Testing fields one at a time, expecting to pass, using exact
+ * allowed length as what is needed. */
+ /* Using tm0 for time: */
+ #define EXP(s) sizeof(s)/sizeof(CHAR)-1, s
+ { CQ("%a"), 3+1, EXP(CQ("Tue")) },
+ { CQ("%A"), 7+1, EXP(CQ("Tuesday")) },
+ { CQ("%b"), 3+1, EXP(CQ("Dec")) },
+ { CQ("%B"), 8+1, EXP(CQ("December")) },
+ { CQ("%c"), 24+1, EXP(CQ("Tue Dec 30 09:53:47 2008")) },
+ { CQ("%C"), 2+1, EXP(CQ("20")) },
+ { CQ("%d"), 2+1, EXP(CQ("30")) },
+ { CQ("%D"), 8+1, EXP(CQ("12/30/08")) },
+ { CQ("%e"), 2+1, EXP(CQ("30")) },
+ { CQ("%F"), 10+1, EXP(CQ("2008-12-30")) },
+ { CQ("%g"), 2+1, EXP(CQ("09")) },
+ { CQ("%G"), 4+1, EXP(CQ("2009")) },
+ { CQ("%h"), 3+1, EXP(CQ("Dec")) },
+ { CQ("%H"), 2+1, EXP(CQ("09")) },
+ { CQ("%I"), 2+1, EXP(CQ("09")) },
+ { CQ("%j"), 3+1, EXP(CQ("365")) },
+ { CQ("%k"), 2+1, EXP(CQ(" 9")) },
+ { CQ("%l"), 2+1, EXP(CQ(" 9")) },
+ { CQ("%m"), 2+1, EXP(CQ("12")) },
+ { CQ("%M"), 2+1, EXP(CQ("53")) },
+ { CQ("%n"), 1+1, EXP(CQ("\n")) },
+ { CQ("%p"), 2+1, EXP(CQ("AM")) },
+ { CQ("%r"), 11+1, EXP(CQ("09:53:47 AM")) },
+ { CQ("%R"), 5+1, EXP(CQ("09:53")) },
+ { CQ("%S"), 2+1, EXP(CQ("47")) },
+ { CQ("%t"), 1+1, EXP(CQ("\t")) },
+ { CQ("%T"), 8+1, EXP(CQ("09:53:47")) },
+ { CQ("%u"), 1+1, EXP(CQ("2")) },
+ { CQ("%U"), 2+1, EXP(CQ("52")) },
+ { CQ("%V"), 2+1, EXP(CQ("01")) },
+ { CQ("%w"), 1+1, EXP(CQ("2")) },
+ { CQ("%W"), 2+1, EXP(CQ("52")) },
+ { CQ("%x"), 8+1, EXP(CQ("12/30/08")) },
+ { CQ("%X"), 8+1, EXP(CQ("09:53:47")) },
+ { CQ("%y"), 2+1, EXP(CQ("08")) },
+ { CQ("%Y"), 4+1, EXP(CQ("2008")) },
+ { CQ("%z"), 5+1, EXP(CQ("-0500")) },
+ { CQ("%Z"), 3+1, EXP(CQ("EST")) },
+ { CQ("%%"), 1+1, EXP(CQ("%")) },
+ #undef EXP
+ };
+/* Define list of test inputs and expected outputs, for the given time zone
+ * and time. */
+const struct tm tm1 = {
+ /* Wed Jul 2 23:01:13 EDT 2008 (time_t=1215054073) */
+ .tm_sec = 13,
+ .tm_min = 1,
+ .tm_hour = 23,
+ .tm_mday = 2,
+ .tm_mon = 6,
+ .tm_year = 108,
+ .tm_wday = 3,
+ .tm_yday = 183,
+ .tm_isdst = 1
+ };
+const struct test Vec1[] = {
+ /* Testing fields one at a time, expecting to pass, using exact
+ * allowed length as what is needed. */
+ /* Using tm1 for time: */
+ #define EXP(s) sizeof(s)/sizeof(CHAR)-1, s
+ { CQ("%a"), 3+1, EXP(CQ("Wed")) },
+ { CQ("%A"), 9+1, EXP(CQ("Wednesday")) },
+ { CQ("%b"), 3+1, EXP(CQ("Jul")) },
+ { CQ("%B"), 4+1, EXP(CQ("July")) },
+ { CQ("%c"), 24+1, EXP(CQ("Wed Jul 2 23:01:13 2008")) },
+ { CQ("%C"), 2+1, EXP(CQ("20")) },
+ { CQ("%d"), 2+1, EXP(CQ("02")) },
+ { CQ("%D"), 8+1, EXP(CQ("07/02/08")) },
+ { CQ("%e"), 2+1, EXP(CQ(" 2")) },
+ { CQ("%F"), 10+1, EXP(CQ("2008-07-02")) },
+ { CQ("%g"), 2+1, EXP(CQ("08")) },
+ { CQ("%G"), 4+1, EXP(CQ("2008")) },
+ { CQ("%h"), 3+1, EXP(CQ("Jul")) },
+ { CQ("%H"), 2+1, EXP(CQ("23")) },
+ { CQ("%I"), 2+1, EXP(CQ("11")) },
+ { CQ("%j"), 3+1, EXP(CQ("184")) },
+ { CQ("%k"), 2+1, EXP(CQ("23")) },
+ { CQ("%l"), 2+1, EXP(CQ("11")) },
+ { CQ("%m"), 2+1, EXP(CQ("07")) },
+ { CQ("%M"), 2+1, EXP(CQ("01")) },
+ { CQ("%n"), 1+1, EXP(CQ("\n")) },
+ { CQ("%p"), 2+1, EXP(CQ("PM")) },
+ { CQ("%r"), 11+1, EXP(CQ("11:01:13 PM")) },
+ { CQ("%R"), 5+1, EXP(CQ("23:01")) },
+ { CQ("%S"), 2+1, EXP(CQ("13")) },
+ { CQ("%t"), 1+1, EXP(CQ("\t")) },
+ { CQ("%T"), 8+1, EXP(CQ("23:01:13")) },
+ { CQ("%u"), 1+1, EXP(CQ("3")) },
+ { CQ("%U"), 2+1, EXP(CQ("26")) },
+ { CQ("%V"), 2+1, EXP(CQ("27")) },
+ { CQ("%w"), 1+1, EXP(CQ("3")) },
+ { CQ("%W"), 2+1, EXP(CQ("26")) },
+ { CQ("%x"), 8+1, EXP(CQ("07/02/08")) },
+ { CQ("%X"), 8+1, EXP(CQ("23:01:13")) },
+ { CQ("%y"), 2+1, EXP(CQ("08")) },
+ { CQ("%Y"), 4+1, EXP(CQ("2008")) },
+ { CQ("%z"), 5+1, EXP(CQ("-0400")) },
+ { CQ("%Z"), 3+1, EXP(CQ("EDT")) },
+ { CQ("%%"), 1+1, EXP(CQ("%")) },
+ #undef EXP
+ #define VEC(s) s, sizeof(s)/sizeof(CHAR), sizeof(s)/sizeof(CHAR)-1, s
+ #define EXP(s) sizeof(s)/sizeof(CHAR), sizeof(s)/sizeof(CHAR)-1, s
+ { VEC(CQ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")) },
+ { CQ("0123456789%%%h:`~"), EXP(CQ("0123456789%Jul:`~")) },
+ { CQ("%R%h:`~ %x %w"), EXP(CQ("23:01Jul:`~ 07/02/08 3")) },
+ #undef VEC
+ #undef EXP
+ };
+
+#if YEAR_BASE == 1900 /* ( */
+/* Checks for very large years. YEAR_BASE value relied upon so that the
+ * answer strings can be predetermined.
+ * Years more than 4 digits are not mentioned in the standard for %C, so the
+ * test for those cases are based on the design intent (which is to print the
+ * whole number, being the century). */
+const struct tm tmyr0 = {
+ /* Wed Jul 2 23:01:13 EDT [HUGE#] */
+ .tm_sec = 13,
+ .tm_min = 1,
+ .tm_hour = 23,
+ .tm_mday = 2,
+ .tm_mon = 6,
+ .tm_year = INT_MAX - YEAR_BASE/2,
+ .tm_wday = 3,
+ .tm_yday = 183,
+ .tm_isdst = 1
+ };
+#if INT_MAX == 32767
+# define YEAR CQ("33717") /* INT_MAX + YEAR_BASE/2 */
+# define CENT CQ("337")
+# define Year CQ("17")
+# elif INT_MAX == 2147483647
+# define YEAR CQ("2147484597")
+# define CENT CQ("21474845")
+# define Year CQ("97")
+# elif INT_MAX == 9223372036854775807
+# define YEAR CQ("9223372036854776757")
+# define CENT CQ("92233720368547777")
+# define Year CQ("57")
+# else
+# error "Unrecognized INT_MAX value: enhance me to recognize what you have"
+#endif
+const struct test Vecyr0[] = {
+ /* Testing fields one at a time, expecting to pass, using a larger
+ * allowed length than what is needed. */
+ /* Using tmyr0 for time: */
+ #define EXP(s) sizeof(s)/sizeof(CHAR)-1, s
+ { CQ("%C"), OUTSIZE, EXP(CENT) },
+ { CQ("%c"), OUTSIZE, EXP(CQ("Wed Jul 2 23:01:13 ")YEAR) },
+ { CQ("%D"), OUTSIZE, EXP(CQ("07/02/")Year) },
+ { CQ("%F"), OUTSIZE, EXP(YEAR CQ("-07-02")) },
+ { CQ("%x"), OUTSIZE, EXP(CQ("07/02/")Year) },
+ { CQ("%y"), OUTSIZE, EXP(Year) },
+ { CQ("%Y"), OUTSIZE, EXP(YEAR) },
+ #undef EXP
+ };
+#undef YEAR
+#undef CENT
+#undef Year
+/* Checks for very large negative years. YEAR_BASE value relied upon so that
+ * the answer strings can be predetermined. */
+const struct tm tmyr1 = {
+ /* Wed Jul 2 23:01:13 EDT [HUGE#] */
+ .tm_sec = 13,
+ .tm_min = 1,
+ .tm_hour = 23,
+ .tm_mday = 2,
+ .tm_mon = 6,
+ .tm_year = INT_MIN,
+ .tm_wday = 3,
+ .tm_yday = 183,
+ .tm_isdst = 1
+ };
+#if INT_MAX == 32767
+# define YEAR CQ("-30868") /* INT_MIN + YEAR_BASE */
+# define CENT CQ("-308")
+# define Year CQ("68")
+# elif INT_MAX == 2147483647
+# define YEAR CQ("-2147481748")
+# define CENT CQ("-21474817")
+# define Year CQ("48")
+# elif INT_MAX == 9223372036854775807
+# define YEAR CQ("-9223372036854773908")
+# define CENT CQ("-92233720368547739")
+# define Year CQ("08")
+# else
+# error "Unrecognized INT_MAX value: enhance me to recognize what you have"
+#endif
+const struct test Vecyr1[] = {
+ /* Testing fields one at a time, expecting to pass, using a larger
+ * allowed length than what is needed. */
+ /* Using tmyr1 for time: */
+ #define EXP(s) sizeof(s)/sizeof(CHAR)-1, s
+ { CQ("%C"), OUTSIZE, EXP(CENT) },
+ { CQ("%c"), OUTSIZE, EXP(CQ("Wed Jul 2 23:01:13 ")YEAR) },
+ { CQ("%D"), OUTSIZE, EXP(CQ("07/02/")Year) },
+ { CQ("%F"), OUTSIZE, EXP(YEAR CQ("-07-02")) },
+ { CQ("%x"), OUTSIZE, EXP(CQ("07/02/")Year) },
+ { CQ("%y"), OUTSIZE, EXP(Year) },
+ { CQ("%Y"), OUTSIZE, EXP(YEAR) },
+ #undef EXP
+ };
+#undef YEAR
+#undef CENT
+#undef Year
+#endif /* YEAR_BASE ) */
+
+/* Checks for years just over zero (also test for s=60).
+ * Years less than 4 digits are not mentioned for %Y in the standard, so the
+ * test for that case is based on the design intent. */
+const struct tm tmyrzp = {
+ /* Wed Jul 2 23:01:60 EDT 0007 */
+ .tm_sec = 60,
+ .tm_min = 1,
+ .tm_hour = 23,
+ .tm_mday = 2,
+ .tm_mon = 6,
+ .tm_year = 7-YEAR_BASE,
+ .tm_wday = 3,
+ .tm_yday = 183,
+ .tm_isdst = 1
+ };
+#define YEAR CQ("0007") /* Design intent: %Y=%C%y */
+#define CENT CQ("00")
+#define Year CQ("07")
+const struct test Vecyrzp[] = {
+ /* Testing fields one at a time, expecting to pass, using a larger
+ * allowed length than what is needed. */
+ /* Using tmyrzp for time: */
+ #define EXP(s) sizeof(s)/sizeof(CHAR)-1, s
+ { CQ("%C"), OUTSIZE, EXP(CENT) },
+ { CQ("%c"), OUTSIZE, EXP(CQ("Wed Jul 2 23:01:60 ")YEAR) },
+ { CQ("%D"), OUTSIZE, EXP(CQ("07/02/")Year) },
+ { CQ("%F"), OUTSIZE, EXP(YEAR CQ("-07-02")) },
+ { CQ("%x"), OUTSIZE, EXP(CQ("07/02/")Year) },
+ { CQ("%y"), OUTSIZE, EXP(Year) },
+ { CQ("%Y"), OUTSIZE, EXP(YEAR) },
+ #undef EXP
+ };
+#undef YEAR
+#undef CENT
+#undef Year
+/* Checks for years just under zero.
+ * Negative years are not handled by the standard, so the vectors here are
+ * verifying the chosen implemtation. */
+const struct tm tmyrzn = {
+ /* Wed Jul 2 23:01:00 EDT -004 */
+ .tm_sec = 00,
+ .tm_min = 1,
+ .tm_hour = 23,
+ .tm_mday = 2,
+ .tm_mon = 6,
+ .tm_year = -4-YEAR_BASE,
+ .tm_wday = 3,
+ .tm_yday = 183,
+ .tm_isdst = 1
+ };
+#define YEAR CQ("-004")
+#define CENT CQ("-0")
+#define Year CQ("04")
+const struct test Vecyrzn[] = {
+ /* Testing fields one at a time, expecting to pass, using a larger
+ * allowed length than what is needed. */
+ /* Using tmyrzn for time: */
+ #define EXP(s) sizeof(s)/sizeof(CHAR)-1, s
+ { CQ("%C"), OUTSIZE, EXP(CENT) },
+ { CQ("%c"), OUTSIZE, EXP(CQ("Wed Jul 2 23:01:00 ")YEAR) },
+ { CQ("%D"), OUTSIZE, EXP(CQ("07/02/")Year) },
+ { CQ("%F"), OUTSIZE, EXP(YEAR CQ("-07-02")) },
+ { CQ("%x"), OUTSIZE, EXP(CQ("07/02/")Year) },
+ { CQ("%y"), OUTSIZE, EXP(Year) },
+ { CQ("%Y"), OUTSIZE, EXP(YEAR) },
+ #undef EXP
+ };
+#undef YEAR
+#undef CENT
+#undef Year
+
+const struct list ListYr[] = {
+ { &tmyrzp, Vecyrzp, sizeof(Vecyrzp)/sizeof(Vecyrzp[0]) },
+ { &tmyrzn, Vecyrzn, sizeof(Vecyrzn)/sizeof(Vecyrzn[0]) },
+ #if YEAR_BASE == 1900
+ { &tmyr0, Vecyr0, sizeof(Vecyr0)/sizeof(Vecyr0[0]) },
+ { &tmyr1, Vecyr1, sizeof(Vecyr1)/sizeof(Vecyr1[0]) },
+ #endif
+ };
+
+
+/* List of tests to be run */
+const struct list List[] = {
+ { &tm0, Vec0, sizeof(Vec0)/sizeof(Vec0[0]) },
+ { &tm1, Vec1, sizeof(Vec1)/sizeof(Vec1[0]) },
+ };
+
+#if defined(STUB_getenv_r)
+char *
+_getenv_r(struct _reent *p, const char *cp) { return getenv(cp); }
+#endif
+
+int
+main(void)
+{
+int i, l, errr=0, erro=0, tot=0;
+const char *cp;
+CHAR out[OUTSIZE];
+size_t ret;
+
+/* Set timezone so that %z and %Z tests come out right */
+cp = TZ;
+if((i=putenv(cp))) {
+ printf( "putenv(%s) FAILED, ret %d\n", cp, i);
+ return(-1);
+ }
+if(strcmp(getenv("TZ"),strchr(TZ,'=')+1)) {
+ printf( "TZ not set properly in environment\n");
+ return(-2);
+ }
+tzset();
+
+#if defined(VERBOSE)
+printf("_timezone=%d, _daylight=%d, _tzname[0]=%s, _tzname[1]=%s\n", _timezone, _daylight, _tzname[0], _tzname[1]);
+{
+long offset;
+__tzinfo_type *tz = __gettzinfo ();
+/* The sign of this is exactly opposite the envvar TZ. We
+ could directly use the global _timezone for tm_isdst==0,
+ but have to use __tzrule for daylight savings. */
+printf("tz->__tzrule[0].offset=%d, tz->__tzrule[1].offset=%d\n", tz->__tzrule[0].offset, tz->__tzrule[1].offset);
+}
+#endif
+
+/* Run all of the exact-length tests as-given--results should match */
+for(l=0; lcnt; i++) {
+ tot++; /* Keep track of number of tests */
+ ret = strftime(out, test->vec[i].max, test->vec[i].fmt, test->tms);
+ if(ret != test->vec[i].ret) {
+ errr++;
+ fprintf(stderr,
+ "ERROR: return %d != %d expected for List[%d].vec[%d]\n",
+ ret, test->vec[i].ret, l, i);
+ }
+ if(strncmp(out, test->vec[i].out, test->vec[i].max-1)) {
+ erro++;
+ fprintf(stderr,
+ "ERROR: \"%"SFLG"s\" != \"%"SFLG"s\" expected for List[%d].vec[%d]\n",
+ out, test->vec[i].out, l, i);
+ }
+ }
+ }
+
+/* Run all of the exact-length tests with the length made too short--expect to
+ * fail. */
+for(l=0; lcnt; i++) {
+ tot++; /* Keep track of number of tests */
+ ret = strftime(out, test->vec[i].max-1, test->vec[i].fmt, test->tms);
+ if(ret != 0) {
+ errr++;
+ fprintf(stderr,
+ "ERROR: return %d != %d expected for List[%d].vec[%d]\n",
+ ret, 0, l, i);
+ }
+ /* Almost every conversion puts out as many characters as possible, so
+ * go ahead and test the output even though have failed. (The test
+ * times chosen happen to not hit any of the cases that fail this, so it
+ * works.) */
+ if(strncmp(out, test->vec[i].out, test->vec[i].max-1-1)) {
+ erro++;
+ fprintf(stderr,
+ "ERROR: \"%"SFLG"s\" != \"%"SFLG"s\" expected for List[%d].vec[%d]\n",
+ out, test->vec[i].out, l, i);
+ }
+ }
+ }
+
+/* Run all of the special year test cases */
+for(l=0; lcnt; i++) {
+ tot++; /* Keep track of number of tests */
+ ret = strftime(out, test->vec[i].max, test->vec[i].fmt, test->tms);
+ if(ret != test->vec[i].ret) {
+ errr++;
+ fprintf(stderr,
+ "ERROR: return %d != %d expected for ListYr[%d].vec[%d]\n",
+ ret, test->vec[i].ret, l, i);
+ }
+ if(strncmp(out, test->vec[i].out, test->vec[i].max-1)) {
+ erro++;
+ fprintf(stderr,
+ "ERROR: \"%"SFLG"s\" != \"%"SFLG"s\" expected for ListYr[%d].vec[%d]\n",
+ out, test->vec[i].out, l, i);
+ }
+ }
+ }
+
+#define STRIZE(f) #f
+#define NAME(f) STRIZE(f)
+printf(NAME(strftime) "() test ");
+if(errr || erro) printf("FAILED %d/%d of", errr, erro);
+ else printf("passed");
+printf(" %d test cases.\n", tot);
+
+return(errr || erro);
+}
+#endif /* defined(_REGRESSION_TEST) ] */
strftime.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property