* zdump.c: Minor integer-size porting fixes.

(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.
This commit is contained in:
Paul Eggert
2013-08-16 21:53:37 -07:00
parent a52dc74e57
commit e0d4fb5f1e
+7 -5
View File
@@ -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);
}
}