aboutsummaryrefslogtreecommitdiff
path: root/tr.c
diff options
context:
space:
mode:
authorerik <erik@69ca8d6d-28ef-0310-b511-8ec308f3f277>2000-05-19 05:35:19 +0000
committererik <erik@69ca8d6d-28ef-0310-b511-8ec308f3f277>2000-05-19 05:35:19 +0000
commit8d4f3abad4f931a843696cb73a50929b7ed636c0 (patch)
treeaa360774a903d3ebb0b2b5f3031c2e359f9c3afb /tr.c
parent3568776688d5969d409882839378da3659af5d1a (diff)
downloadbusybox-w32-8d4f3abad4f931a843696cb73a50929b7ed636c0.tar.gz
busybox-w32-8d4f3abad4f931a843696cb73a50929b7ed636c0.tar.bz2
busybox-w32-8d4f3abad4f931a843696cb73a50929b7ed636c0.zip
More libc portability updates, add in the website (which has not been
archived previously). Wrote 'which' during the meeting today. -Erik git-svn-id: svn://busybox.net/trunk/busybox@558 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'tr.c')
-rw-r--r--tr.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/tr.c b/tr.c
index ebb64799f..3e7ba583c 100644
--- a/tr.c
+++ b/tr.c
@@ -30,6 +30,20 @@
30#include <stdlib.h> 30#include <stdlib.h>
31#include <unistd.h> 31#include <unistd.h>
32#include <sys/types.h> 32#include <sys/types.h>
33#define BB_DECLARE_EXTERN
34#define bb_need_write_error
35#include "messages.c"
36
37const char *tr_usage="tr [-cds] STRING1 [STRING2]\n"
38#ifndef BB_FEATURE_TRIVIAL_HELP
39 "\nTranslate, squeeze, and/or delete characters from\n"
40 "standard input, writing to standard output.\n\n"
41 "Options:\n"
42 "\t-c\ttake complement of STRING1\n"
43 "\t-d\tdelete input characters coded STRING1\n"
44 "\t-s\tsqueeze multiple output characters of STRING2 into one character\n"
45#endif
46;
33 47
34 48
35 49
@@ -60,7 +74,7 @@ static void convert()
60 if (in_index == read_chars) { 74 if (in_index == read_chars) {
61 if ((read_chars = read(0, (char *) input, BUFSIZ)) <= 0) { 75 if ((read_chars = read(0, (char *) input, BUFSIZ)) <= 0) {
62 if (write(1, (char *) output, out_index) != out_index) 76 if (write(1, (char *) output, out_index) != out_index)
63 write(2, "Bad write\n", 10); 77 write(2, write_error, strlen(write_error));
64 exit(0); 78 exit(0);
65 } 79 }
66 in_index = 0; 80 in_index = 0;
@@ -74,7 +88,7 @@ static void convert()
74 output[out_index++] = last = coded; 88 output[out_index++] = last = coded;
75 if (out_index == BUFSIZ) { 89 if (out_index == BUFSIZ) {
76 if (write(1, (char *) output, out_index) != out_index) { 90 if (write(1, (char *) output, out_index) != out_index) {
77 write(2, "Bad write\n", 10); 91 write(2, write_error, strlen(write_error));
78 exit(1); 92 exit(1);
79 } 93 }
80 out_index = 0; 94 out_index = 0;
@@ -167,16 +181,7 @@ extern int tr_main(int argc, char **argv)
167 sq_fl = TRUE; 181 sq_fl = TRUE;
168 break; 182 break;
169 default: 183 default:
170 usage("tr [-cds] STRING1 [STRING2]\n" 184 usage(tr_usage);
171#ifndef BB_FEATURE_TRIVIAL_HELP
172 "\nTranslate, squeeze, and/or delete characters from\n"
173 "standard input, writing to standard output.\n\n"
174 "Options:\n"
175 "\t-c\ttake complement of STRING1\n"
176 "\t-d\tdelete input characters coded STRING1\n"
177 "\t-s\tsqueeze multiple output characters of STRING2 into one character\n"
178#endif
179 );
180 } 185 }
181 } 186 }
182 index++; 187 index++;