CVS commit: src/games/canfield/cfscores

2010-01-03 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun Jan  3 17:08:45 UTC 2010

Modified Files:
src/games/canfield/cfscores: cfscores.c

Log Message:
Christos points out that usage should not use errx, but should use
getprogname.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/games/canfield/cfscores/cfscores.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Re: CVS commit: src/games/canfield/cfscores

2010-01-01 Thread Marc Balmer

Am 01.01.2010 um 07:20 schrieb David A. Holland:

 Module Name:  src
 Committed By: dholland
 Date: Fri Jan  1 06:20:45 UTC 2010
 
 Modified Files:
   src/games/canfield/cfscores: cfscores.c
 
 Log Message:
 Send error messages to stderr. Use errx/warnx, not printf.
 
 
 To generate a diff of this commit:
 cvs rdiff -u -r1.17 -r1.18 src/games/canfield/cfscores/cfscores.c
 
 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.
 
 Modified files:
 
 Index: src/games/canfield/cfscores/cfscores.c
 diff -u src/games/canfield/cfscores/cfscores.c:1.17 
 src/games/canfield/cfscores/cfscores.c:1.18
 --- src/games/canfield/cfscores/cfscores.c:1.17   Fri Jan  1 06:16:36 2010
 +++ src/games/canfield/cfscores/cfscores.cFri Jan  1 06:20:45 2010
 @@ -1,4 +1,4 @@
 -/*   $NetBSD: cfscores.c,v 1.17 2010/01/01 06:16:36 dholland Exp $   */
 +/*   $NetBSD: cfscores.c,v 1.18 2010/01/01 06:20:45 dholland Exp $   */
 
 /*
  * Copyright (c) 1983, 1993
 @@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = @(#)cfscores.c8.1 (Berkeley) 5/31/93;
 #else
 -__RCSID($NetBSD: cfscores.c,v 1.17 2010/01/01 06:16:36 dholland Exp $);
 +__RCSID($NetBSD: cfscores.c,v 1.18 2010/01/01 06:20:45 dholland Exp $);
 #endif
 #endif /* not lint */
 
 @@ -78,8 +78,7 @@
   setgid(getgid());
 
   if (argc  2) {
 - printf(Usage: cfscores -a | cfscores [user]\n);
 - exit(1);
 + errx(1, Usage: cfscores -a | cfscores [user]);

imo, lower case usage would be more consistent with other commands.

   }
   dbfd = open(_PATH_SCORE, O_RDONLY);
   if (dbfd  0)
 @@ -89,8 +88,7 @@
   uid = getuid();
   pw = getpwuid(uid);
   if (pw == 0) {
 - printf(You are not listed in the password file?!?\n);
 - exit(2);
 + errx(2, You are not listed in the password file?!?);
   }
   printuser(pw, 1);
   exit(0);
 @@ -102,8 +100,7 @@
   }
   pw = getpwnam(argv[1]);
   if (pw == 0) {
 - printf(User %s unknown\n, argv[1]);
 - exit(3);
 + errx(3, User %s unknown, argv[1]);
   }
   printuser(pw, 1);
   exit(0);
 @@ -122,7 +119,7 @@
   pos = pw-pw_uid * (off_t)sizeof(struct betinfo);
   /* test pos, not pw_uid; uid_t can be unsigned, which makes gcc warn */
   if (pos  0) {
 - printf(Bad uid %d\n, (int)pw-pw_uid);
 + warnx(Bad uid %d, (int)pw-pw_uid);
   return;
   }
   i = lseek(dbfd, pos, SEEK_SET);
 



Re: CVS commit: src/games/canfield/cfscores

2010-01-01 Thread David Holland
On Fri, Jan 01, 2010 at 03:33:26PM +0100, Marc Balmer wrote:
  if (argc  2) {
   -  printf(Usage: cfscores -a | cfscores [user]\n);
   -  exit(1);
   +  errx(1, Usage: cfscores -a | cfscores [user]);
  
  imo, lower case usage would be more consistent with other commands.

Some grep usage suggests that lowercase outnumbers capitalized by a
good margin, but there's still a healthy minority of capitalized usage
messages. (It's about 500 to 125.)

Is this something we care enough about to make a point of fixing it as
we go?

-- 
David A. Holland
dholl...@netbsd.org


Re: CVS commit: src/games/canfield/cfscores

2010-01-01 Thread Marc Balmer

Am 01.01.2010 um 18:35 schrieb David Holland:

 On Fri, Jan 01, 2010 at 03:33:26PM +0100, Marc Balmer wrote:
 if (argc  2) {
 -   printf(Usage: cfscores -a | cfscores [user]\n);
 -   exit(1);
 +   errx(1, Usage: cfscores -a | cfscores [user]);
 
 imo, lower case usage would be more consistent with other commands.
 
 Some grep usage suggests that lowercase outnumbers capitalized by a
 good margin, but there's still a healthy minority of capitalized usage
 messages. (It's about 500 to 125.)
 
 Is this something we care enough about to make a point of fixing it as
 we go?

with a ratio of 500:125, I am inclined to say no.

 
 -- 
 David A. Holland
 dholl...@netbsd.org



Re: CVS commit: src/games/canfield/cfscores

2010-01-01 Thread Christos Zoulas
In article 20100101173538.ga17...@netbsd.org,
David Holland  dholland-sourcechan...@netbsd.org wrote:
On Fri, Jan 01, 2010 at 03:33:26PM +0100, Marc Balmer wrote:
 if (argc  2) {
   - printf(Usage: cfscores -a | cfscores [user]\n);
   - exit(1);
   + errx(1, Usage: cfscores -a | cfscores [user]);
  
  imo, lower case usage would be more consistent with other commands.

Some grep usage suggests that lowercase outnumbers capitalized by a
good margin, but there's still a healthy minority of capitalized usage
messages. (It's about 500 to 125.)

Is this something we care enough about to make a point of fixing it as
we go?

I think consistency is good, but at the same time I like upper case :-)
Also using errx() for usage is inconsistent because you end up printing
prog: Usage: prog instead of Usage: prog. And everything should
consistently use getprogname() instead of hard-coding it.

christos



CVS commit: src/games/canfield/cfscores

2009-12-31 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Fri Jan  1 06:16:36 UTC 2010

Modified Files:
src/games/canfield/cfscores: cfscores.c

Log Message:
Correct usage message.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/games/canfield/cfscores/cfscores.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/games/canfield/cfscores

2009-12-31 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Fri Jan  1 06:20:45 UTC 2010

Modified Files:
src/games/canfield/cfscores: cfscores.c

Log Message:
Send error messages to stderr. Use errx/warnx, not printf.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/games/canfield/cfscores/cfscores.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/games/canfield/cfscores

2009-12-31 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Fri Jan  1 06:31:18 UTC 2010

Modified Files:
src/games/canfield/cfscores: cfscores.c

Log Message:
Use NULL instead of 0 for pointer tests. Remove an unnecessary cast.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/games/canfield/cfscores/cfscores.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.