[tz] [PATCH] * zdump.c: Minor integer-size porting fixes.
Paul Eggert
eggert at cs.ucla.edu
Sat Aug 17 04:54:40 UTC 2013
(main): Don't assume SECSPERDAY <= INT_MAX here, since we try
not to assume that sort of thing elsewhere in this file.
Don't rely on undefined behavior in the weird case where
cuthitime < absolute_min_time + SECSPERDAY / 2.
---
zdump.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/zdump.c b/zdump.c
index fa5f8d8..3d5ec64 100644
--- a/zdump.c
+++ b/zdump.c
@@ -452,7 +452,7 @@ main(int argc, char *argv[])
t = absolute_min_time;
if (!Vflag) {
show(argv[i], t, TRUE);
- t += SECSPERHOUR * HOURSPERDAY;
+ t += SECSPERDAY;
show(argv[i], t, TRUE);
}
if (t < cutlotime)
@@ -463,9 +463,11 @@ main(int argc, char *argv[])
(void) strncpy(buf, abbr(&tm), (sizeof buf) - 1);
}
for ( ; ; ) {
- if (t >= cuthitime || t >= cuthitime - SECSPERHOUR * 12)
+ newt = (t < absolute_max_time - SECSPERDAY / 2
+ ? t + SECSPERDAY / 2
+ : absolute_max_time);
+ if (cuthitime <= newt)
break;
- newt = t + SECSPERHOUR * 12;
newtmp = localtime(&newt);
if (newtmp != NULL)
newtm = *newtmp;
@@ -488,9 +490,9 @@ main(int argc, char *argv[])
}
if (!Vflag) {
t = absolute_max_time;
- t -= SECSPERHOUR * HOURSPERDAY;
+ t -= SECSPERDAY;
show(argv[i], t, TRUE);
- t += SECSPERHOUR * HOURSPERDAY;
+ t += SECSPERDAY;
show(argv[i], t, TRUE);
}
}
--
1.7.11.7
More information about the tz
mailing list