From 4f690a51e3e58ea83e492f7658765711964a9a82 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Wed, 28 May 1997 12:01:33 +0000 Subject: update from FSF --- lib/strftime.c | 60 +++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 19 deletions(-) (limited to 'lib/strftime.c') diff --git a/lib/strftime.c b/lib/strftime.c index 8c838f783..abd039f5b 100644 --- a/lib/strftime.c +++ b/lib/strftime.c @@ -1,21 +1,22 @@ /* Copyright (C) 1991, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc. - NOTE: The canonical source of this file is maintained with the GNU C - Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu. +NOTE: The canonical source of this file is maintained with the GNU C Library. +Bugs can be reported to bug-glibc@prep.ai.mit.edu. - 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 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. +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. */ +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 @@ -176,11 +177,12 @@ localtime_r (t, tp) /* Some systems lack the `memset' function and we don't want to introduce additional dependencies. */ static const char spaces[16] = " "; +static const char zeroes[16] = "0000000000000000"; # define memset_space(P, Len) \ do { \ int _len = (Len); \ - \ + \ do \ { \ int _this = _len > 16 ? 16 : _len; \ @@ -190,11 +192,26 @@ static const char spaces[16] = " "; } \ while (_len > 0); \ } while (0) + +# define memset_zero(P, Len) \ + do { \ + int _len = (Len); \ + \ + do \ + { \ + int _this = _len > 16 ? 16 : _len; \ + memcpy ((P), zeroes, _this); \ + (P) += _this; \ + _len -= _this; \ + } \ + while (_len > 0); \ + } while (0) #else -# define memset_space(P, Len) memset ((P), ' ', (Len)) +# define memset_space(P, Len) (memset ((P), ' ', (Len)), (P) += (Len)) +# define memset_zero(P, Len) (memset ((P), '0', (Len)), (P) += (Len)) #endif -#define add(n, f) \ +#define add(n, f) \ do \ { \ int _n = (n); \ @@ -205,7 +222,12 @@ static const char spaces[16] = " "; if (p) \ { \ if (_delta > 0) \ - memset_space (p, _delta); \ + { \ + if (pad == '0') \ + memset_zero (p, _delta); \ + else \ + memset_space (p, _delta); \ + } \ f; \ p += _n; \ } \ @@ -349,11 +371,11 @@ static char const month_name[][10] = # ifdef strftime # undef strftime # endif -# define strftime _strftime_copytm +# define strftime(S, Maxsize, Format, Tp) \ + _strftime_copytm (S, Maxsize, Format, Tp) #endif - /* Write information from TP into S according to the format string FORMAT, writing no more that MAXSIZE characters (including the terminating '\0') and returning number of -- cgit v1.2.3-54-g00ecf