#include <sys/types.h>
#include "busybox.h"
-static const int ASCII = 0377;
+/* This must be a #define, since when DODEBUG and BUFFERS_GO_IN_BSS are
+ * enabled, we otherwise get a "storage size isn't constant error. */
+#define ASCII 0377
/* some "globals" shared across this file */
static char com_fl, del_fl, sq_fl;
static char *pinvec, *poutvec;
-static void convert()
+static void convert(void)
{
short read_chars = 0;
short c, coded;
if (in_index == read_chars) {
if ((read_chars = read(0, (char *) pinput, BUFSIZ)) <= 0) {
if (write(1, (char *) poutput, out_index) != out_index)
- write(2, write_error, strlen(write_error));
+ error_msg("%s", write_error);
exit(0);
}
in_index = 0;
continue;
poutput[out_index++] = last = coded;
if (out_index == BUFSIZ) {
- if (write(1, (char *) poutput, out_index) != out_index) {
- write(2, write_error, strlen(write_error));
- exit(1);
- }
+ if (write(1, (char *) poutput, out_index) != out_index)
+ error_msg_and_die("%s", write_error);
out_index = 0;
}
}
if (*arg == '\\') {
arg++;
*buffer++ = process_escape_sequence(&arg);
+ } else if (*(arg+1) == '-') {
+ ac = *(arg+2);
+ if(ac == 0) {
+ *buffer++ = *arg++;
+ continue;
+ }
+ i = *arg;
+ while (i <= ac)
+ *buffer++ = i++;
+ arg += 3; /* Skip the assumed a-z */
} else if (*arg == '[') {
arg++;
i = *arg++;
int output_length=0, input_length;
int idx = 1;
int i;
- RESERVE_BB_BUFFER(output, BUFSIZ);
- RESERVE_BB_BUFFER(input, BUFSIZ);
- RESERVE_BB_UBUFFER(vector, ASCII+1);
- RESERVE_BB_BUFFER(invec, ASCII+1);
- RESERVE_BB_BUFFER(outvec, ASCII+1);
+ RESERVE_CONFIG_BUFFER(output, BUFSIZ);
+ RESERVE_CONFIG_BUFFER(input, BUFSIZ);
+ RESERVE_CONFIG_UBUFFER(vector, ASCII+1);
+ RESERVE_CONFIG_BUFFER(invec, ASCII+1);
+ RESERVE_CONFIG_BUFFER(outvec, ASCII+1);
/* ... but make them available globally */
poutput = output;