Some minor fixes and improvments:
1. Fixed compiler warnings about incompatible usage of time_t in snprintf and fprintf format strings (Line 85 and 102). 2. Fixed usage of wronge time variable in failsafe error message (Line 102). 3. Clearified error message about wrong timestamp format. It now says integer instead of numeric (Line 87).
This commit is contained in:
@@ -82,16 +82,16 @@ int main(int argc, char** argv) {
|
||||
t = atol(argv[i]);
|
||||
l = strlen(argv[i]);
|
||||
if((p = malloc(l + 1)) != NULL) {
|
||||
snprintf(p, l + 1, "%d", t);
|
||||
snprintf(p, l + 1, "%ld", t);
|
||||
if(strcmp(argv[i], p)) {
|
||||
fprintf(stderr, "%s: not numeric: %s\n", progname,
|
||||
fprintf(stderr, "%s: not integer: %s\n", progname,
|
||||
argv[i]);
|
||||
exit(EX_DATAERR);
|
||||
}
|
||||
free(p);
|
||||
} else {
|
||||
fprintf(stderr, "%s: Warning: cannot allocate memory"
|
||||
" to do numeric test on input.\n", progname);
|
||||
" to do integer test on input.\n", progname);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -99,7 +99,7 @@ int main(int argc, char** argv) {
|
||||
|
||||
p = ctime((& t));
|
||||
if(p == NULL) {
|
||||
fprintf(stderr, "%s: unrecognized date '%d'.\n", progname, time);
|
||||
fprintf(stderr, "%s: unrecognized date '%ld'.\n", progname, t);
|
||||
exit(EX_DATAERR);
|
||||
}
|
||||
fputs(p, stdout);
|
||||
|
||||
Reference in New Issue
Block a user