summaryrefslogtreecommitdiff
path: root/usr.bin/spell/spellprog.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2002-03-02 16:20:34 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2002-03-02 16:20:34 +0000
commit494bd394af808a3f901b6227c98de9f88cebfb49 (patch)
tree6e11ebf3fdbd3ddbec70fd7f7b48cf337971aacc /usr.bin/spell/spellprog.c
parent367e6e91dd296fdd0027e17e32823b374fd69801 (diff)
No more writable strings in -b mode.
Diffstat (limited to 'usr.bin/spell/spellprog.c')
-rw-r--r--usr.bin/spell/spellprog.c40
1 files changed, 30 insertions, 10 deletions
diff --git a/usr.bin/spell/spellprog.c b/usr.bin/spell/spellprog.c
index acaad64c200..650b922eb4c 100644
--- a/usr.bin/spell/spellprog.c
+++ b/usr.bin/spell/spellprog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: spellprog.c,v 1.1 2002/03/01 22:01:11 millert Exp $ */
+/* $OpenBSD: spellprog.c,v 1.2 2002/03/02 16:20:33 millert Exp $ */
/*
* Copyright (c) 1991, 1993
@@ -79,7 +79,7 @@ static const char copyright[] =
static const char sccsid[] = "@(#)spell.c 8.1 (Berkeley) 6/6/93";
#else
#endif
-static const char rcsid[] = "$OpenBSD: spellprog.c,v 1.1 2002/03/01 22:01:11 millert Exp $";
+static const char rcsid[] = "$OpenBSD: spellprog.c,v 1.2 2002/03/02 16:20:33 millert Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -122,6 +122,7 @@ int CCe(char *, char *, char *, int);
int VCe(char *, char *, char *, int);
char *lookuppref(char **, char *);
char *skipv(char *);
+char *estrdup(const char *);
void ise(void);
void print_word(FILE *);
void ztos(char *);
@@ -131,7 +132,7 @@ __dead void usage(void);
int look(unsigned char *, unsigned char *, unsigned char *);
struct suftab {
- char *suf; /* XXX - needs to be writable for ise() */
+ char *suf;
int (*p1)(); /* XXX - variable args */
int n1;
char *d1;
@@ -317,7 +318,6 @@ main(int argc, char **argv)
else if ((found = fopen(outfile, "w")) == NULL)
err(1, "cannot open %s", outfile);
- /* XXX - this fprintf is for loop abuse */
for (;; print_word(file)) {
affix[0] = '\0';
file = found;
@@ -742,12 +742,22 @@ vowel(int c)
void
ise(void)
{
- struct suftab *p;
-
- for (p = suftab; p->suf; p++) {
- ztos(p->suf);
- ztos(p->d1);
- ztos(p->a1);
+ struct suftab *tab;
+
+ for (tab = suftab; tab->suf; tab++) {
+ /* Assume that suffix will contain 'z' if a1 or d1 do */
+ if (strchr(tab->suf, 'z')) {
+ tab->suf = estrdup(tab->suf);
+ ztos(tab->suf);
+ if (strchr(tab->d1, 'z')) {
+ tab->d1 = estrdup(tab->d1);
+ ztos(tab->d1);
+ }
+ if (strchr(tab->a1, 'z')) {
+ tab->a1 = estrdup(tab->a1);
+ ztos(tab->a1);
+ }
+ }
}
}
@@ -760,6 +770,16 @@ ztos(char *s)
*s = 's';
}
+char *
+estrdup(const char *s)
+{
+ char *d;
+
+ if ((d = strdup(s)) == NULL)
+ err(1, "strdup");
+ return(d);
+}
+
/*
* Look up a word in the dictionary.
* Returns 1 if found, 0 if not.