From 64afd7747b31e8c8a8275fee8280b675534a2649 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Thu, 8 Jan 2004 18:15:13 +0000 Subject: [PATCH] (index, rindex): Obsolete BSDisms; remove. Use standard strchr() and strrchr() instead. (setbuffer): Obsolete BSDism, unused; remove. --- src/client/Makefile | 4 +-- src/client/expect.c | 2 +- src/client/hpux.c | 66 ---------------------------------- src/client/login.c | 3 +- src/client/main.c | 19 ---------- src/client/misc.h | 4 --- src/doconfig/doconfig.c | 48 +++---------------------- src/lib/commands/bomb.c | 3 +- src/lib/commands/info.c | 8 ++--- src/lib/commands/offs.c | 3 +- src/lib/common/keyword.c | 7 ++-- src/lib/common/log.c | 4 +-- src/lib/gen/Makefile | 4 +-- src/lib/gen/hpux.c | 76 ---------------------------------------- src/lib/subs/pr.c | 2 +- src/lib/subs/sarg.c | 3 +- 16 files changed, 29 insertions(+), 227 deletions(-) delete mode 100644 src/client/hpux.c delete mode 100644 src/lib/gen/hpux.c diff --git a/src/client/Makefile b/src/client/Makefile index 407d8738f..64b8268c6 100644 --- a/src/client/Makefile +++ b/src/client/Makefile @@ -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 \ diff --git a/src/client/expect.c b/src/client/expect.c index 75233f8c6..803f41030 100644 --- a/src/client/expect.c +++ b/src/client/expect.c @@ -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 diff --git a/src/client/hpux.c b/src/client/hpux.c deleted file mode 100644 index 8071530f0..000000000 --- a/src/client/hpux.c +++ /dev/null @@ -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 -#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 diff --git a/src/client/login.c b/src/client/login.c index cd95f5f26..c94ad1e81 100644 --- a/src/client/login.c +++ b/src/client/login.c @@ -37,6 +37,7 @@ #include #include +#include #if !defined(_WIN32) #include #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) { diff --git a/src/client/main.c b/src/client/main.c index 80821f67d..ecc952be5 100644 --- a/src/client/main.c +++ b/src/client/main.c @@ -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; diff --git a/src/client/misc.h b/src/client/misc.h index e54dc81ef..25ff05d39 100644 --- a/src/client/misc.h +++ b/src/client/misc.h @@ -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(); diff --git a/src/doconfig/doconfig.c b/src/doconfig/doconfig.c index eb9851d4e..6a733d9fe 100644 --- a/src/doconfig/doconfig.c +++ b/src/doconfig/doconfig.c @@ -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 = diff --git a/src/lib/commands/bomb.c b/src/lib/commands/bomb.c index 2a8ecaa65..cbf44321f 100644 --- a/src/lib/commands/bomb.c +++ b/src/lib/commands/bomb.c @@ -34,6 +34,7 @@ */ #include +#include #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) diff --git a/src/lib/commands/info.c b/src/lib/commands/info.c index 4af391f38..ce6e0654a 100644 --- a/src/lib/commands/info.c +++ b/src/lib/commands/info.c @@ -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"; diff --git a/src/lib/commands/offs.c b/src/lib/commands/offs.c index f94e2cb33..52d977bdb 100644 --- a/src/lib/commands/offs.c +++ b/src/lib/commands/offs.c @@ -32,6 +32,7 @@ */ #include +#include #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; diff --git a/src/lib/common/keyword.c b/src/lib/common/keyword.c index 6a502d8b5..cb882abb4 100644 --- a/src/lib/common/keyword.c +++ b/src/lib/common/keyword.c @@ -36,6 +36,7 @@ #include "gen.h" #include #include +#include #include #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) diff --git a/src/lib/common/log.c b/src/lib/common/log.c index e0d5e88e0..dcc997d95 100644 --- a/src/lib/common/log.c +++ b/src/lib/common/log.c @@ -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) diff --git a/src/lib/gen/Makefile b/src/lib/gen/Makefile index 443935a67..43a056818 100644 --- a/src/lib/gen/Makefile +++ b/src/lib/gen/Makefile @@ -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 diff --git a/src/lib/gen/hpux.c b/src/lib/gen/hpux.c deleted file mode 100644 index ac8f99aba..000000000 --- a/src/lib/gen/hpux.c +++ /dev/null @@ -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 - -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 diff --git a/src/lib/subs/pr.c b/src/lib/subs/pr.c index 0bfa4fe6f..0f30d222d 100644 --- a/src/lib/subs/pr.c +++ b/src/lib/subs/pr.c @@ -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)) diff --git a/src/lib/subs/sarg.c b/src/lib/subs/sarg.c index 2f3598d96..fad8f918e 100644 --- a/src/lib/subs/sarg.c +++ b/src/lib/subs/sarg.c @@ -32,6 +32,7 @@ */ #include +#include #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; -- 2.43.0