diff options
author | ru <ru@FreeBSD.org> | 2001-08-15 14:53:55 +0000 |
---|---|---|
committer | ru <ru@FreeBSD.org> | 2001-08-15 14:53:55 +0000 |
commit | c14d208cbde9ca7e7d4a7be9aef46db162c46ff6 (patch) | |
tree | 9828b0d985eb96d81835453c8ba2eb90e959c82a /usr.bin/fmt/fmt.c | |
parent | 839c5a13326aca13093860164f18e9875972e237 (diff) | |
download | FreeBSD-src-c14d208cbde9ca7e7d4a7be9aef46db162c46ff6.zip FreeBSD-src-c14d208cbde9ca7e7d4a7be9aef46db162c46ff6.tar.gz |
The old fmt(1) always did what the new ``-l 8'' option does.
POLA: Changed the default to ``-l 8'' while still providing
a way to disable this feature with ``-l 0''.
PR: bin/29247
Reviewed by: iedowse
Diffstat (limited to 'usr.bin/fmt/fmt.c')
-rw-r--r-- | usr.bin/fmt/fmt.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/usr.bin/fmt/fmt.c b/usr.bin/fmt/fmt.c index c601c4d..a40e2fe 100644 --- a/usr.bin/fmt/fmt.c +++ b/usr.bin/fmt/fmt.c @@ -202,6 +202,15 @@ get_positive(const char *s, const char *err_mess, int fussyP) { return (size_t) result; } +static size_t +get_nonnegative(const char *s, const char *err_mess, int fussyP) { + char *t; + long result = strtol(s,&t,0); + if (*t) { if (fussyP) goto Lose; else return 0; } + if (result<0) { Lose: errx(EX_USAGE, "%s", err_mess); } + return (size_t) result; +} + /* Global variables */ static int centerP=0; /* Try to center lines? */ @@ -210,7 +219,7 @@ static size_t max_length=0; /* Maximum length for output lines */ static int coalesce_spaces_P=0; /* Coalesce multiple whitespace -> ' ' ? */ static int allow_indented_paragraphs=0; /* Can first line have diff. ind.? */ static int tab_width=8; /* Number of spaces per tab stop */ -static size_t output_tab_width=0; /* Ditto, when squashing leading spaces */ +static size_t output_tab_width=8; /* Ditto, when squashing leading spaces */ static const char *sentence_enders=".?!"; /* Double-space after these */ static int grok_mail_headers=0; /* treat embedded mail headers magically? */ @@ -258,7 +267,7 @@ main(int argc, char *argv[]) { continue; case 'l': output_tab_width - = get_positive(optarg, "output tab width must be positive", 1); + = get_nonnegative(optarg, "output tab width must be non-negative", 1); continue; case 'm': grok_mail_headers = 1; |