Replace some homegrown string-functions with standard-<string.h>-macros.

Reported by Joseph Myers <jsm28@cam.ac.uk> in PR 6028.
This commit is contained in:
hubertf 1998-08-24 22:26:23 +00:00
parent 5f3ed2ad7d
commit 814a994a5e
2 changed files with 11 additions and 44 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: extern.h,v 1.4 1998/08/24 22:07:37 hubertf Exp $ */
/* $NetBSD: extern.h,v 1.5 1998/08/24 22:26:23 hubertf Exp $ */
/*
* Copyright (c) 1997 Christos Zoulas. All rights reserved.
@ -29,6 +29,8 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <string.h>
/* crc.c */
void crc_start __P((void));
unsigned long crc __P((char *, int));
@ -116,9 +118,12 @@ int put __P((int, int, int));
void carry __P((int, int));
void drop __P((int, int));
int vocab __P((char *, int, int));
void copystr __P((char *, char *));
int weq __P((char *, char *));
int length __P((char *));
/* These three used to be functions in vocab.c */
#define copystr(src, dest) strcpy((dest), (src))
#define weq(str1, str2) (!strncmp((str1), (str2), 5))
#define length(str) (strlen((str)) + 1)
void prht __P((void));
/* wizard.c */

View File

@ -1,4 +1,4 @@
/* $NetBSD: vocab.c,v 1.5 1997/10/11 01:53:38 lukem Exp $ */
/* $NetBSD: vocab.c,v 1.6 1998/08/24 22:26:23 hubertf Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -43,7 +43,7 @@
#if 0
static char sccsid[] = "@(#)vocab.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: vocab.c,v 1.5 1997/10/11 01:53:38 lukem Exp $");
__RCSID("$NetBSD: vocab.c,v 1.6 1998/08/24 22:26:23 hubertf Exp $");
#endif
#endif /* not lint */
@ -201,44 +201,6 @@ exitloop2: /* hashed entry does not match */
}
}
void
copystr(w1, w2) /* copy one string to another */
char *w1, *w2;
{
char *s, *t;
for (s = w1, t = w2; *s;)
*t++ = *s++;
*t = 0;
}
int
weq(w1, w2) /* compare words */
char *w1, *w2; /* w1 is user, w2 is system */
{
char *s, *t;
int i;
s = w1;
t = w2;
for (i = 0; i < 5; i++) { /* compare at most 5 chars */
if (*t == 0 && *s == 0)
return (TRUE);
if (*s++ != *t++)
return (FALSE);
}
return (TRUE);
}
int
length(str) /* includes 0 at end */
char *str;
{
char *s;
int n;
for (n = 0, s = str; *s++;)
n++;
return (n + 1);
}
void
prht()
{ /* print hash table */