From 952db1ec53b2365d68d84970049975065cd884f5 Mon Sep 17 00:00:00 2001 From: lukem Date: Fri, 10 Oct 1997 12:04:23 +0000 Subject: WARNSify --- caesar/caesar.6 | 8 ++++---- caesar/caesar.c | 32 ++++++++++++++++++++------------ 2 files changed, 24 insertions(+), 16 deletions(-) (limited to 'caesar') diff --git a/caesar/caesar.6 b/caesar/caesar.6 index 12615368..e62f4957 100644 --- a/caesar/caesar.6 +++ b/caesar/caesar.6 @@ -1,4 +1,4 @@ -.\" $NetBSD: caesar.6,v 1.4 1995/03/21 15:08:20 cgd Exp $ +.\" $NetBSD: caesar.6,v 1.5 1997/10/10 12:07:08 lukem Exp $ .\" .\" Copyright (c) 1989, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -40,14 +40,14 @@ .Nm caesar .Nd decrypt caesar cyphers .Sh SYNOPSIS -.Nm caesar +.Nm .Op Ar rotation .Sh DESCRIPTION The -.Nm caesar +.Nm utility attempts to decrypt caesar cyphers using English letter frequency statistics. -.Nm Caesar +.Nm reads from the standard input and writes to the standard output. .Pp The optional numerical argument diff --git a/caesar/caesar.c b/caesar/caesar.c index 2d4772e7..e2355fdc 100644 --- a/caesar/caesar.c +++ b/caesar/caesar.c @@ -1,4 +1,4 @@ -/* $NetBSD: caesar.c,v 1.4 1996/02/06 22:47:15 jtc Exp $ */ +/* $NetBSD: caesar.c,v 1.5 1997/10/10 12:07:11 lukem Exp $ */ /* * Copyright (c) 1989, 1993 @@ -41,25 +41,27 @@ * SUCH DAMAGE. */ +#include #ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1989, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; +__COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\ + The Regents of the University of California. All rights reserved.\n"); #endif /* not lint */ #ifndef lint #if 0 static char sccsid[] = "@(#)caesar.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: caesar.c,v 1.4 1996/02/06 22:47:15 jtc Exp $"; +__RCSID("$NetBSD: caesar.c,v 1.5 1997/10/10 12:07:11 lukem Exp $"); #endif #endif /* not lint */ +#include +#include #include #include -#include +#include +#include #include -#include #define LINELENGTH 2048 #define ROTATE(ch, perm) \ @@ -76,15 +78,20 @@ double stdf[26] = { 2.62, 0.81, 1.88, 0.23, 2.07, 0.06, }; + +int main __P((int, char *[])); +void printit __P((char *)); + +int main(argc, argv) int argc; char **argv; { - register int ch, dot, i, nread, winnerdot; - register char *inbuf; + int ch, dot, i, nread, winnerdot; + char *inbuf; int obs[26], try, winner; - char *malloc(), *strerror(); + winnerdot = 0; if (argc > 1) printit(argv[1]); @@ -98,7 +105,7 @@ main(argc, argv) stdf[i] = log(stdf[i]) + log(26.0 / 100.0); /* zero out observation table */ - bzero(obs, 26 * sizeof(int)); + memset(obs, 0, 26 * sizeof(int)); if ((nread = read(STDIN_FILENO, inbuf, LINELENGTH)) < 0) { (void)fprintf(stderr, "caesar: %s\n", strerror(errno)); @@ -145,10 +152,11 @@ main(argc, argv) exit(0); } +void printit(arg) char *arg; { - register int ch, rot; + int ch, rot; if ((rot = atoi(arg)) < 0) { (void)fprintf(stderr, "caesar: bad rotation value.\n"); -- cgit v1.2.3-56-ge451