[ksh93-integration-discuss] Adding "-C" switch to ksh93's "wc" builtin command

Roland Mainz roland.mainz at nrubsig.org
Mon Aug 21 07:06:56 PDT 2006


Hi!

----

Attached is a small patch
("ksh93_libcmd_wc_add_C_for_multibyte001.diff.txt") which adds the "-C"
switch to ksh93/libcmd's "wc" builtin command to be fully compatible
with the Solaris /usr/bin/wc command. It would be nice if this gets
included in the next alpha version of ksh93r+ ...

----

Bye,
Roland

-- 
  __ .  . __
 (o.\ \/ /.o) roland.mainz at nrubsig.org
  \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
  /O /==\ O\  TEL +49 641 7950090
 (;O/ \/ \O;)
-------------- next part --------------
Index: src/lib/libcmd/common/wc.c
===================================================================
--- src/lib/libcmd/common/wc.c	(revision 394)
+++ src/lib/libcmd/common/wc.c	(working copy)
@@ -23,7 +23,7 @@
  * David Korn
  * AT&T Bell Laboratories
  *
- * wc [-c] [-m] [-w] [-l] [file] ...
+ * wc [-c] [-C] [-m] [-w] [-l] [file] ...
  *
  * count the number of bytes, words, and lines in a file
  */
@@ -43,14 +43,16 @@
 	"of the file name.]"
 "[+?By default, \bwc\b writes all three counts.  Options can specified "
 	"so that only certain counts are written.  The options \b-c\b "
-	"and \b-m\b are mutually exclusive.]"
+	"and \b-C\b/\b-m\b are mutually exclusive.]"
 "[+?If no \afile\a is given, or if the \afile\a is \b-\b, \bwc\b "
         "reads from standard input and no filename is written to standard "
 	"output.  The start of the file is defined as the current offset.]"
 "[l:lines?Writes the line counts.]"
 "[w:words?Writes the word counts.]"
 "[ [c:bytes|chars:chars?Writes the byte counts.]"
-"[m:multibyte-chars?Writes the character counts.] ]"
+"  [C:multibyte-chars?Writes the character counts.]"
+"  [m:multibyte-chars?Writes the character counts.]"
+" ]"
 "\n"
 "\n[file ...]\n"
 "\n"
@@ -58,7 +60,7 @@
         "[+0?All files processed successfully.]"
         "[+>0?One or more files failed to open or could not be read.]"
 "}"
-"[+SEE ALSO?\bcat\b(1), \bisspace\b(3)]"
+"[+SEE ALSO?\bcat\b(1), \bisspace\b(3), \biswspace\b(3)]"
 ;
 
 
@@ -99,14 +101,15 @@
 		mode |= WC_WORDS;
 		break;
 	case 'c':
+	case 'C':
 	case 'm':
 		if(mode&WC_CHARS)
 		{
-			if((n=='m') ^ ((mode&WC_MBYTE)!=0))
-				error(2, "c and m are mutually exclusive");
+			if(((n=='C')||(n=='m')) ^ ((mode&WC_MBYTE)!=0))
+				error(2, "c and C/m are mutually exclusive");
 		}
 		mode |= WC_CHARS;
-		if(n=='m')
+		if((n=='C')||(n=='m'))
 			mode |= WC_MBYTE;
 		break;
 	case 'l':


More information about the ksh93-integration-discuss mailing list