(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

@ -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;