summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1996-05-27 22:43:43 +0000
committerache <ache@FreeBSD.org>1996-05-27 22:43:43 +0000
commite1b45fe28090cb6417cd23e17139cfbf8a5a10f9 (patch)
tree2193cd48f5c12ef60c99951b8232b36323622e30
parent59d2d1c67bbc3323110cb3141ddf3de74efcbfb1 (diff)
downloadFreeBSD-src-e1b45fe28090cb6417cd23e17139cfbf8a5a10f9.zip
FreeBSD-src-e1b45fe28090cb6417cd23e17139cfbf8a5a10f9.tar.gz
Localize it.
off_t -> long. Install strfile & unstr -Wall cleanup Fix matching bug with offensive database
-rw-r--r--games/fortune/Makefile8
-rw-r--r--games/fortune/datfiles/Makefile4
-rw-r--r--games/fortune/fortune/Makefile2
-rw-r--r--games/fortune/fortune/fortune.c89
-rw-r--r--games/fortune/strfile/Makefile5
-rw-r--r--games/fortune/strfile/strfile.c125
-rw-r--r--games/fortune/strfile/strfile.h2
-rw-r--r--games/fortune/unstr/Makefile3
-rw-r--r--games/fortune/unstr/unstr.c22
9 files changed, 130 insertions, 130 deletions
diff --git a/games/fortune/Makefile b/games/fortune/Makefile
index d360284..b8b4ff1 100644
--- a/games/fortune/Makefile
+++ b/games/fortune/Makefile
@@ -1,11 +1,5 @@
# @(#)Makefile 8.1 (Berkeley) 5/31/93
-SUBDIR= fortune
-
-.if !make(install) && !make(distribute)
-SUBDIR+=strfile
-.endif
-
-SUBDIR+= datfiles
+SUBDIR= fortune strfile datfiles unstr
.include <bsd.subdir.mk>
diff --git a/games/fortune/datfiles/Makefile b/games/fortune/datfiles/Makefile
index 72786ee..d3962d9 100644
--- a/games/fortune/datfiles/Makefile
+++ b/games/fortune/datfiles/Makefile
@@ -25,8 +25,10 @@ CAESAR=/usr/games/caesar
.if exists(${.CURDIR}/../strfile/obj/strfile)
STRFILE=${.CURDIR}/../strfile/obj/strfile
-.else
+.elif exists(${.CURDIR}/../strfile/strfile)
STRFILE=${.CURDIR}/../strfile/strfile
+.else
+STRFILE=/usr/games/strfile
.endif
CLEANFILES+=${BLDS}
diff --git a/games/fortune/fortune/Makefile b/games/fortune/fortune/Makefile
index 598d99b..62f8182 100644
--- a/games/fortune/fortune/Makefile
+++ b/games/fortune/fortune/Makefile
@@ -2,7 +2,7 @@
PROG= fortune
MAN6= fortune.6
-CFLAGS+=-I${.CURDIR}/../strfile
+CFLAGS+=-DDEBUG -Wall -I${.CURDIR}/../strfile
DPADD= ${COMPAT}
LDADD= -lcompat
diff --git a/games/fortune/fortune/fortune.c b/games/fortune/fortune/fortune.c
index 802a092..7b17879 100644
--- a/games/fortune/fortune/fortune.c
+++ b/games/fortune/fortune/fortune.c
@@ -35,13 +35,13 @@
*/
#ifndef lint
-static char copyright[] =
+static const char copyright[] =
"@(#) Copyright (c) 1986, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)fortune.c 8.1 (Berkeley) 5/31/93";
+static const char sccsid[] = "@(#)fortune.c 8.1 (Berkeley) 5/31/93";
#endif /* not lint */
# include <sys/param.h>
@@ -55,6 +55,8 @@ static char sccsid[] = "@(#)fortune.c 8.1 (Berkeley) 5/31/93";
# include <ctype.h>
# include <stdlib.h>
# include <string.h>
+# include <locale.h>
+# include <time.h>
# include "strfile.h"
# include "pathnames.h"
@@ -66,11 +68,11 @@ static char sccsid[] = "@(#)fortune.c 8.1 (Berkeley) 5/31/93";
# define CPERS 20 /* # of chars for each sec */
# define SLEN 160 /* # of chars in short fortune */
-# define POS_UNKNOWN ((off_t) -1) /* pos for file unknown */
+# define POS_UNKNOWN ((long) -1) /* pos for file unknown */
# define NO_PROB (-1) /* no prob specified for file */
# ifdef DEBUG
-# define DPRINTF(l,x) if (Debug >= l) fprintf x; else
+# define DPRINTF(l,x) { if (Debug >= l) fprintf x; }
# undef NDEBUG
# else
# define DPRINTF(l,x)
@@ -80,7 +82,7 @@ static char sccsid[] = "@(#)fortune.c 8.1 (Berkeley) 5/31/93";
typedef struct fd {
int percent;
int fd, datfd;
- off_t pos;
+ long pos;
FILE *inf;
char *name;
char *path;
@@ -112,7 +114,7 @@ char *Fortbuf = NULL; /* fortune buffer for -m */
int Fort_len = 0;
-off_t Seekpts[2]; /* seek pointers to fortunes */
+long Seekpts[2]; /* seek pointers to fortunes */
FILEDESC *File_list = NULL, /* Head of file list */
*File_tail = NULL; /* Tail of file list */
@@ -186,6 +188,8 @@ char *av[];
int fd;
#endif /* OK_TO_WRITE_DISK */
+ (void) setlocale(LC_CTYPE, "");
+
getargs(ac, av);
#ifndef NO_REGEX
@@ -194,7 +198,7 @@ char *av[];
#endif
init_prob();
- srandom((int)(time((time_t *) NULL) + getpid()));
+ srandom((int)(time((time_t *) NULL) ^ getpid()));
do {
get_fort();
} while ((Short_only && fortlen() > SLEN) ||
@@ -235,19 +239,23 @@ void
display(fp)
FILEDESC *fp;
{
- register char *p, ch;
+ register char *p;
+ register unsigned char ch;
char line[BUFSIZ];
open_fp(fp);
- (void) fseek(fp->inf, (long)Seekpts[0], 0);
+ (void) fseek(fp->inf, Seekpts[0], 0);
for (Fort_len = 0; fgets(line, sizeof line, fp->inf) != NULL &&
!STR_ENDSTRING(line, fp->tbl); Fort_len++) {
if (fp->tbl.str_flags & STR_ROTATED)
- for (p = line; ch = *p; ++p)
- if (isupper(ch))
- *p = 'A' + (ch - 'A' + 13) % 26;
- else if (islower(ch))
- *p = 'a' + (ch - 'a' + 13) % 26;
+ for (p = line; (ch = *p) != '\0'; ++p) {
+ if (isascii(ch)) {
+ if (isupper(ch))
+ *p = 'A' + (ch - 'A' + 13) % 26;
+ else if (islower(ch))
+ *p = 'a' + (ch - 'a' + 13) % 26;
+ }
+ }
fputs(line, stdout);
}
(void) fflush(stdout);
@@ -267,7 +275,7 @@ fortlen()
nchar = (Seekpts[1] - Seekpts[0] <= SLEN);
else {
open_fp(Fortfile);
- (void) fseek(Fortfile->inf, (long)Seekpts[0], 0);
+ (void) fseek(Fortfile->inf, Seekpts[0], 0);
nchar = 0;
while (fgets(line, sizeof line, Fortfile->inf) != NULL &&
!STR_ENDSTRING(line, Fortfile->tbl))
@@ -399,11 +407,11 @@ register int file_cnt;
&File_list, &File_tail, NULL);
for (i = 0; i < file_cnt; i++) {
percent = NO_PROB;
- if (!isdigit(files[i][0]))
+ if (!isdigit((unsigned char)files[i][0]))
sp = files[i];
else {
percent = 0;
- for (sp = files[i]; isdigit(*sp); sp++)
+ for (sp = files[i]; isdigit((unsigned char)*sp); sp++)
percent = percent * 10 + *sp - '0';
if (percent > 100) {
fprintf(stderr, "percentages must be <= 100\n");
@@ -791,12 +799,14 @@ int check_for_offend;
*datp = datfile;
else
free(datfile);
-#ifdef OK_TO_WRITE_DISK
if (posp != NULL) {
+#ifdef OK_TO_WRITE_DISK
*posp = copy(file, (unsigned int) (strlen(file) + 4)); /* +4 for ".dat" */
(void) strcat(*posp, ".pos");
- }
+#else
+ *posp = NULL;
#endif /* OK_TO_WRITE_DISK */
+ }
DPRINTF(2, (stderr, "TRUE\n"));
return TRUE;
}
@@ -856,7 +866,7 @@ void *ptr;
void
init_prob()
{
- register FILEDESC *fp, *last;
+ register FILEDESC *fp, *last = NULL;
register int percent, num_noprob, frac;
/*
@@ -955,17 +965,17 @@ get_fort()
if (fp->next != NULL) {
sum_noprobs(fp);
choice = random() % Noprob_tbl.str_numstr;
- DPRINTF(1, (stderr, "choice = %d (of %d) \n", choice,
+ DPRINTF(1, (stderr, "choice = %d (of %ld) \n", choice,
Noprob_tbl.str_numstr));
while (choice >= fp->tbl.str_numstr) {
choice -= fp->tbl.str_numstr;
fp = fp->next;
DPRINTF(1, (stderr,
- " skip \"%s\", %d (choice = %d)\n",
+ " skip \"%s\", %ld (choice = %d)\n",
fp->name, fp->tbl.str_numstr,
choice));
}
- DPRINTF(1, (stderr, "using \"%s\", %d\n", fp->name,
+ DPRINTF(1, (stderr, "using \"%s\", %ld\n", fp->name,
fp->tbl.str_numstr));
}
get_tbl(fp);
@@ -1007,15 +1017,15 @@ FILEDESC *parent;
else {
get_tbl(parent);
choice = random() % parent->tbl.str_numstr;
- DPRINTF(1, (stderr, " choice = %d (of %d)\n",
+ DPRINTF(1, (stderr, " choice = %d (of %ld)\n",
choice, parent->tbl.str_numstr));
for (fp = parent->child; choice >= fp->tbl.str_numstr;
fp = fp->next) {
choice -= fp->tbl.str_numstr;
- DPRINTF(1, (stderr, "\tskip %s, %d (choice = %d)\n",
+ DPRINTF(1, (stderr, "\tskip %s, %ld (choice = %d)\n",
fp->name, fp->tbl.str_numstr, choice));
}
- DPRINTF(1, (stderr, " using %s, %d\n", fp->name,
+ DPRINTF(1, (stderr, " using %s, %ld\n", fp->name,
fp->tbl.str_numstr));
return fp;
}
@@ -1106,7 +1116,7 @@ FILEDESC *fp;
}
if (++(fp->pos) >= fp->tbl.str_numstr)
fp->pos -= fp->tbl.str_numstr;
- DPRINTF(1, (stderr, "pos for %s is %qd\n", fp->name, fp->pos));
+ DPRINTF(1, (stderr, "pos for %s is %ld\n", fp->name, fp->pos));
}
/*
@@ -1159,7 +1169,7 @@ register STRFILE *tp;
{
tp->str_numstr = 0;
tp->str_longlen = 0;
- tp->str_shortlen = -1;
+ tp->str_shortlen = ~((unsigned long)0);
}
/*
@@ -1207,7 +1217,6 @@ int lev;
fprintf(stderr, " %s", STR(list->name));
DPRINTF(1, (stderr, " (%s, %s, %s)\n", STR(list->path),
STR(list->datfile), STR(list->posfile)));
- putc('\n', stderr);
if (list->child != NULL)
print_list(list->child, lev + 1);
list = list->next;
@@ -1229,7 +1238,7 @@ register char *orig;
cnt = 1; /* allow for '\0' */
for (sp = orig; *sp != '\0'; sp++)
- if (isalpha(*sp))
+ if (isalpha((unsigned char)*sp))
cnt += 4;
else
cnt++;
@@ -1239,16 +1248,16 @@ register char *orig;
}
for (sp = new; *orig != '\0'; orig++) {
- if (islower(*orig)) {
+ if (islower((unsigned char)*orig)) {
*sp++ = '[';
*sp++ = *orig;
- *sp++ = toupper(*orig);
+ *sp++ = toupper((unsigned char)*orig);
*sp++ = ']';
}
- else if (isupper(*orig)) {
+ else if (isupper((unsigned char)*orig)) {
*sp++ = '[';
*sp++ = *orig;
- *sp++ = tolower(*orig);
+ *sp++ = tolower((unsigned char)*orig);
*sp++ = ']';
}
else
@@ -1310,9 +1319,10 @@ void
matches_in_list(list)
FILEDESC *list;
{
- register char *sp;
+ register char *sp, *p;
register FILEDESC *fp;
int in_file;
+ unsigned char ch;
for (fp = list; fp != NULL; fp = fp->next) {
if (fp->child != NULL) {
@@ -1328,6 +1338,15 @@ FILEDESC *list;
sp += strlen(sp);
else {
*sp = '\0';
+ if (fp->tbl.str_flags & STR_ROTATED)
+ for (p = Fortbuf; (ch = *p) != '\0'; ++p) {
+ if (isascii(ch)) {
+ if (isupper(ch))
+ *p = 'A' + (ch - 'A' + 13) % 26;
+ else if (islower(ch))
+ *p = 'a' + (ch - 'a' + 13) % 26;
+ }
+ }
if (RE_EXEC(Fortbuf)) {
printf("%c%c", fp->tbl.str_delim,
fp->tbl.str_delim);
diff --git a/games/fortune/strfile/Makefile b/games/fortune/strfile/Makefile
index 6c0a8d9..744e000 100644
--- a/games/fortune/strfile/Makefile
+++ b/games/fortune/strfile/Makefile
@@ -1,6 +1,9 @@
# @(#)Makefile 8.1 (Berkeley) 5/31/93
PROG= strfile
-NOMAN= noman
+MAN8= strfile.8
+MLINKS= strfile.8 unstr.8
+CFLAGS+= -Wall
+.include "${.CURDIR}/../../Makefile.inc"
.include <bsd.prog.mk>
diff --git a/games/fortune/strfile/strfile.c b/games/fortune/strfile/strfile.c
index 729cb5c..1f6a9bb 100644
--- a/games/fortune/strfile/strfile.c
+++ b/games/fortune/strfile/strfile.c
@@ -35,25 +35,25 @@
*/
#ifndef lint
-static char copyright[] =
+static const char copyright[] =
"@(#) Copyright (c) 1989, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)strfile.c 8.1 (Berkeley) 5/31/93";
+static const char sccsid[] = "@(#)strfile.c 8.1 (Berkeley) 5/31/93";
#endif /* not lint */
-# include <machine/endian.h>
# include <sys/param.h>
# include <stdio.h>
+# include <stdlib.h>
# include <ctype.h>
+# include <string.h>
+# include <time.h>
+# include <locale.h>
+# include <unistd.h>
# include "strfile.h"
-# ifndef MAXPATHLEN
-# define MAXPATHLEN 1024
-# endif /* MAXPATHLEN */
-
/*
* This program takes a file composed of strings seperated by
* lines starting with two consecutive delimiting character (default
@@ -83,12 +83,7 @@ static char sccsid[] = "@(#)strfile.c 8.1 (Berkeley) 5/31/93";
# define STORING_PTRS (Oflag || Rflag)
# define CHUNKSIZE 512
-#ifdef lint
-# define ALWAYS atoi("1")
-#else
-# define ALWAYS 1
-#endif
-# define ALLOC(ptr,sz) if (ALWAYS) { \
+# define ALLOC(ptr,sz) { \
if (ptr == NULL) \
ptr = malloc((unsigned int) (CHUNKSIZE * sizeof *ptr)); \
else if (((sz) + 1) % CHUNKSIZE == 0) \
@@ -97,7 +92,7 @@ static char sccsid[] = "@(#)strfile.c 8.1 (Berkeley) 5/31/93";
fprintf(stderr, "out of space\n"); \
exit(1); \
} \
- } else
+ }
#ifdef NO_VOID
# define void char
@@ -105,7 +100,7 @@ static char sccsid[] = "@(#)strfile.c 8.1 (Berkeley) 5/31/93";
typedef struct {
char first;
- off_t pos;
+ long pos;
} STR;
char *Infile = NULL, /* input file name */
@@ -119,7 +114,7 @@ int Rflag = FALSE; /* randomize order flag */
int Xflag = FALSE; /* set rotated bit */
long Num_pts = 0; /* number of pointers/strings */
-off_t *Seekpts;
+long *Seekpts;
FILE *Sort_1, *Sort_2; /* pointers for sorting */
@@ -127,9 +122,8 @@ STRFILE Tbl; /* statistics table */
STR *Firstch; /* first chars of each string */
-char *fgets(), *strcpy(), *strcat();
-
-void *malloc(), *realloc();
+void getargs(), add_offset(), do_order(), randomize(), usage();
+int cmp_str();
/*
* main:
@@ -140,18 +134,20 @@ void *malloc(), *realloc();
* CHUNKSIZE blocks; if the latter, we just write each pointer,
* and then seek back to the beginning to write in the table.
*/
-main(ac, av)
+void main(ac, av)
int ac;
char **av;
{
register char *sp, dc;
register FILE *inf, *outf;
- register off_t last_off, length, pos, *p;
+ register long last_off, length, pos, *p;
register int first, cnt;
register char *nsp;
register STR *fp;
static char string[257];
+ (void) setlocale(LC_CTYPE, "");
+
getargs(ac, av); /* evalute arguments */
dc = Delimch;
if ((inf = fopen(Infile, "r")) == NULL) {
@@ -164,14 +160,14 @@ char **av;
exit(1);
}
if (!STORING_PTRS)
- (void) fseek(outf, sizeof Tbl, 0);
+ (void) fseek(outf, (long) sizeof Tbl, 0);
/*
* Write the strings onto the file
*/
Tbl.str_longlen = 0;
- Tbl.str_shortlen = (unsigned int) 0xffffffff;
+ Tbl.str_shortlen = ~((unsigned long) 0);
Tbl.str_delim = dc;
Tbl.str_version = VERSION;
first = Oflag;
@@ -179,7 +175,7 @@ char **av;
last_off = 0;
do {
sp = fgets(string, 256, inf);
- if (sp == NULL || sp[0] == dc && sp[1] == '\n') {
+ if (sp == NULL || (sp[0] == dc && sp[1] == '\n')) {
pos = ftell(inf);
length = pos - last_off - (sp ? strlen(sp) : 0);
last_off = pos;
@@ -193,12 +189,12 @@ char **av;
first = Oflag;
}
else if (first) {
- for (nsp = sp; !isalnum(*nsp); nsp++)
+ for (nsp = sp; !isalnum((unsigned char)*nsp); nsp++)
continue;
ALLOC(Firstch, Num_pts);
fp = &Firstch[Num_pts - 1];
- if (Iflag && isupper(*nsp))
- fp->first = tolower(*nsp);
+ if (Iflag && isupper((unsigned char)*nsp))
+ fp->first = tolower((unsigned char)*nsp);
else
fp->first = *nsp;
fp->pos = Seekpts[Num_pts - 1];
@@ -225,14 +221,14 @@ char **av;
if (Num_pts == 2)
puts("There was 1 string");
else
- printf("There were %d strings\n", Num_pts - 1);
+ printf("There were %ld strings\n", Num_pts - 1);
printf("Longest string: %lu byte%s\n", Tbl.str_longlen,
Tbl.str_longlen == 1 ? "" : "s");
printf("Shortest string: %lu byte%s\n", Tbl.str_shortlen,
Tbl.str_shortlen == 1 ? "" : "s");
}
- (void) fseek(outf, (off_t) 0, 0);
+ rewind(outf);
Tbl.str_version = htonl(Tbl.str_version);
Tbl.str_numstr = htonl(Num_pts - 1);
Tbl.str_longlen = htonl(Tbl.str_longlen);
@@ -251,7 +247,7 @@ char **av;
/*
* This routine evaluates arguments from the command line
*/
-getargs(argc, argv)
+void getargs(argc, argv)
int argc;
char **argv;
{
@@ -265,7 +261,7 @@ char **argv;
Delimch = *optarg;
if (!isascii(Delimch)) {
printf("bad delimiting character: '\\%o\n'",
- Delimch);
+ (unsigned char)Delimch);
}
break;
case 'i': /* ignore case in ordering */
@@ -304,7 +300,7 @@ char **argv;
}
}
-usage()
+void usage()
{
(void) fprintf(stderr,
"strfile [-iorsx] [-c char] sourcefile [datafile]\n");
@@ -315,11 +311,11 @@ usage()
* add_offset:
* Add an offset to the list, or write it out, as appropriate.
*/
-add_offset(fp, off)
+void add_offset(fp, off)
FILE *fp;
-off_t off;
+long off;
{
- off_t net;
+ long net;
if (!STORING_PTRS) {
net = htonl(off);
@@ -335,12 +331,11 @@ off_t off;
* do_order:
* Order the strings alphabetically (possibly ignoring case).
*/
-do_order()
+void do_order()
{
register int i;
- register off_t *lp;
+ register long *lp;
register STR *fp;
- extern int cmp_str();
Sort_1 = fopen(Infile, "r");
Sort_2 = fopen(Infile, "r");
@@ -359,38 +354,21 @@ do_order()
* cmp_str:
* Compare two strings in the file
*/
-char *
-unctrl(c)
-char c;
-{
- static char buf[3];
-
- if (isprint(c)) {
- buf[0] = c;
- buf[1] = '\0';
- }
- else if (c == 0177) {
- buf[0] = '^';
- buf[1] = '?';
- }
- else {
- buf[0] = '^';
- buf[1] = c + 'A' - 1;
- }
- return buf;
-}
-
-cmp_str(p1, p2)
+int cmp_str(p1, p2)
STR *p1, *p2;
{
register int c1, c2;
register int n1, n2;
+ static char s1[2], s2[2];
+ int r;
# define SET_N(nf,ch) (nf = (ch == '\n'))
-# define IS_END(ch,nf) (ch == Delimch && nf)
+# define IS_END(ch,nf) (ch == EOF || (ch == (unsigned char) Delimch && nf))
- c1 = p1->first;
- c2 = p2->first;
+ s1[0] = c1 = (unsigned char) p1->first;
+ s2[0] = c2 = (unsigned char) p2->first;
+ if ((r = strcoll(s1, s2)) != 0)
+ return r;
if (c1 != c2)
return c1 - c2;
@@ -399,9 +377,9 @@ STR *p1, *p2;
n1 = FALSE;
n2 = FALSE;
- while (!isalnum(c1 = getc(Sort_1)) && c1 != '\0')
+ while (!isalnum(c1 = getc(Sort_1)) && c1 != '\0' && c1 != EOF)
SET_N(n1, c1);
- while (!isalnum(c2 = getc(Sort_2)) && c2 != '\0')
+ while (!isalnum(c2 = getc(Sort_2)) && c2 != '\0' && c2 != EOF)
SET_N(n2, c2);
while (!IS_END(c1, n1) && !IS_END(c2, n2)) {
@@ -411,6 +389,10 @@ STR *p1, *p2;
if (isupper(c2))
c2 = tolower(c2);
}
+ s1[0] = c1;
+ s2[0] = c2;
+ if ((r = strcoll(s1, s2)) != 0)
+ return r;
if (c1 != c2)
return c1 - c2;
SET_N(n1, c1);
@@ -422,6 +404,10 @@ STR *p1, *p2;
c1 = 0;
if (IS_END(c2, n2))
c2 = 0;
+ s1[0] = c1;
+ s2[0] = c2;
+ if ((r = strcoll(s1, s2)) != 0)
+ return r;
return c1 - c2;
}
@@ -431,14 +417,13 @@ STR *p1, *p2;
* not to randomize across delimiter boundaries. All
* randomization is done within each block.
*/
-randomize()
+void randomize()
{
register int cnt, i;
- register off_t tmp;
- register off_t *sp;
- extern time_t time();
+ register long tmp;
+ register long *sp;
- srandom((int)(time((time_t *) NULL) + getpid()));
+ srandom((int)(time((time_t *) NULL) ^ getpid()));
Tbl.str_flags |= STR_RANDOM;
cnt = Tbl.str_numstr;
diff --git a/games/fortune/strfile/strfile.h b/games/fortune/strfile/strfile.h
index 9abc5f7..7d35acb 100644
--- a/games/fortune/strfile/strfile.h
+++ b/games/fortune/strfile/strfile.h
@@ -37,7 +37,7 @@
*/
#define STR_ENDSTRING(line,tbl) \
- ((line)[0] == (tbl).str_delim && (line)[1] == '\n')
+ (((unsigned char)(line)[0]) == (tbl).str_delim && (line)[1] == '\n')
typedef struct { /* information table */
#define VERSION 1
diff --git a/games/fortune/unstr/Makefile b/games/fortune/unstr/Makefile
index ad3075f..fa17ec6 100644
--- a/games/fortune/unstr/Makefile
+++ b/games/fortune/unstr/Makefile
@@ -2,6 +2,7 @@
PROG= unstr
NOMAN= noman
-CFLAGS+=-I${.CURDIR}/../strfile
+CFLAGS+=-Wall -I${.CURDIR}/../strfile
+.include "${.CURDIR}/../../Makefile.inc"
.include <bsd.prog.mk>
diff --git a/games/fortune/unstr/unstr.c b/games/fortune/unstr/unstr.c
index 78d584b..78a21fb 100644
--- a/games/fortune/unstr/unstr.c
+++ b/games/fortune/unstr/unstr.c
@@ -35,13 +35,13 @@
*/
#ifndef lint
-static char copyright[] =
+static const char copyright[] =
"@(#) Copyright (c) 1991, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)unstr.c 8.1 (Berkeley) 5/31/93";
+static const char sccsid[] = "@(#)unstr.c 8.1 (Berkeley) 5/31/93";
#endif /* not lint */
/*
@@ -57,15 +57,11 @@ static char sccsid[] = "@(#)unstr.c 8.1 (Berkeley) 5/31/93";
* Ken Arnold Aug 13, 1978
*/
-# include <machine/endian.h>
# include <sys/param.h>
-# include "strfile.h"
# include <stdio.h>
# include <ctype.h>
-
-# ifndef MAXPATHLEN
-# define MAXPATHLEN 1024
-# endif /* MAXPATHLEN */
+# include <string.h>
+# include "strfile.h"
char *Infile, /* name of input file */
Datafile[MAXPATHLEN], /* name of data file */
@@ -73,10 +69,10 @@ char *Infile, /* name of input file */
FILE *Inf, *Dataf;
-char *strcat(), *strcpy();
+void getargs(), order_unstr();
/* ARGSUSED */
-main(ac, av)
+void main(ac, av)
int ac;
char **av;
{
@@ -108,7 +104,7 @@ char **av;
exit(0);
}
-getargs(av)
+void getargs(av)
register char *av[];
{
if (!*++av) {
@@ -120,12 +116,12 @@ register char *av[];
(void) strcat(Datafile, ".dat");
}
-order_unstr(tbl)
+void order_unstr(tbl)
register STRFILE *tbl;
{
register int i;
register char *sp;
- auto off_t pos;
+ long pos;
char buf[BUFSIZ];
for (i = 0; i < tbl->str_numstr; i++) {
OpenPOWER on IntegriCloud