Skip to content

Commit 814a994

Browse files
hubertfhubertf
hubertf
authored and
hubertf
committed
Replace some homegrown string-functions with standard-<string.h>-macros.
Reported by Joseph Myers <jsm28@cam.ac.uk> in PR 6028.
1 parent 5f3ed2a commit 814a994

File tree

2 files changed

+11
-44
lines changed

2 files changed

+11
-44
lines changed

games/adventure/extern.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: extern.h,v 1.4 1998/08/24 22:07:37 hubertf Exp $ */
1+
/* $NetBSD: extern.h,v 1.5 1998/08/24 22:26:23 hubertf Exp $ */
22

33
/*
44
* Copyright (c) 1997 Christos Zoulas. All rights reserved.
@@ -29,6 +29,8 @@
2929
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030
*/
3131

32+
#include <string.h>
33+
3234
/* crc.c */
3335
void crc_start __P((void));
3436
unsigned long crc __P((char *, int));
@@ -116,9 +118,12 @@ int put __P((int, int, int));
116118
void carry __P((int, int));
117119
void drop __P((int, int));
118120
int vocab __P((char *, int, int));
119-
void copystr __P((char *, char *));
120-
int weq __P((char *, char *));
121-
int length __P((char *));
121+
122+
/* These three used to be functions in vocab.c */
123+
#define copystr(src, dest) strcpy((dest), (src))
124+
#define weq(str1, str2) (!strncmp((str1), (str2), 5))
125+
#define length(str) (strlen((str)) + 1)
126+
122127
void prht __P((void));
123128

124129
/* wizard.c */

games/adventure/vocab.c

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: vocab.c,v 1.5 1997/10/11 01:53:38 lukem Exp $ */
1+
/* $NetBSD: vocab.c,v 1.6 1998/08/24 22:26:23 hubertf Exp $ */
22

33
/*-
44
* Copyright (c) 1991, 1993
@@ -43,7 +43,7 @@
4343
#if 0
4444
static char sccsid[] = "@(#)vocab.c 8.1 (Berkeley) 5/31/93";
4545
#else
46-
__RCSID("$NetBSD: vocab.c,v 1.5 1997/10/11 01:53:38 lukem Exp $");
46+
__RCSID("$NetBSD: vocab.c,v 1.6 1998/08/24 22:26:23 hubertf Exp $");
4747
#endif
4848
#endif /* not lint */
4949

@@ -201,44 +201,6 @@ vocab(word, type, value) /* look up or store a word */
201201
}
202202
}
203203

204-
void
205-
copystr(w1, w2) /* copy one string to another */
206-
char *w1, *w2;
207-
{
208-
char *s, *t;
209-
for (s = w1, t = w2; *s;)
210-
*t++ = *s++;
211-
*t = 0;
212-
}
213-
214-
int
215-
weq(w1, w2) /* compare words */
216-
char *w1, *w2; /* w1 is user, w2 is system */
217-
{
218-
char *s, *t;
219-
int i;
220-
s = w1;
221-
t = w2;
222-
for (i = 0; i < 5; i++) { /* compare at most 5 chars */
223-
if (*t == 0 && *s == 0)
224-
return (TRUE);
225-
if (*s++ != *t++)
226-
return (FALSE);
227-
}
228-
return (TRUE);
229-
}
230-
231-
int
232-
length(str) /* includes 0 at end */
233-
char *str;
234-
{
235-
char *s;
236-
int n;
237-
for (n = 0, s = str; *s++;)
238-
n++;
239-
return (n + 1);
240-
}
241-
242204
void
243205
prht()
244206
{ /* print hash table */

0 commit comments

Comments
 (0)