summaryrefslogtreecommitdiff
path: root/src/strftime.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@twinsun.com>1997-05-27 03:15:29 +0000
committerPaul Eggert <eggert@twinsun.com>1997-05-27 03:15:29 +0000
commit098401cfa2769a1be43535cbb401cfff2de036b5 (patch)
treec4e2dc98cb284023c2adef7ea0b1fb0b5d7aa9dc /src/strftime.c
parent1aa6072f7d8439d34950925c51c21e0cb1625279 (diff)
downloademacs-098401cfa2769a1be43535cbb401cfff2de036b5.tar.gz
automatically generated from GPLed version
Diffstat (limited to 'src/strftime.c')
-rw-r--r--src/strftime.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/strftime.c b/src/strftime.c
index c0cc077b072..abd039f5b24 100644
--- a/src/strftime.c
+++ b/src/strftime.c
@@ -177,6 +177,7 @@ 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 { \
@@ -191,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)), (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); \
@@ -206,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; \
} \