From: Jim Meyering Date: Sat, 18 Aug 2001 17:45:31 +0000 (+0000) Subject: (isint, binary_operator, unary_operator): X-Git-Tag: TEXTUTILS-2_0_15~371 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=1c9af0041d765e7a8e63704ead2abeaf39392ae9;p=thirdparty%2Fcoreutils.git (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. --- diff --git a/src/test.c b/src/test.c index 70346db923..9f7de6a9c5 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 ();