Implement suggestion from Adam Slattery, (don't default to killing closing bug #1190.
[oweals/busybox.git] / tr.c
diff --git a/tr.c b/tr.c
index 32a4f2917406e396e3ca5a3d88e2354bd5b4c20a..a5d068262bb636488e1ed6adf7ffb70a1bc3ef3f 100644 (file)
--- a/tr.c
+++ b/tr.c
 #include <unistd.h>
 #include <sys/types.h>
 #include "busybox.h"
-#define BB_DECLARE_EXTERN
-#define bb_need_write_error
-#include "messages.c"
 
-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 glabals shared across this file */
+/* some "globals" shared across this file */
 static char com_fl, del_fl, sq_fl;
 static short in_index, out_index;
 /* these last are pointers to static buffers declared in tr_main */
@@ -93,7 +92,11 @@ static void map(register unsigned char *string1, unsigned int string1_len,
        }
 }
 
-static unsigned int expand(char *arg, register unsigned char *buffer)
+/* supported constructs:
+ *   Ranges,  e.g.,  [0-9]  ==>  0123456789
+ *   Escapes, e.g.,  \a     ==>  Control-G
+ */
+static unsigned int expand(const char *arg, register unsigned char *buffer)
 {
        unsigned char *buffer_start = buffer;
        int i, ac;
@@ -113,7 +116,7 @@ static unsigned int expand(char *arg, register unsigned char *buffer)
                        ac = *arg++;
                        while (i <= ac)
                                *buffer++ = i++;
-                       arg++;                          /* Skip ']' */
+                       arg++;                          /* Skip the assumed ']' */
                } else
                        *buffer++ = *arg++;
        }