diff options
| author | Glenn L McGrath <bug1@ihug.co.nz> | 2004-08-11 02:45:47 +0000 |
|---|---|---|
| committer | Glenn L McGrath <bug1@ihug.co.nz> | 2004-08-11 02:45:47 +0000 |
| commit | 73db8be80a2bca50e0d29a162f5d431f70e227c8 (patch) | |
| tree | 974bb226421e4baecba178833433ba9cb13b0bdc /coreutils | |
| parent | d2c6f9a1f9d5974155f1a7224aecbafba91631a1 (diff) | |
| download | busybox-w32-73db8be80a2bca50e0d29a162f5d431f70e227c8.tar.gz busybox-w32-73db8be80a2bca50e0d29a162f5d431f70e227c8.tar.bz2 busybox-w32-73db8be80a2bca50e0d29a162f5d431f70e227c8.zip | |
Patch from Bastian Blank to add 64 bit support to the test command.
Example of broken usage: ./busybox test 2147483648 -gt 2147483648
Diffstat (limited to 'coreutils')
| -rw-r--r-- | coreutils/Config.in | 7 | ||||
| -rw-r--r-- | coreutils/test.c | 42 |
2 files changed, 35 insertions, 14 deletions
diff --git a/coreutils/Config.in b/coreutils/Config.in index c995e55ff..e1f0516fd 100644 --- a/coreutils/Config.in +++ b/coreutils/Config.in | |||
| @@ -455,6 +455,13 @@ if !CONFIG_ASH && !CONFIG_HUSH && !CONFIG_LASH && !CONFIG_MSH | |||
| 455 | and bash) have test builtin. | 455 | and bash) have test builtin. |
| 456 | endif | 456 | endif |
| 457 | 457 | ||
| 458 | config CONFIG_FEATURE_TEST_64 | ||
| 459 | bool " Extend test to 64 bit" | ||
| 460 | default n | ||
| 461 | depends on CONFIG_TEST | ||
| 462 | help | ||
| 463 | Enable 64-bit support in test. | ||
| 464 | |||
| 458 | config CONFIG_TOUCH | 465 | config CONFIG_TOUCH |
| 459 | bool "touch" | 466 | bool "touch" |
| 460 | default n | 467 | default n |
diff --git a/coreutils/test.c b/coreutils/test.c index 419da5101..8fa6d166f 100644 --- a/coreutils/test.c +++ b/coreutils/test.c | |||
| @@ -155,19 +155,25 @@ static const struct t_op { | |||
| 155 | 0, 0, 0} | 155 | 0, 0, 0} |
| 156 | }; | 156 | }; |
| 157 | 157 | ||
| 158 | #ifdef CONFIG_FEATURE_TEST_64 | ||
| 159 | typedef int64_t arith_t; | ||
| 160 | #else | ||
| 161 | typedef int arith_t; | ||
| 162 | #endif | ||
| 163 | |||
| 158 | static char **t_wp; | 164 | static char **t_wp; |
| 159 | static struct t_op const *t_wp_op; | 165 | static struct t_op const *t_wp_op; |
| 160 | static gid_t *group_array = NULL; | 166 | static gid_t *group_array = NULL; |
| 161 | static int ngroups; | 167 | static int ngroups; |
| 162 | 168 | ||
| 163 | static enum token t_lex(char *s); | 169 | static enum token t_lex(char *s); |
| 164 | static int oexpr(enum token n); | 170 | static arith_t oexpr(enum token n); |
| 165 | static int aexpr(enum token n); | 171 | static arith_t aexpr(enum token n); |
| 166 | static int nexpr(enum token n); | 172 | static arith_t nexpr(enum token n); |
| 167 | static int binop(void); | 173 | static int binop(void); |
| 168 | static int primary(enum token n); | 174 | static arith_t primary(enum token n); |
| 169 | static int filstat(char *nm, enum token mode); | 175 | static int filstat(char *nm, enum token mode); |
| 170 | static int getn(const char *s); | 176 | static arith_t getn(const char *s); |
| 171 | static int newerf(const char *f1, const char *f2); | 177 | static int newerf(const char *f1, const char *f2); |
| 172 | static int olderf(const char *f1, const char *f2); | 178 | static int olderf(const char *f1, const char *f2); |
| 173 | static int equalf(const char *f1, const char *f2); | 179 | static int equalf(const char *f1, const char *f2); |
| @@ -232,9 +238,9 @@ static void syntax(const char *op, const char *msg) | |||
| 232 | } | 238 | } |
| 233 | } | 239 | } |
| 234 | 240 | ||
| 235 | static int oexpr(enum token n) | 241 | static arith_t oexpr(enum token n) |
| 236 | { | 242 | { |
| 237 | int res; | 243 | arith_t res; |
| 238 | 244 | ||
| 239 | res = aexpr(n); | 245 | res = aexpr(n); |
| 240 | if (t_lex(*++t_wp) == BOR) { | 246 | if (t_lex(*++t_wp) == BOR) { |
| @@ -244,9 +250,9 @@ static int oexpr(enum token n) | |||
| 244 | return res; | 250 | return res; |
| 245 | } | 251 | } |
| 246 | 252 | ||
| 247 | static int aexpr(enum token n) | 253 | static arith_t aexpr(enum token n) |
| 248 | { | 254 | { |
| 249 | int res; | 255 | arith_t res; |
| 250 | 256 | ||
| 251 | res = nexpr(n); | 257 | res = nexpr(n); |
| 252 | if (t_lex(*++t_wp) == BAND) | 258 | if (t_lex(*++t_wp) == BAND) |
| @@ -255,16 +261,16 @@ static int aexpr(enum token n) | |||
| 255 | return res; | 261 | return res; |
| 256 | } | 262 | } |
| 257 | 263 | ||
| 258 | static int nexpr(enum token n) | 264 | static arith_t nexpr(enum token n) |
| 259 | { | 265 | { |
| 260 | if (n == UNOT) | 266 | if (n == UNOT) |
| 261 | return !nexpr(t_lex(*++t_wp)); | 267 | return !nexpr(t_lex(*++t_wp)); |
| 262 | return primary(n); | 268 | return primary(n); |
| 263 | } | 269 | } |
| 264 | 270 | ||
| 265 | static int primary(enum token n) | 271 | static arith_t primary(enum token n) |
| 266 | { | 272 | { |
| 267 | int res; | 273 | arith_t res; |
| 268 | 274 | ||
| 269 | if (n == EOI) { | 275 | if (n == EOI) { |
| 270 | syntax(NULL, "argument expected"); | 276 | syntax(NULL, "argument expected"); |
| @@ -441,13 +447,21 @@ static enum token t_lex(char *s) | |||
| 441 | } | 447 | } |
| 442 | 448 | ||
| 443 | /* atoi with error detection */ | 449 | /* atoi with error detection */ |
| 444 | static int getn(const char *s) | 450 | static arith_t getn(const char *s) |
| 445 | { | 451 | { |
| 446 | char *p; | 452 | char *p; |
| 453 | #ifdef CONFIG_FEATURE_TEST_64 | ||
| 454 | long long r; | ||
| 455 | #else | ||
| 447 | long r; | 456 | long r; |
| 457 | #endif | ||
| 448 | 458 | ||
| 449 | errno = 0; | 459 | errno = 0; |
| 460 | #ifdef CONFIG_FEATURE_TEST_64 | ||
| 461 | r = strtoll(s, &p, 10); | ||
| 462 | #else | ||
| 450 | r = strtol(s, &p, 10); | 463 | r = strtol(s, &p, 10); |
| 464 | #endif | ||
| 451 | 465 | ||
| 452 | if (errno != 0) | 466 | if (errno != 0) |
| 453 | bb_error_msg_and_die("%s: out of range", s); | 467 | bb_error_msg_and_die("%s: out of range", s); |
| @@ -456,7 +470,7 @@ static int getn(const char *s) | |||
| 456 | if (*(bb_skip_whitespace(p))) | 470 | if (*(bb_skip_whitespace(p))) |
| 457 | bb_error_msg_and_die("%s: bad number", s); | 471 | bb_error_msg_and_die("%s: bad number", s); |
| 458 | 472 | ||
| 459 | return (int) r; | 473 | return r; |
| 460 | } | 474 | } |
| 461 | 475 | ||
| 462 | static int newerf(const char *f1, const char *f2) | 476 | static int newerf(const char *f1, const char *f2) |
