* Original copyright notice is retained at the end of this file.
*/
-#include "busybox.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
-#define BB_DECLARE_EXTERN
-#define bb_need_write_error
-#include "messages.c"
+#include "busybox.h"
static const int ASCII = 0377;
}
}
-static unsigned int expand(char *arg, register unsigned char *buffer)
+static unsigned int expand(const char *arg, register unsigned char *buffer)
{
unsigned char *buffer_start = buffer;
int i, ac;
static int complement(unsigned char *buffer, int buffer_len)
{
- register short i, j, index;
+ register short i, j, ix;
char conv[ASCII + 2];
- index = 0;
+ ix = 0;
for (i = 0; i <= ASCII; i++) {
for (j = 0; j < buffer_len; j++)
if (buffer[j] == i)
break;
if (j == buffer_len)
- conv[index++] = i & ASCII;
+ conv[ix++] = i & ASCII;
}
- memcpy(buffer, conv, index);
- return index;
+ memcpy(buffer, conv, ix);
+ return ix;
}
extern int tr_main(int argc, char **argv)
{
register unsigned char *ptr;
int output_length=0, input_length;
- int index = 1;
+ int idx = 1;
int i;
RESERVE_BB_BUFFER(output, BUFSIZ);
RESERVE_BB_BUFFER(input, BUFSIZ);
pinvec = invec;
poutvec = outvec;
- if (argc > 1 && argv[index][0] == '-') {
- for (ptr = (unsigned char *) &argv[index][1]; *ptr; ptr++) {
+ if (argc > 1 && argv[idx][0] == '-') {
+ for (ptr = (unsigned char *) &argv[idx][1]; *ptr; ptr++) {
switch (*ptr) {
case 'c':
com_fl = TRUE;
show_usage();
}
}
- index++;
+ idx++;
}
for (i = 0; i <= ASCII; i++) {
vector[i] = i;
invec[i] = outvec[i] = FALSE;
}
- if (argv[index] != NULL) {
- input_length = expand(argv[index++], input);
+ if (argv[idx] != NULL) {
+ input_length = expand(argv[idx++], input);
if (com_fl)
input_length = complement(input, input_length);
- if (argv[index] != NULL) {
- if (*argv[index] == '\0')
+ if (argv[idx] != NULL) {
+ if (*argv[idx] == '\0')
error_msg_and_die("STRING2 cannot be empty");
- output_length = expand(argv[index], output);
+ output_length = expand(argv[idx], output);
map(input, input_length, output, output_length);
}
for (i = 0; i < input_length; i++)