Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 Aug 1999 22:42:13 -0400 (EDT)
From:      James Howard <howardjp@wam.umd.edu>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/13364: Patch to wc(1) for Unix 98 compliance.
Message-ID:  <199908250242.WAA07663@rac9.wam.umd.edu>

next in thread | raw e-mail | index | archive | help

>Number:         13364
>Category:       bin
>Synopsis:       Patch to wc(1) for Unix 98 compliance.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Aug 24 19:50:01 PDT 1999
>Closed-Date:
>Last-Modified:
>Originator:     James Howard
>Release:        FreeBSD 3.2-STABLE i386
>Organization:
University of Maryland
>Environment:

FreeBSD byzantine 3.2-STABLE FreeBSD 3.2-STABLE #5: Sat Aug  7 23:43:54 GMT 1999     root@byzantine:/usr/src/sys/compile/BYZANTINE  i386

>Description:

Unix 98 requires wc(1) to accept a -m argument.  -m makes wc print out
the number of characters in file in place of the bytes (-c).  This is 
for systems (like DOS) which use two characters for a newline.  Under
FreeBSD and other Unices, this will simply be a synonym for -c.  This
diff will add a -m to wc (which falls through to the -c code) and a 
comment explaing why it is there.  The man page is also updated.

>How-To-Repeat:

wc -m gives an illegal option error

>Fix:

diff -c /usr/src/usr.bin/wc/wc.1 /usr/local/src/wc/wc.1
*** /usr/src/usr.bin/wc/wc.1	Mon Aug 25 06:44:58 1997
--- /usr/local/src/wc/wc.1	Tue Aug 24 16:26:35 1999
***************
*** 40,49 ****
  .Os
  .Sh NAME
  .Nm wc
! .Nd word, line, and byte count
  .Sh SYNOPSIS
  .Nm wc
! .Op Fl clw
  .Op Ar
  .Sh DESCRIPTION
  The
--- 40,49 ----
  .Os
  .Sh NAME
  .Nm wc
! .Nd word, line, byte, and character count
  .Sh SYNOPSIS
  .Nm wc
! .Op Fl clmw
  .Op Ar
  .Sh DESCRIPTION
  The
***************
*** 71,76 ****
--- 71,79 ----
  .It Fl l
  The number of lines in each input file
  is written to the standard output.
+ .It Fl m
+ The number of characters in each input file
+ is written to the standard output.
  .It Fl w
  The number of words in each input file
  is written to the standard output.
***************
*** 80,85 ****
--- 83,93 ----
  .Nm
  only reports the information requested by that option.
  The default action is equivalent to specifying all of the flags.
+ If 
+ .Fl c 
+ and 
+ .Fl m
+ are both specified, the information is given only once.
  .Pp
  If no files are specified, the standard input is used and no
  file name is displayed.
diff -c /usr/src/usr.bin/wc/wc.c /usr/local/src/wc/wc.c
*** /usr/src/usr.bin/wc/wc.c	Mon Aug 25 06:44:59 1997
--- /usr/local/src/wc/wc.c	Tue Aug 24 16:03:02 1999
***************
*** 74,80 ****
  
  	(void) setlocale(LC_CTYPE, "");
  
! 	while ((ch = getopt(argc, argv, "lwc")) != -1)
  		switch((char)ch) {
  		case 'l':
  			doline = 1;
--- 74,80 ----
  
  	(void) setlocale(LC_CTYPE, "");
  
! 	while ((ch = getopt(argc, argv, "lwmc")) != -1)
  		switch((char)ch) {
  		case 'l':
  			doline = 1;
***************
*** 82,87 ****
--- 82,97 ----
  		case 'w':
  			doword = 1;
  			break;
+ 		case 'm':
+ 			/*
+ 			 * Unix 98 demands that wc accept a -m argument
+ 			 * which counts the number of characters in
+ 			 * a file.  This is for systems which might 
+ 			 * have a two byte newline or other strange 
+ 			 * characters.  Under FreeBSD, this will be 
+ 			 * identical to -c.
+ 			 */
+ 			/* FALLTHROUGH */
  		case 'c':
  			dochar = 1;
  			break;
***************
*** 236,241 ****
  void
  usage()
  {
! 	(void)fprintf(stderr, "usage: wc [-clw] [file ...]\n");
  	exit(1);
  }
--- 246,251 ----
  void
  usage()
  {
! 	(void)fprintf(stderr, "usage: wc [-clmw] [file ...]\n");
  	exit(1);
  }

>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199908250242.WAA07663>