I've just checked in the files that complete the
implementation of the new fprintftime module.
In coreutils, both date and du now use fprintftime.
The strftime.c [FPRINTFTIME] changes have been here for a while,
and all of this code has been in coreutils for a couple of months.
Here are the ChangeLog entries I wrote for coreutils:
* strftime.c [FPRINTFTIME] (fprintftime): Provide a new interface:
size_t fprintftime (FILE *fp, char const *fmt, struct tm const *tm,
int utc, int nanoseconds);
Background:
date should not have to allocate a megabyte of virtual memory to
handle a format argument like +%1048575T. When implemented with
strftime, it must allocate such a buffer, use strftime to fill it
in, print it, then free it.
With fprintftime, it simply prints everything and exits.
With no need for memory allocation, that's one fewer way to fail.
* fprintftime.c, fprintftime.h: New files.
ChangeLog
2005-12-16 Jim Meyering <[EMAIL PROTECTED]>
* modules/fprintftime: New module.
* MODULES.html.sh (Date and time <time.h>): Add fprintftime.
Index: m4/ChangeLog
2005-12-16 Jim Meyering <[EMAIL PROTECTED]>
* fprintftime.m4: New file.
Index: lib/ChangeLog
2005-12-16 Jim Meyering <[EMAIL PROTECTED]>
* fprintftime.c, fprintftime.h: New files.
Index: MODULES.html.sh
===================================================================
RCS file: /sources/gnulib/gnulib/MODULES.html.sh,v
retrieving revision 1.110
retrieving revision 1.111
diff -u -p -u -r1.110 -r1.111
--- MODULES.html.sh 11 Oct 2005 18:50:37 -0000 1.110
+++ MODULES.html.sh 16 Dec 2005 15:05:12 -0000 1.111
@@ -1456,6 +1456,7 @@ func_all_modules ()
func_echo "$element"
func_begin_table
+ func_module fprintftime
func_module strftime
func_end_table
Index: modules/fprintftime
===================================================================
RCS file: modules/fprintftime
diff -N modules/fprintftime
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ modules/fprintftime 16 Dec 2005 15:04:59 -0000 1.1
@@ -0,0 +1,24 @@
+Description:
+like nstrftime, but output the formatted date to a FILE* stream
+
+Files:
+lib/fprintftime.h
+lib/fprintftime.c
+m4/fprintftime.m4
+
+Depends-on:
+strftime
+
+configure.ac:
+gl_FPRINTFTIME
+
+Makefile.am:
+
+Include:
+"fprintftime.h"
+
+License:
+GPL
+
+Maintainer:
+Jim Meyering
Index: lib/fprintftime.c
===================================================================
RCS file: lib/fprintftime.c
diff -N lib/fprintftime.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lib/fprintftime.c 16 Dec 2005 15:07:03 -0000 1.1
@@ -0,0 +1,7 @@
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "fprintftime.h"
+#define FPRINTFTIME 1
+#include "strftime.c"
Index: lib/fprintftime.h
===================================================================
RCS file: lib/fprintftime.h
diff -N lib/fprintftime.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lib/fprintftime.h 16 Dec 2005 15:06:54 -0000 1.1
@@ -0,0 +1,12 @@
+#include <stdio.h>
+#include <time.h>
+
+/* A cross between fprintf and nstrftime, that prints directly
+ to the output stream, without the need for the potentially
+ large buffer that nstrftime would require.
+
+ Output to stream FP the result of formatting (according to the
+ nstrftime format string, FMT) the time data, *TM, and the UTC
+ and NANOSECONDS values. */
+size_t fprintftime (FILE *fp, char const *fmt, struct tm const *tm,
+ int utc, int nanoseconds);
Index: m4/fprintftime.m4
===================================================================
RCS file: m4/fprintftime.m4
diff -N m4/fprintftime.m4
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ m4/fprintftime.m4 16 Dec 2005 15:05:47 -0000 1.1
@@ -0,0 +1,11 @@
+#serial 1
+dnl Copyright (C) 2005 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FPRINTFTIME],
+[
+ AC_LIBSOURCES([fprintftime.c, fprintftime.h])
+ AC_LIBOBJ([fprintftime])
+])
_______________________________________________
bug-gnulib mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-gnulib