From 330fd2b5767110f29544131d4c72c77e0506b6df Mon Sep 17 00:00:00 2001 From: Erik Andersen Date: Fri, 19 May 2000 05:35:19 +0000 Subject: More libc portability updates, add in the website (which has not been archived previously). Wrote 'which' during the meeting today. -Erik --- coreutils/tr.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'coreutils/tr.c') diff --git a/coreutils/tr.c b/coreutils/tr.c index ebb64799f..3e7ba583c 100644 --- a/coreutils/tr.c +++ b/coreutils/tr.c @@ -30,6 +30,20 @@ #include #include #include +#define BB_DECLARE_EXTERN +#define bb_need_write_error +#include "messages.c" + +const char *tr_usage="tr [-cds] STRING1 [STRING2]\n" +#ifndef BB_FEATURE_TRIVIAL_HELP + "\nTranslate, squeeze, and/or delete characters from\n" + "standard input, writing to standard output.\n\n" + "Options:\n" + "\t-c\ttake complement of STRING1\n" + "\t-d\tdelete input characters coded STRING1\n" + "\t-s\tsqueeze multiple output characters of STRING2 into one character\n" +#endif +; @@ -60,7 +74,7 @@ static void convert() if (in_index == read_chars) { if ((read_chars = read(0, (char *) input, BUFSIZ)) <= 0) { if (write(1, (char *) output, out_index) != out_index) - write(2, "Bad write\n", 10); + write(2, write_error, strlen(write_error)); exit(0); } in_index = 0; @@ -74,7 +88,7 @@ static void convert() output[out_index++] = last = coded; if (out_index == BUFSIZ) { if (write(1, (char *) output, out_index) != out_index) { - write(2, "Bad write\n", 10); + write(2, write_error, strlen(write_error)); exit(1); } out_index = 0; @@ -167,16 +181,7 @@ extern int tr_main(int argc, char **argv) sq_fl = TRUE; break; default: - usage("tr [-cds] STRING1 [STRING2]\n" -#ifndef BB_FEATURE_TRIVIAL_HELP - "\nTranslate, squeeze, and/or delete characters from\n" - "standard input, writing to standard output.\n\n" - "Options:\n" - "\t-c\ttake complement of STRING1\n" - "\t-d\tdelete input characters coded STRING1\n" - "\t-s\tsqueeze multiple output characters of STRING2 into one character\n" -#endif - ); + usage(tr_usage); } } index++; -- cgit v1.2.3