diff options
Diffstat (limited to 'tr.c')
-rw-r--r-- | tr.c | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -54,7 +54,7 @@ static void convert() | |||
54 | if (in_index == read_chars) { | 54 | if (in_index == read_chars) { |
55 | if ((read_chars = read(0, (char *) pinput, BUFSIZ)) <= 0) { | 55 | if ((read_chars = read(0, (char *) pinput, BUFSIZ)) <= 0) { |
56 | if (write(1, (char *) poutput, out_index) != out_index) | 56 | if (write(1, (char *) poutput, out_index) != out_index) |
57 | write(2, write_error, strlen(write_error)); | 57 | error_msg("%s", write_error); |
58 | exit(0); | 58 | exit(0); |
59 | } | 59 | } |
60 | in_index = 0; | 60 | in_index = 0; |
@@ -67,10 +67,8 @@ static void convert() | |||
67 | continue; | 67 | continue; |
68 | poutput[out_index++] = last = coded; | 68 | poutput[out_index++] = last = coded; |
69 | if (out_index == BUFSIZ) { | 69 | if (out_index == BUFSIZ) { |
70 | if (write(1, (char *) poutput, out_index) != out_index) { | 70 | if (write(1, (char *) poutput, out_index) != out_index) |
71 | write(2, write_error, strlen(write_error)); | 71 | error_msg_and_die("%s", write_error); |
72 | exit(1); | ||
73 | } | ||
74 | out_index = 0; | 72 | out_index = 0; |
75 | } | 73 | } |
76 | } | 74 | } |
@@ -105,6 +103,16 @@ static unsigned int expand(const char *arg, register unsigned char *buffer) | |||
105 | if (*arg == '\\') { | 103 | if (*arg == '\\') { |
106 | arg++; | 104 | arg++; |
107 | *buffer++ = process_escape_sequence(&arg); | 105 | *buffer++ = process_escape_sequence(&arg); |
106 | } else if (*(arg+1) == '-') { | ||
107 | ac = *(arg+2); | ||
108 | if(ac == 0) { | ||
109 | *buffer++ = *arg++; | ||
110 | continue; | ||
111 | } | ||
112 | i = *arg; | ||
113 | while (i <= ac) | ||
114 | *buffer++ = i++; | ||
115 | arg += 3; /* Skip the assumed a-z */ | ||
108 | } else if (*arg == '[') { | 116 | } else if (*arg == '[') { |
109 | arg++; | 117 | arg++; |
110 | i = *arg++; | 118 | i = *arg++; |