Patch from vodz to support 'tr a-z A-Z' syntax.
authorEric Andersen <andersen@codepoet.org>
Mon, 9 Jul 2001 21:32:29 +0000 (21:32 -0000)
committerEric Andersen <andersen@codepoet.org>
Mon, 9 Jul 2001 21:32:29 +0000 (21:32 -0000)
Changelog
coreutils/tr.c
tr.c

index 0a06a0a05efe51867788429d83f323ae4d23b900..90b767d818672e5c826e0528f39dd1638e1a8ef4 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -1,3 +1,19 @@
+0.53pre
+
+    Critical Bugfixes:
+       * None yet
+
+    New Applets:
+       * None yet
+
+    Other Changes:
+       * Vladimir Oleynik -- Fixed tr to support 'tr a-z A-Z' syntax.
+       
+
+        -Not Yet Released
+
+
+
 0.52
        
     Critical Bugfixes:
index a5d068262bb636488e1ed6adf7ffb70a1bc3ef3f..5b7b8d091a5952c24a69fe4627c47f8fd05d82fa 100644 (file)
@@ -54,7 +54,7 @@ static void convert()
                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;
@@ -67,10 +67,8 @@ static void convert()
                        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;
                }
        }
@@ -105,6 +103,16 @@ static unsigned int expand(const char *arg, register unsigned char *buffer)
                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++;
diff --git a/tr.c b/tr.c
index a5d068262bb636488e1ed6adf7ffb70a1bc3ef3f..5b7b8d091a5952c24a69fe4627c47f8fd05d82fa 100644 (file)
--- a/tr.c
+++ b/tr.c
@@ -54,7 +54,7 @@ static void convert()
                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;
@@ -67,10 +67,8 @@ static void convert()
                        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;
                }
        }
@@ -105,6 +103,16 @@ static unsigned int expand(const char *arg, register unsigned char *buffer)
                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++;