(index, rindex): Obsolete BSDisms; remove. Use standard strchr() and

strrchr() instead.
(setbuffer): Obsolete BSDism, unused; remove.
This commit is contained in:
Markus Armbruster 2004-01-08 18:15:13 +00:00
parent 4ae9c417b3
commit 64afd7747b
16 changed files with 29 additions and 227 deletions

View file

@ -33,10 +33,10 @@ include ../make.src
include ../make.defs
CFILES = bit.c dtable.c expect.c globals.c handle.c host.c \
hpux.c ioqueue.c ipglob.c login.c main.c queue.c saveargv.c \
ioqueue.c ipglob.c login.c main.c queue.c saveargv.c \
servcmd.c serverio.c tags.c termio.c termlib.c
OFILES = bit.o dtable.o expect.o globals.o handle.o host.o \
hpux.o ioqueue.o ipglob.o login.o main.o queue.o saveargv.o \
ioqueue.o ipglob.o login.o main.o queue.o saveargv.o \
servcmd.o serverio.o tags.o termio.o termlib.o
OBJFILES = bit.obj dtable.obj expect.obj globals.obj handle.obj host.obj \
hpux.obj ioqueue.obj ipglob.obj login.obj main.obj queue.obj saveargv.obj \

View file

@ -100,7 +100,7 @@ s_char *buf;
}
size -= n;
ptr[n] = '\0';
} while ((p = index(ptr, '\n')) == 0);
} while ((p = strchr(ptr, '\n')) == 0);
newline = 1 + p - buf;
*p = 0;
} else

View file

@ -1,66 +0,0 @@
/*
* Empire - A multi-player, client/server Internet based war game.
* Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* ---
*
* See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
* related information and legal notices. It is expected that any future
* projects/authors will amend these files as needed.
*
* ---
*
* hpux.c: hpux dependencies
*
* Known contributors to this file:
*
*/
#ifdef hpux
#include <memory.h>
#define NULL 0
#include "misc.h"
s_char *
rindex(sp, c)
register s_char *sp;
register int c;
{
register s_char *r;
r = NULL;
do {
if (*sp == c)
r = sp;
} while (*sp++);
return r;
}
s_char *
index(sp, c)
register s_char *sp;
register int c;
{
do {
if (*sp == c)
return (sp);
} while (*sp++);
return NULL;
}
#endif

View file

@ -37,6 +37,7 @@
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#if !defined(_WIN32)
#include <unistd.h>
#endif
@ -116,7 +117,7 @@ int kill_proc;
}
for (ptr = buf; !isspace(*ptr); ptr++) ;
ptr++;
p = index(ptr, '\n');
p = strchr(ptr, '\n');
if (p != 0)
*p = 0;
if (atoi(ptr) != CLIENTPROTO) {

View file

@ -84,25 +84,6 @@ void servercmd();
void ioq_drain();
#ifdef _WIN32
s_char *
index(str, c)
s_char *str;
char c;
{
static s_char *p;
p = str;
while (p && *p) {
if (*p == c)
return (s_char *)p;
p++;
}
return (s_char *)0;
}
#endif
int
main(ac, av)
int ac;

View file

@ -123,10 +123,6 @@ extern s_char *calloc();
extern s_char *ctime();
extern s_char *strncpy();
extern s_char *strcpy();
#ifndef NeXT
extern s_char *index();
extern s_char *rindex();
#endif /* NeXT */
#endif /* !aix && !sgi */
extern time_t time();

View file

@ -52,44 +52,6 @@ char *_c_copyright_header =
char *_ipglob_copyright_header =
"/*\n * Empire - A multi-player, client/server Internet based war game.\n * Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,\n * Ken Stevens, Steve McClure\n *\n * This program is free software; you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation; either version 2 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program; if not, write to the Free Software\n * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n *\n * ---\n *\n * See the \"LEGAL\", \"LICENSE\", \"CREDITS\" and \"README\" files for all the\n * related information and legal notices. It is expected that any future\n * projects/authors will amend these files as needed.\n *\n * ---\n *\n * ipglob.c: This is an auto-generated file.\n * \n * Known contributors to this file:\n * Automatically generated by doconfig.c\n */\n\n";
#if defined(_WIN32)
char *
rindex(char *path, char c)
{
int i;
char *cp;
i = strlen(path);
cp = &path[i - 1];
while (i) {
if (*cp == c)
return cp;
i--;
cp--;
}
return (char *)0;
}
char *
index(char *path, char c)
{
int i;
char *cp;
cp = &path[0];
i = 0;
while (path[i]) {
if (*cp == c)
return cp;
i++;
cp++;
}
return (char *)0;
}
#endif
int
main()
@ -103,14 +65,14 @@ main()
exit(-1);
}
#if !defined(_WIN32)
cp = (char *)rindex(pathname, '/');
cp = strrchr(pathname, '/');
*cp = '\0';
cp = (char *)rindex(pathname, '/');
cp = strrchr(pathname, '/');
*cp = '\0';
#else
cp = (char *)rindex(pathname, '\\');
cp = strrchr(pathname, '\\');
*cp = '\0';
cp = (char *)rindex(pathname, '\\');
cp = strrchr(pathname, '\\');
*cp = '\0';
#endif
printf("Configuring...\n");
@ -227,7 +189,7 @@ wrgamesdef(char *filename)
strcpy(buf, EF);
if (strlen(buf) > 0)
c = buf[strlen(buf) - 1];
if (index("dhm", c) && strlen(buf) > 0) {
if (strchr("dhm", c) && strlen(buf) > 0) {
s_p_etu = atoi(buf);
if (c == 'd')
s_p_etu =

View file

@ -34,6 +34,7 @@
*/
#include <ctype.h>
#include <string.h>
#include "misc.h"
#include "player.h"
#include "var.h"
@ -116,7 +117,7 @@ bomb(void)
getstarg(player->argp[3], "pinpoint, or strategic? ", buf)) == 0)
return RET_SYN;
mission = *p;
if (index("ps", mission) == 0)
if (strchr("ps", mission) == 0)
return RET_SYN;
if ((p = getstarg(player->argp[4], "assembly point? ", buf)) == 0
|| *p == 0)

View file

@ -114,7 +114,7 @@ info(void)
/*
* don't let sneaky people go outside the info directory
*/
else if (NULL != (bp = rindex(player->argp[1], '/')))
else if (NULL != (bp = strrchr(player->argp[1], '/')))
bp++;
else
bp = player->argp[1];
@ -394,11 +394,11 @@ info(void)
* don't let sneaky people go outside the info directory
*/
bp = player->argp[1];
if (NULL != (bp2 = rindex(bp, '/')))
if (NULL != (bp2 = strrchr(bp, '/')))
bp = ++bp2;
if (NULL != (bp2 = rindex(bp, '\\')))
if (NULL != (bp2 = strrchr(bp, '\\')))
bp = ++bp2;
if (NULL != (bp2 = rindex(bp, ':')))
if (NULL != (bp2 = strrchr(bp, ':')))
bp = ++bp2;
if (!*bp)
bp = "TOP";

View file

@ -32,6 +32,7 @@
*/
#include <ctype.h>
#include <string.h>
#include "misc.h"
#include "player.h"
#include "file.h"
@ -54,7 +55,7 @@ offs(void)
yorg = natp->nat_yorg;
if (!(cp = getstarg(player->argp[1], "sector or nation? ", buf)))
return RET_SYN;
if (index(cp, ',')) { /* x, y pair for offset */
if (strchr(cp, ',')) { /* x, y pair for offset */
if (!sarg_xy(cp, &dx, &dy)) {
pr("Bad sector designation.\n");
return RET_SYN;

View file

@ -36,6 +36,7 @@
#include "gen.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "common.h"
@ -67,10 +68,10 @@ kw_read(FILE * fp)
/* Allow for comments.. any line starting with # */
if (buf[0] == '#')
continue;
p = rindex(buf, '\n');
p = strrchr(buf, '\n');
if (p != 0)
*p = 0;
if ((p = index(buf, ':')) == 0) {
if ((p = strchr(buf, ':')) == 0) {
logerror("kw_read: Bad keyword line #%d\n", n);
return 0;
}
@ -123,7 +124,7 @@ kw_parse(int type, s_char *text, int *data)
text = get_time(text, &data[0]);
break;
case CF_TIMERANGE:
if ((next = index(text, '-')) == 0)
if ((next = strchr(text, '-')) == 0)
return 0;
next++;
if ((text = get_time(text, &data[0])) == 0)

View file

@ -91,11 +91,11 @@ logerror(s_char *format, ...)
loginit();
va_start(list, format);
vsprintf(buf, format, list);
if ((p = index(buf, '\n')) != 0)
if ((p = strchr(buf, '\n')) != 0)
*p = 0;
(void)time(&now);
strcpy(cbuf, ctime(&now));
if ((p = index(cbuf, '\n')) != 0)
if ((p = strchr(cbuf, '\n')) != 0)
*p = 0;
(void)sprintf(buf1, "%s %s\n", cbuf, buf);
if ((logf = open(logfile, O_WRONLY | O_CREAT | O_APPEND, 0666)) < 0)

View file

@ -36,13 +36,13 @@ LIB = $(SRCDIR)/lib/libgen.a
NTLIB = $(SRCDIR)\lib\libgen.lib
OBJS = atoip.o bit.o chance.o copy.o disassoc.o dtable.o \
emp_config.o getstarg.o getstring.o hpux.o inet.o io.o \
emp_config.o getstarg.o getstring.o inet.o io.o \
io_mask.o ioqueue.o lock.o mapdist.o minmax.o numstr.o onearg.o \
parse.o plur.o queue.o round.o scthash.o \
strdup.o
NTOBJS = atoip.obj bit.obj chance.obj copy.obj disassoc.obj dtable.obj \
emp_config.obj getstarg.obj getstring.obj hpux.obj \
emp_config.obj getstarg.obj getstring.obj \
inet.obj io.obj io_mask.obj ioqueue.obj lock.obj mapdist.obj minmax.obj \
numstr.obj onearg.obj parse.obj plur.obj queue.obj round.obj \
scthash.obj strdup.obj

View file

@ -1,76 +0,0 @@
/*
* Empire - A multi-player, client/server Internet based war game.
* Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* ---
*
* See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
* related information and legal notices. It is expected that any future
* projects/authors will amend these files as needed.
*
* ---
*
* hpux.c: Things specific to hpux
*
* Known contributors to this file:
*
*/
#include "misc.h"
#ifdef hpux
#include <stdio.h>
setbuffer(fp, buf, size)
FILE *fp;
s_char *buf;
int size;
{
if (size > BUFSIZ)
setbuf(fp, buf);
/* XXX else report error */
}
s_char *
rindex(sp, c)
register s_char *sp;
register int c;
{
register s_char *r;
r = NULL;
do {
if (*sp == c)
r = sp;
} while (*sp++);
return r;
}
s_char *
index(sp, c)
register s_char *sp;
register int c;
{
do {
if (*sp == c)
return (sp);
} while (*sp++);
return NULL;
}
#endif

View file

@ -160,7 +160,7 @@ pr_player(struct player *pl, int id, s_char *buf)
if (pl->curid == -1) {
outid(pl, id);
}
p = index(bp, '\n');
p = strchr(bp, '\n');
if (p != 0) {
len = (p - bp) + 1;
if (pl->command && (pl->command->c_flags & C_MOD))

View file

@ -32,6 +32,7 @@
*/
#include <ctype.h>
#include <string.h>
#include "misc.h"
#include "player.h"
#include "xy.h"
@ -63,7 +64,7 @@ sarg_type(s_char *ptr)
return NS_DIST;
if (c == '*')
return NS_ALL;
if (c == '#' || index(ptr, ',') != 0)
if (c == '#' || strchr(ptr, ',') != 0)
return NS_AREA;
if (isdigit(c))
return NS_LIST;