aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/ChangeLog6
-rw-r--r--util/memory.c4
-rw-r--r--util/miscutil.c18
3 files changed, 24 insertions, 4 deletions
diff --git a/util/ChangeLog b/util/ChangeLog
index 589eb26c8..1530f07b3 100644
--- a/util/ChangeLog
+++ b/util/ChangeLog
@@ -1,3 +1,9 @@
+2001-04-19 Werner Koch <[email protected]>
+
+ * miscutil.c (asctimestamp): Handle negative times. We must do
+ this because Windoze segvs on negative times passed to gmtime().
+ (strtimestamp): Ditto.
+
2001-04-14 Werner Koch <[email protected]>
* strgutil.c (utf8_to_native): Fixed a segv. Thanks to Keith Clayton.
diff --git a/util/memory.c b/util/memory.c
index af79cd0cb..ef9a315dc 100644
--- a/util/memory.c
+++ b/util/memory.c
@@ -42,6 +42,10 @@
#define MAGIC_SEC_BYTE 0xcc
#define MAGIC_END_BYTE 0xaa
+/* This is a very crude alignment check which does not work on all CPUs
+ * IIRC, I once introduced it for testing on an Alpha. We should better
+ * replace this guard stuff with one provided by a modern malloc library
+ */
#if SIZEOF_UNSIGNED_LONG == 8
#define EXTRA_ALIGN 4
#else
diff --git a/util/miscutil.c b/util/miscutil.c
index be41d93d4..376834fa6 100644
--- a/util/miscutil.c
+++ b/util/miscutil.c
@@ -124,10 +124,15 @@ strtimestamp( u32 stamp )
static char buffer[11+5];
struct tm *tp;
time_t atime = stamp;
-
- tp = gmtime( &atime );
- sprintf(buffer,"%04d-%02d-%02d",
- 1900+tp->tm_year, tp->tm_mon+1, tp->tm_mday );
+
+ if (atime < 0) {
+ strcpy (buffer, "????-??-??");
+ }
+ else {
+ tp = gmtime( &atime );
+ sprintf(buffer,"%04d-%02d-%02d",
+ 1900+tp->tm_year, tp->tm_mon+1, tp->tm_mday );
+ }
return buffer;
}
@@ -144,6 +149,11 @@ asctimestamp( u32 stamp )
struct tm *tp;
time_t atime = stamp;
+ if (atime < 0) {
+ strcpy (buffer, "????-??-??");
+ return buffer;
+ }
+
tp = localtime( &atime );
#ifdef HAVE_STRFTIME
#if defined(HAVE_NL_LANGINFO)