diff options
| author | landley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-06-30 19:04:09 +0000 |
|---|---|---|
| committer | landley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-06-30 19:04:09 +0000 |
| commit | 37c324f41e1f80bc9fd28c817f45d66bb5864d74 (patch) | |
| tree | 94715062b854b2e24ecee457380f0b9ab9edbc46 | |
| parent | e06e7c4f17b3a6cb8086f6cb1fb895987a499f4d (diff) | |
| download | busybox-w32-37c324f41e1f80bc9fd28c817f45d66bb5864d74.tar.gz busybox-w32-37c324f41e1f80bc9fd28c817f45d66bb5864d74.tar.bz2 busybox-w32-37c324f41e1f80bc9fd28c817f45d66bb5864d74.zip | |
Make warnings go away.
git-svn-id: svn://busybox.net/trunk/busybox@15560 69ca8d6d-28ef-0310-b511-8ec308f3f277
| -rw-r--r-- | coreutils/tr.c | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/coreutils/tr.c b/coreutils/tr.c index 594962f92..32f6f5966 100644 --- a/coreutils/tr.c +++ b/coreutils/tr.c | |||
| @@ -18,14 +18,16 @@ | |||
| 18 | 18 | ||
| 19 | #include "busybox.h" | 19 | #include "busybox.h" |
| 20 | 20 | ||
| 21 | // Even with -funsigned-char, gcc still complains about char as an array index. | ||
| 22 | |||
| 23 | #define GCC4_IS_STUPID int | ||
| 24 | |||
| 21 | #define ASCII 0377 | 25 | #define ASCII 0377 |
| 22 | 26 | ||
| 23 | /* some "globals" shared across this file */ | 27 | /* some "globals" shared across this file */ |
| 24 | static char com_fl, del_fl, sq_fl; | 28 | static char com_fl, del_fl, sq_fl; |
| 25 | /* these last are pointers to static buffers declared in tr_main */ | 29 | /* these last are pointers to static buffers declared in tr_main */ |
| 26 | static unsigned char *poutput; | 30 | static char *poutput, *pvector, *pinvec, *poutvec; |
| 27 | static unsigned char *pvector; | ||
| 28 | static unsigned char *pinvec, *poutvec; | ||
| 29 | 31 | ||
| 30 | static void convert(void) | 32 | static void convert(void) |
| 31 | { | 33 | { |
| @@ -60,17 +62,17 @@ static void convert(void) | |||
| 60 | /* NOTREACHED */ | 62 | /* NOTREACHED */ |
| 61 | } | 63 | } |
| 62 | 64 | ||
| 63 | static void map(register unsigned char *string1, unsigned int string1_len, | 65 | static void map(char *string1, unsigned int string1_len, |
| 64 | register unsigned char *string2, unsigned int string2_len) | 66 | char *string2, unsigned int string2_len) |
| 65 | { | 67 | { |
| 66 | unsigned char last = '0'; | 68 | char last = '0'; |
| 67 | unsigned int i, j; | 69 | unsigned int i, j; |
| 68 | 70 | ||
| 69 | for (j = 0, i = 0; i < string1_len; i++) { | 71 | for (j = 0, i = 0; i < string1_len; i++) { |
| 70 | if (string2_len <= j) | 72 | if (string2_len <= j) |
| 71 | pvector[string1[i]] = last; | 73 | pvector[(GCC4_IS_STUPID)string1[i]] = last; |
| 72 | else | 74 | else |
| 73 | pvector[string1[i]] = last = string2[j++]; | 75 | pvector[(GCC4_IS_STUPID)string1[i]] = last = string2[j++]; |
| 74 | } | 76 | } |
| 75 | } | 77 | } |
| 76 | 78 | ||
| @@ -79,9 +81,9 @@ static void map(register unsigned char *string1, unsigned int string1_len, | |||
| 79 | * Escapes, e.g., \a ==> Control-G | 81 | * Escapes, e.g., \a ==> Control-G |
| 80 | * Character classes, e.g. [:upper:] ==> A ... Z | 82 | * Character classes, e.g. [:upper:] ==> A ... Z |
| 81 | */ | 83 | */ |
| 82 | static unsigned int expand(const char *arg, register unsigned char *buffer) | 84 | static unsigned int expand(const char *arg, char *buffer) |
| 83 | { | 85 | { |
| 84 | unsigned char *buffer_start = buffer; | 86 | char *buffer_start = buffer; |
| 85 | int i, ac; | 87 | int i, ac; |
| 86 | 88 | ||
| 87 | while (*arg) { | 89 | while (*arg) { |
| @@ -174,7 +176,7 @@ static unsigned int expand(const char *arg, register unsigned char *buffer) | |||
| 174 | return (buffer - buffer_start); | 176 | return (buffer - buffer_start); |
| 175 | } | 177 | } |
| 176 | 178 | ||
| 177 | static int complement(unsigned char *buffer, int buffer_len) | 179 | static int complement(char *buffer, int buffer_len) |
| 178 | { | 180 | { |
| 179 | register short i, j, ix; | 181 | register short i, j, ix; |
| 180 | char conv[ASCII + 2]; | 182 | char conv[ASCII + 2]; |
| @@ -203,10 +205,10 @@ int tr_main(int argc, char **argv) | |||
| 203 | RESERVE_CONFIG_BUFFER(outvec, ASCII+1); | 205 | RESERVE_CONFIG_BUFFER(outvec, ASCII+1); |
| 204 | 206 | ||
| 205 | /* ... but make them available globally */ | 207 | /* ... but make them available globally */ |
| 206 | poutput = (unsigned char*)output; | 208 | poutput = output; |
| 207 | pvector = (unsigned char*)vector; | 209 | pvector = vector; |
| 208 | pinvec = (unsigned char*)invec; | 210 | pinvec = invec; |
| 209 | poutvec = (unsigned char*)outvec; | 211 | poutvec = outvec; |
| 210 | 212 | ||
| 211 | if (argc > 1 && argv[idx][0] == '-') { | 213 | if (argc > 1 && argv[idx][0] == '-') { |
| 212 | for (ptr = (unsigned char *) &argv[idx][1]; *ptr; ptr++) { | 214 | for (ptr = (unsigned char *) &argv[idx][1]; *ptr; ptr++) { |
| @@ -238,13 +240,13 @@ int tr_main(int argc, char **argv) | |||
| 238 | if (argv[idx] != NULL) { | 240 | if (argv[idx] != NULL) { |
| 239 | if (*argv[idx] == '\0') | 241 | if (*argv[idx] == '\0') |
| 240 | bb_error_msg_and_die("STRING2 cannot be empty"); | 242 | bb_error_msg_and_die("STRING2 cannot be empty"); |
| 241 | output_length = expand(argv[idx], (unsigned char*)output); | 243 | output_length = expand(argv[idx], output); |
| 242 | map(bb_common_bufsiz1, input_length, (unsigned char*)output, output_length); | 244 | map(bb_common_bufsiz1, input_length, output, output_length); |
| 243 | } | 245 | } |
| 244 | for (i = 0; i < input_length; i++) | 246 | for (i = 0; i < input_length; i++) |
| 245 | invec[bb_common_bufsiz1[i]] = TRUE; | 247 | invec[(GCC4_IS_STUPID)bb_common_bufsiz1[i]] = TRUE; |
| 246 | for (i = 0; i < output_length; i++) | 248 | for (i = 0; i < output_length; i++) |
| 247 | outvec[(unsigned char)output[i]] = TRUE; | 249 | outvec[(GCC4_IS_STUPID)output[i]] = TRUE; |
| 248 | } | 250 | } |
| 249 | convert(); | 251 | convert(); |
| 250 | return (0); | 252 | return (0); |
