X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/7786c61ec816eea6683fc592563be60a2ca80885..6c363f70858369b3dca6738f37654d1dfc5e8d0f:/pig/pig.c diff --git a/pig/pig.c b/pig/pig.c index 2284d63c..028fe59b 100644 --- a/pig/pig.c +++ b/pig/pig.c @@ -1,4 +1,4 @@ -/* $NetBSD: pig.c,v 1.4 1997/01/07 11:16:12 tls Exp $ */ +/* $NetBSD: pig.c,v 1.7 1998/09/13 15:27:29 hubertf Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -33,41 +33,43 @@ * SUCH DAMAGE. */ +#include #ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1992, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; +__COPYRIGHT("@(#) Copyright (c) 1992, 1993\n\ + The Regents of the University of California. All rights reserved.\n"); #endif /* not lint */ #ifndef lint #if 0 static char sccsid[] = "@(#)pig.c 8.2 (Berkeley) 5/4/95"; #else -static char rcsid[] = "$NetBSD: pig.c,v 1.4 1997/01/07 11:16:12 tls Exp $"; +__RCSID("$NetBSD: pig.c,v 1.7 1998/09/13 15:27:29 hubertf Exp $"); #endif #endif /* not lint */ #include #include +#include #include #include #include #include +int main __P((int, char *[])); void pigout __P((char *, int)); -void usage __P((void)); +void usage __P((void)) __attribute__((__noreturn__)); int main(argc, argv) int argc; char *argv[]; { - register int len; + int len; int ch; char buf[1024]; - while ((ch = getopt(argc, argv, "")) != EOF) + while ((ch = getopt(argc, argv, "")) != -1) switch(ch) { case '?': default: @@ -78,10 +80,8 @@ main(argc, argv) for (len = 0; (ch = getchar()) != EOF;) { if (isalpha(ch)) { - if (len >= sizeof(buf)) { - (void)fprintf(stderr, "pig: ate too much!\n"); - exit(1); - } + if (len >= sizeof(buf)) + errx(1, "ate too much!"); buf[len++] = ch; continue; } @@ -99,7 +99,7 @@ pigout(buf, len) char *buf; int len; { - register int ch, start, i; + int ch, start, i; int olen, allupper, firstupper; /* See if the word is all upper case */ @@ -111,7 +111,7 @@ pigout(buf, len) * If the word starts with a vowel, append "way". Don't treat 'y' * as a vowel if it appears first. */ - if (index("aeiouAEIOU", buf[0]) != NULL) { + if (strchr("aeiouAEIOU", buf[0]) != NULL) { (void)printf("%.*s%s", len, buf, allupper ? "WAY" : "way"); return; @@ -124,7 +124,7 @@ pigout(buf, len) if (!allupper) buf[0] = tolower(buf[0]); for (start = 0, olen = len; - !index("aeiouyAEIOUY", buf[start]) && start < olen;) { + !strchr("aeiouyAEIOUY", buf[start]) && start < olen;) { ch = buf[len++] = buf[start++]; if ((ch == 'q' || ch == 'Q') && start < olen && (buf[start] == 'u' || buf[start] == 'U'))