diff options
author | Jim Meyering <jim@meyering.net> | 2001-08-18 17:45:31 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2001-08-18 17:45:31 +0000 |
commit | 1c9af0041d765e7a8e63704ead2abeaf39392ae9 (patch) | |
tree | 1114e8cfb5c3c3c0b4c63e55ade7634eb8a0c895 /src | |
parent | 9402bfd9ef7221d2915102634287cced5e4ef0cf (diff) | |
download | coreutils-1c9af0041d765e7a8e63704ead2abeaf39392ae9.tar.xz |
(isint, binary_operator, unary_operator):
Use intmax_t for argument integers, not long.
(age_of, binary_operator): Use time_t for times, not long.
(unary_operator): If N is out of int range, -t N now returns false.
Diffstat (limited to 'src')
-rw-r--r-- | src/test.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/test.c b/src/test.c index 70346db92..9f7de6a9c 100644 --- a/src/test.c +++ b/src/test.c @@ -236,12 +236,12 @@ integer_expected_error (char *pch) /* Return nonzero if the characters pointed to by STRING constitute a valid number. Stuff the converted number into RESULT if RESULT is - a non-null pointer to a long. */ + not null. */ static int -isint (register char *string, long int *result) +isint (register char *string, intmax_t *result) { int sign; - long value; + intmax_t value; sign = 1; value = 0; @@ -292,10 +292,10 @@ isint (register char *string, long int *result) return (1); } -/* Find the modification time of FILE, and stuff it into AGE, a pointer - to a long. Return nonzero if successful, else zero. */ +/* Find the modification time of FILE, and stuff it into *AGE. + Return nonzero if successful, else zero. */ static int -age_of (char *filename, long int *age) +age_of (char *filename, time_t *age) { struct stat finfo; @@ -388,7 +388,9 @@ binary_operator (void) { register int op; struct stat stat_buf, stat_spare; - long int l, r, value; + intmax_t l, r; + int value; + time_t lt, rt; /* Are the left and right integer expressions of the form '-l string'? */ int l_is_l, r_is_l; @@ -521,8 +523,8 @@ binary_operator (void) pos += 3; if (l_is_l || r_is_l) test_syntax_error (_("-nt does not accept -l\n"), NULL); - if (age_of (argv[op - 1], &l) && age_of (argv[op + 1], &r)) - return (TRUE == (l > r)); + if (age_of (argv[op - 1], <) && age_of (argv[op + 1], &rt)) + return (TRUE == (lt > rt)); else return (FALSE); } @@ -594,8 +596,8 @@ binary_operator (void) pos += 3; if (l_is_l || r_is_l) test_syntax_error (_("-nt does not accept -l\n"), NULL); - if (age_of (argv[op - 1], &l) && age_of (argv[op + 1], &r)) - return (TRUE == (l < r)); + if (age_of (argv[op - 1], <) && age_of (argv[op + 1], &rt)) + return (TRUE == (lt < rt)); return (FALSE); } break; @@ -624,7 +626,8 @@ binary_operator (void) static int unary_operator (void) { - long fd, value; + intmax_t fd; + int value; struct stat stat_buf; switch (argv[pos][1]) @@ -793,7 +796,7 @@ unary_operator (void) { fd = 1; } - return (TRUE == (isatty ((int) fd))); + return (TRUE == (fd == (int) fd && isatty (fd))); case 'n': /* True if arg has some length. */ unary_advance (); |