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:
2012-10-09 10:34:47 +02:00
parent dba38a0648
commit ca123fb724

View File

@@ -82,16 +82,16 @@ int main(int argc, char** argv) {
t = atol(argv[i]); t = atol(argv[i]);
l = strlen(argv[i]); l = strlen(argv[i]);
if((p = malloc(l + 1)) != NULL) { if((p = malloc(l + 1)) != NULL) {
snprintf(p, l + 1, "%d", t); snprintf(p, l + 1, "%ld", t);
if(strcmp(argv[i], p)) { if(strcmp(argv[i], p)) {
fprintf(stderr, "%s: not numeric: %s\n", progname, fprintf(stderr, "%s: not integer: %s\n", progname,
argv[i]); argv[i]);
exit(EX_DATAERR); exit(EX_DATAERR);
} }
free(p); free(p);
} else { } else {
fprintf(stderr, "%s: Warning: cannot allocate memory" fprintf(stderr, "%s: Warning: cannot allocate memory"
" to do numeric test on input.\n", progname); " to do integer test on input.\n", progname);
} }
break; break;
} }
@@ -99,7 +99,7 @@ int main(int argc, char** argv) {
p = ctime((& t)); p = ctime((& t));
if(p == NULL) { if(p == NULL) {
fprintf(stderr, "%s: unrecognized date '%d'.\n", progname, time); fprintf(stderr, "%s: unrecognized date '%ld'.\n", progname, t);
exit(EX_DATAERR); exit(EX_DATAERR);
} }
fputs(p, stdout); fputs(p, stdout);