Hi Raf,
Yes, I am in favour of 'nflag' should be modified to "aflag", and revise
this patch. Thanks!
Index: w.c
===
RCS file: /cvs/src/usr.bin/w/w.c,v
retrieving revision 1.65
diff -u -p -r1.65 w.c
--- w.c 18 Dec 2017 05:51:53 - 1.65
+++ w.c 15 Jun 2018 09:43:52 -
@@ -71,9 +71,9 @@ struct winsizews;
kvm_t *kd;
time_t now;/* the current time of day */
intttywidth; /* width of tty */
-intargwidth; /* width of tty */
-intheader = 1; /* true if -h flag: don't print heading */
-intnflag = 1; /* true if -n flag: don't convert addrs */
+intargwidth; /* width of name and args of the current
process */
+intheader = 1; /* false if -h or -M flag: don't print heading
*/
+intaflag = 1; /* false if -a flag: don't convert addrs */
intsortidle; /* sort by idle time */
char *sel_user; /* login of particular user selected */
char domain[HOST_NAME_MAX+1];
@@ -144,7 +144,7 @@ main(int argc, char *argv[])
nlistf = optarg;
break;
case 'a':
- nflag = 0;
+ aflag = 0;
break;
case 'f': case 'l': case 's': case 'u': case 'w':
warnx("[-flsuw] no longer supported");
@@ -156,7 +156,7 @@ main(int argc, char *argv[])
argc -= optind;
argv += optind;
- if (nflag == 0) {
+ if (aflag == 0) {
if (pledge("stdio tty rpath dns ps vminfo", NULL) == -1)
err(1, "pledge");
} else {
@@ -285,7 +285,7 @@ main(int argc, char *argv[])
}
}
- if (!nflag) {
+ if (!aflag) {
if (gethostname(domain, sizeof(domain)) < 0 ||
(p = strchr(domain, '.')) == 0)
domain[0] = '\0';
@@ -303,7 +303,7 @@ main(int argc, char *argv[])
*x++ = '\0';
break;
}
- if (!nflag && inet_aton(p, ) &&
+ if (!aflag && inet_aton(p, ) &&
(hp = gethostbyaddr((char *), sizeof(addr), AF_INET)))
{
if (domain[0] != '\0') {
p = hp->h_name;
On 6/15/2018 5:57 AM, Raf Czlonka wrote:
> On Thu, Jun 14, 2018 at 06:28:47AM BST, Nan Xiao wrote:
>> Hi tech@,
>>
>> The following patch fix some inaccurate comment in w.c. E.g., there is
>> no "-n" option, and "-a" instead. Sorry id I am wrong, thanks!
>>
>> Index: w.c
>> ===
>> RCS file: /cvs/src/usr.bin/w/w.c,v
>> retrieving revision 1.65
>> diff -u -p -r1.65 w.c
>> --- w.c 18 Dec 2017 05:51:53 - 1.65
>> +++ w.c 14 Jun 2018 05:17:00 -
>> @@ -71,9 +71,9 @@ struct winsize ws;
>> kvm_t *kd;
>> time_t now;/* the current time of day */
>> int ttywidth; /* width of tty */
>> -int argwidth; /* width of tty */
>> -int header = 1; /* true if -h flag: don't print heading */
>> -int nflag = 1; /* true if -n flag: don't convert addrs */
>> +int argwidth; /* width of name and args of the current
>> process */
>> +int header = 1; /* false if -h or -M flag: don't print heading
>> */
>> +int nflag = 1; /* false if -a flag: don't convert addrs */
>> int sortidle; /* sort by idle time */
>> char *sel_user; /* login of particular user selected */
>> chardomain[HOST_NAME_MAX+1];
>
> FYI, the '-n' to '-a' change happened nearly 22 years ago[0].
>
> Given that "-a flag" should clearly be in the comment, shouldn't
> there a mechanical nflag -> aflag change also take place?
>
> [0]
> http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/w/w.c.diff?r1=1.5=1.6=h
>
> Regards,
>
> Raf
>
--
Best Regards
Nan Xiao(肖楠)