[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-gnulib] xctime
From: |
Simon Josefsson |
Subject: |
[Bug-gnulib] xctime |
Date: |
Thu, 16 Sep 2004 16:53:21 +0200 |
User-agent: |
Gnus/5.110003 (No Gnus v0.3) Emacs/21.3.50 (gnu/linux) |
How about this?
Do ctime_r ever return a string longer than 26 characters? Taking
into account locales etc? I did some testing, and it didn't seem that
way. But if so, how should that be handled? Just doing a x2realloc
loop on a NULL return value might not be the best idea.
2004-09-16 Simon Josefsson <address@hidden>
* MODULES.html.sh: Add xctime.
* modules/xctime: New file.
2004-09-16 Simon Josefsson <address@hidden>
* xctime.m4: New file.
2004-09-16 Simon Josefsson <address@hidden>
* xctime.h, xctime.c: New file.
Index: MODULES.html.sh
===================================================================
RCS file: /cvsroot/gnulib/gnulib/MODULES.html.sh,v
retrieving revision 1.60
diff -u -p -r1.60 MODULES.html.sh
--- MODULES.html.sh 8 Sep 2004 12:43:11 -0000 1.60
+++ MODULES.html.sh 16 Sep 2004 14:51:41 -0000
@@ -1854,6 +1855,7 @@ func_all_modules ()
func_module gettime
func_module settime
func_module posixtm
+ func_module xctime
func_module xnanosleep
func_end_table
Index: lib/xctime.h
===================================================================
RCS file: lib/xctime.h
diff -N lib/xctime.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lib/xctime.h 16 Sep 2004 14:51:41 -0000
@@ -0,0 +1,30 @@
+/* xctime.h -- Convert Unix time to newly allocated human readable string.
+ Copyright (C) 2004 Free Software Foundation, Inc.
+ Written by Simon Josefsson.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef XCTIME_H
+# define XCTIME_H
+
+/* Get time_t. */
+# include <time.h>
+
+/* Convert Unix time TIMEP to newly allocated human readable string.
+ The format is "Wed Jun 30 21:49:08 1993\n". Unlike ctime, it does
+ not set tzname. */
+char *xctime(const time_t *timep);
+
+#endif /* XCTIME_H */
Index: lib/xctime.c
===================================================================
RCS file: lib/xctime.c
diff -N lib/xctime.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lib/xctime.c 16 Sep 2004 14:51:41 -0000
@@ -0,0 +1,39 @@
+/* xctime.c -- Convert Unix time to newly allocated human readable string.
+ Copyright (C) 2004 Free Software Foundation, Inc.
+ Written by Simon Josefsson.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+/* Specification. */
+#include "xctime.h"
+
+/* Get ctime_r. */
+#include "time_r.h"
+
+/* Get xmalloc, xalloc_die. */
+#include "xalloc.h"
+
+char *
+xctime(const time_t *timep)
+{
+ char *p = xmalloc (26);
+ if (!ctime_r (timep, p))
+ xalloc_die ();
+ return p;
+}
Index: m4/xctime.m4
===================================================================
RCS file: m4/xctime.m4
diff -N m4/xctime.m4
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ m4/xctime.m4 16 Sep 2004 14:51:41 -0000
@@ -0,0 +1,18 @@
+# xctime.m4 serial 1
+dnl Copyright (C) 2004 Free Software Foundation, Inc.
+dnl This file is free software, distributed under the terms of the GNU
+dnl General Public License. As a special exception to the GNU General
+dnl Public License, this file may be distributed as part of a program
+dnl that contains a configuration script generated by Autoconf, under
+dnl the same distribution terms as the rest of that program.
+
+AC_DEFUN([gl_FUNC_XCTIME],
+[
+ gl_PREREQ_XCTIME
+])
+
+# Prerequisites of lib/xctime.c.
+AC_DEFUN([gl_PREREQ_XCTIME],
+[
+ AC_REQUIRE([gl_TIME_R])
+])
Index: modules/xctime
===================================================================
RCS file: modules/xctime
diff -N modules/xctime
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ modules/xctime 16 Sep 2004 14:51:41 -0000
@@ -0,0 +1,23 @@
+Description:
+Convert Unix time to newly allocated human readable string.
+
+Files:
+lib/xctime.h
+lib/xctime.c
+m4/xctime.m4
+
+Depends-on:
+time_r
+xalloc
+
+configure.ac:
+gl_FUNC_XCTIME
+
+Makefile.am:
+lib_SOURCES += xctime.h xctime.c
+
+Include:
+"xctime.h"
+
+Maintainer:
+Simon Josefsson
- [Bug-gnulib] xctime,
Simon Josefsson <=