Mercurial > hg > toybox
annotate toys/posix/wc.c @ 719:053061a0b5b6
The previous wc -m didn't handle multibyte characters that crossed a buffer boundary, so take a guess at making that work. (I haven't got a test case for this. I also don't know how to handle invalid sequences so just don't count them.)
author | Rob Landley <rob@landley.net> |
---|---|
date | Wed, 28 Nov 2012 03:12:02 -0600 |
parents | a950dd960593 |
children | 9499e4cf830f |
rev | line source |
---|---|
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
1 /* wc.c - Word count |
386 | 2 * |
387
67b0ded3c56c
Add dirname, and typo fixes to wc header.
Rob Landley <rob@landley.net>
parents:
386
diff
changeset
|
3 * Copyright 2011 Rob Landley <rob@landley.net> |
386 | 4 * |
5 * See http://opengroup.org/onlinepubs/9699919799/utilities/wc.html | |
6 | |
712
a950dd960593
Cleanup i18n support (#ifdefectomy, move global init to process launch). Teach make.sh to emit "#define FLAG_x 0" for options inside disabled USE macros so we can unconditionally refer to them.
Rob Landley <rob@landley.net>
parents:
710
diff
changeset
|
7 USE_WC(NEWTOY(wc, USE_TOYBOX_I18N("m")"cwl", TOYFLAG_USR|TOYFLAG_BIN)) |
386 | 8 |
9 config WC | |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
10 bool "wc" |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
11 default y |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
12 help |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
13 usage: wc -lwcm [FILE...] |
386 | 14 |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
15 Count lines, words, and characters in input. |
386 | 16 |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
17 -l show lines |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
18 -w show words |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
19 -c show bytes |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
20 -m show characters |
386 | 21 |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
22 By default outputs lines, words, bytes, and filename for each |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
23 argument (or from stdin if none). Displays only either bytes |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
24 or characters. |
386 | 25 */ |
26 | |
674
7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents:
662
diff
changeset
|
27 #define FOR_wc |
386 | 28 #include "toys.h" |
29 | |
674
7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents:
662
diff
changeset
|
30 GLOBALS( |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
31 unsigned long totals[3]; |
662
5cb41d56f9d3
Posix compliance: wc shouldn't have trailing spaces (breaks aboriginal's mkinitr
Rob Landley <rob@landley.net>
parents:
653
diff
changeset
|
32 ) |
5cb41d56f9d3
Posix compliance: wc shouldn't have trailing spaces (breaks aboriginal's mkinitr
Rob Landley <rob@landley.net>
parents:
653
diff
changeset
|
33 |
5cb41d56f9d3
Posix compliance: wc shouldn't have trailing spaces (breaks aboriginal's mkinitr
Rob Landley <rob@landley.net>
parents:
653
diff
changeset
|
34 static void show_lengths(unsigned long *lengths, char *name) |
5cb41d56f9d3
Posix compliance: wc shouldn't have trailing spaces (breaks aboriginal's mkinitr
Rob Landley <rob@landley.net>
parents:
653
diff
changeset
|
35 { |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
36 int i, nospace = 1; |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
37 for (i=0; i<3; i++) { |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
38 if (!toys.optflags || (toys.optflags&(1<<i))) { |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
39 xprintf(" %ld"+nospace, lengths[i]); |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
40 nospace = 0; |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
41 } |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
42 TT.totals[i] += lengths[i]; |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
43 } |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
44 if (*toys.optargs) xprintf(" %s", name); |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
45 xputc('\n'); |
662
5cb41d56f9d3
Posix compliance: wc shouldn't have trailing spaces (breaks aboriginal's mkinitr
Rob Landley <rob@landley.net>
parents:
653
diff
changeset
|
46 } |
5cb41d56f9d3
Posix compliance: wc shouldn't have trailing spaces (breaks aboriginal's mkinitr
Rob Landley <rob@landley.net>
parents:
653
diff
changeset
|
47 |
386 | 48 static void do_wc(int fd, char *name) |
49 { | |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
50 int i, len, clen=1, space; |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
51 unsigned long word=0, lengths[]={0,0,0}; |
386 | 52 |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
53 for (;;) { |
719
053061a0b5b6
The previous wc -m didn't handle multibyte characters that crossed a buffer boundary, so take a guess at making that work. (I haven't got a test case for this. I also don't know how to handle invalid sequences so just don't count them.)
Rob Landley <rob@landley.net>
parents:
712
diff
changeset
|
54 i = 0; |
053061a0b5b6
The previous wc -m didn't handle multibyte characters that crossed a buffer boundary, so take a guess at making that work. (I haven't got a test case for this. I also don't know how to handle invalid sequences so just don't count them.)
Rob Landley <rob@landley.net>
parents:
712
diff
changeset
|
55 again: |
053061a0b5b6
The previous wc -m didn't handle multibyte characters that crossed a buffer boundary, so take a guess at making that work. (I haven't got a test case for this. I also don't know how to handle invalid sequences so just don't count them.)
Rob Landley <rob@landley.net>
parents:
712
diff
changeset
|
56 len = i+read(fd, toybuf+i, sizeof(toybuf)-i); |
053061a0b5b6
The previous wc -m didn't handle multibyte characters that crossed a buffer boundary, so take a guess at making that work. (I haven't got a test case for this. I also don't know how to handle invalid sequences so just don't count them.)
Rob Landley <rob@landley.net>
parents:
712
diff
changeset
|
57 if (len < i) { |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
58 perror_msg("%s",name); |
719
053061a0b5b6
The previous wc -m didn't handle multibyte characters that crossed a buffer boundary, so take a guess at making that work. (I haven't got a test case for this. I also don't know how to handle invalid sequences so just don't count them.)
Rob Landley <rob@landley.net>
parents:
712
diff
changeset
|
59 toys.exitval = 1; |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
60 } |
719
053061a0b5b6
The previous wc -m didn't handle multibyte characters that crossed a buffer boundary, so take a guess at making that work. (I haven't got a test case for this. I also don't know how to handle invalid sequences so just don't count them.)
Rob Landley <rob@landley.net>
parents:
712
diff
changeset
|
61 if (!len) break; |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
62 for (i=0; i<len; i+=clen) { |
712
a950dd960593
Cleanup i18n support (#ifdefectomy, move global init to process launch). Teach make.sh to emit "#define FLAG_x 0" for options inside disabled USE macros so we can unconditionally refer to them.
Rob Landley <rob@landley.net>
parents:
710
diff
changeset
|
63 if (CFG_TOYBOX_I18N && (toys.optflags&FLAG_m)) { |
719
053061a0b5b6
The previous wc -m didn't handle multibyte characters that crossed a buffer boundary, so take a guess at making that work. (I haven't got a test case for this. I also don't know how to handle invalid sequences so just don't count them.)
Rob Landley <rob@landley.net>
parents:
712
diff
changeset
|
64 wchar_t wchar = 0; |
053061a0b5b6
The previous wc -m didn't handle multibyte characters that crossed a buffer boundary, so take a guess at making that work. (I haven't got a test case for this. I also don't know how to handle invalid sequences so just don't count them.)
Rob Landley <rob@landley.net>
parents:
712
diff
changeset
|
65 |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
66 clen = mbrtowc(&wchar, toybuf+i, len-i, 0); |
719
053061a0b5b6
The previous wc -m didn't handle multibyte characters that crossed a buffer boundary, so take a guess at making that work. (I haven't got a test case for this. I also don't know how to handle invalid sequences so just don't count them.)
Rob Landley <rob@landley.net>
parents:
712
diff
changeset
|
67 if (clen < 1) { |
053061a0b5b6
The previous wc -m didn't handle multibyte characters that crossed a buffer boundary, so take a guess at making that work. (I haven't got a test case for this. I also don't know how to handle invalid sequences so just don't count them.)
Rob Landley <rob@landley.net>
parents:
712
diff
changeset
|
68 // If the problem might be buffer wrap, move and read more data |
053061a0b5b6
The previous wc -m didn't handle multibyte characters that crossed a buffer boundary, so take a guess at making that work. (I haven't got a test case for this. I also don't know how to handle invalid sequences so just don't count them.)
Rob Landley <rob@landley.net>
parents:
712
diff
changeset
|
69 if (i) { |
053061a0b5b6
The previous wc -m didn't handle multibyte characters that crossed a buffer boundary, so take a guess at making that work. (I haven't got a test case for this. I also don't know how to handle invalid sequences so just don't count them.)
Rob Landley <rob@landley.net>
parents:
712
diff
changeset
|
70 memmove(toybuf, toybuf+i, sizeof(toybuf)-i); |
053061a0b5b6
The previous wc -m didn't handle multibyte characters that crossed a buffer boundary, so take a guess at making that work. (I haven't got a test case for this. I also don't know how to handle invalid sequences so just don't count them.)
Rob Landley <rob@landley.net>
parents:
712
diff
changeset
|
71 i = len - i; |
053061a0b5b6
The previous wc -m didn't handle multibyte characters that crossed a buffer boundary, so take a guess at making that work. (I haven't got a test case for this. I also don't know how to handle invalid sequences so just don't count them.)
Rob Landley <rob@landley.net>
parents:
712
diff
changeset
|
72 goto again; |
053061a0b5b6
The previous wc -m didn't handle multibyte characters that crossed a buffer boundary, so take a guess at making that work. (I haven't got a test case for this. I also don't know how to handle invalid sequences so just don't count them.)
Rob Landley <rob@landley.net>
parents:
712
diff
changeset
|
73 } else { |
053061a0b5b6
The previous wc -m didn't handle multibyte characters that crossed a buffer boundary, so take a guess at making that work. (I haven't got a test case for this. I also don't know how to handle invalid sequences so just don't count them.)
Rob Landley <rob@landley.net>
parents:
712
diff
changeset
|
74 clen=1; |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
75 continue; |
719
053061a0b5b6
The previous wc -m didn't handle multibyte characters that crossed a buffer boundary, so take a guess at making that work. (I haven't got a test case for this. I also don't know how to handle invalid sequences so just don't count them.)
Rob Landley <rob@landley.net>
parents:
712
diff
changeset
|
76 } |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
77 } |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
78 space = iswspace(wchar); |
712
a950dd960593
Cleanup i18n support (#ifdefectomy, move global init to process launch). Teach make.sh to emit "#define FLAG_x 0" for options inside disabled USE macros so we can unconditionally refer to them.
Rob Landley <rob@landley.net>
parents:
710
diff
changeset
|
79 } else space = isspace(toybuf[i]); |
686
9414be56b1db
wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents:
674
diff
changeset
|
80 |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
81 if (toybuf[i]==10) lengths[0]++; |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
82 if (space) word=0; |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
83 else { |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
84 if (!word) lengths[1]++; |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
85 word=1; |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
86 } |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
87 lengths[2]++; |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
88 } |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
89 } |
662
5cb41d56f9d3
Posix compliance: wc shouldn't have trailing spaces (breaks aboriginal's mkinitr
Rob Landley <rob@landley.net>
parents:
653
diff
changeset
|
90 |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
91 show_lengths(lengths, name); |
386 | 92 } |
93 | |
94 void wc_main(void) | |
95 { | |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
96 toys.optflags |= (toys.optflags&8)>>1; |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
97 loopfiles(toys.optargs, do_wc); |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
686
diff
changeset
|
98 if (toys.optc>1) show_lengths(TT.totals, "total"); |
386 | 99 } |