(copy, atopi, same): Remove, use strcpy(), atoi(), strcmp(). Callers
changed. Remove empty source files.
This commit is contained in:
parent
9c90022634
commit
d0feb8570a
11 changed files with 11 additions and 311 deletions
|
@ -149,7 +149,6 @@ extern long random();
|
||||||
double dmax _PROTO((double n1, double n2));
|
double dmax _PROTO((double n1, double n2));
|
||||||
double dmin _PROTO((double n1, double n2));
|
double dmin _PROTO((double n1, double n2));
|
||||||
|
|
||||||
extern s_char *copy _PROTO((s_char *s1, s_char *s2));
|
|
||||||
extern s_char *numstr _PROTO((s_char buf[], int n));
|
extern s_char *numstr _PROTO((s_char buf[], int n));
|
||||||
extern s_char *esplur _PROTO((int n));
|
extern s_char *esplur _PROTO((int n));
|
||||||
extern s_char *splur _PROTO((int n));
|
extern s_char *splur _PROTO((int n));
|
||||||
|
|
|
@ -410,11 +410,9 @@ extern int emp_config(char *file);
|
||||||
extern void print_config(FILE * fp);
|
extern void print_config(FILE * fp);
|
||||||
|
|
||||||
extern int atoip(s_char **);
|
extern int atoip(s_char **);
|
||||||
extern int atopi(s_char *);
|
|
||||||
extern int roll(int);
|
extern int roll(int);
|
||||||
extern int roundavg(double);
|
extern int roundavg(double);
|
||||||
extern int chance(double);
|
extern int chance(double);
|
||||||
extern s_char *copy(register s_char *, register s_char *);
|
|
||||||
extern void disassoc(void);
|
extern void disassoc(void);
|
||||||
extern int getfdtablesize(void);
|
extern int getfdtablesize(void);
|
||||||
extern void setfdtablesize(int, int);
|
extern void setfdtablesize(int, int);
|
||||||
|
@ -447,7 +445,6 @@ extern s_char *iesplur(int);
|
||||||
extern s_char *plur(int, s_char *, s_char *);
|
extern s_char *plur(int, s_char *, s_char *);
|
||||||
extern int ldround(double, int);
|
extern int ldround(double, int);
|
||||||
extern int roundintby(int, int);
|
extern int roundintby(int, int);
|
||||||
extern int same(register s_char *, register s_char *);
|
|
||||||
extern int scthash(register int, register int, int);
|
extern int scthash(register int, register int, int);
|
||||||
#ifdef NOSTRDUP
|
#ifdef NOSTRDUP
|
||||||
extern char *strdup(char *x);
|
extern char *strdup(char *x);
|
||||||
|
|
|
@ -102,7 +102,6 @@ extern double dmax();
|
||||||
extern double dmin();
|
extern double dmin();
|
||||||
|
|
||||||
extern s_char *fmt();
|
extern s_char *fmt();
|
||||||
extern s_char *copy();
|
|
||||||
extern s_char *numstr();
|
extern s_char *numstr();
|
||||||
extern s_char *esplur();
|
extern s_char *esplur();
|
||||||
extern s_char *splur();
|
extern s_char *splur();
|
||||||
|
|
|
@ -90,7 +90,7 @@ chan(void)
|
||||||
return RET_SYN;
|
return RET_SYN;
|
||||||
p[sizeof(us->nat_cnam) - 1] = 0;
|
p[sizeof(us->nat_cnam) - 1] = 0;
|
||||||
for (cn = 0; NULL != (natp = getnatp(cn)); cn++) {
|
for (cn = 0; NULL != (natp = getnatp(cn)); cn++) {
|
||||||
if (same(p, natp->nat_cnam)) {
|
if (!strcmp(p, natp->nat_cnam)) {
|
||||||
pr("Country #%d is already called `%s'!\n", cn, p);
|
pr("Country #%d is already called `%s'!\n", cn, p);
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,8 +128,8 @@ do_treaty(void)
|
||||||
cp = getstring("Proposed treaty duration? (days) ", buf);
|
cp = getstring("Proposed treaty duration? (days) ", buf);
|
||||||
if (cp == 0)
|
if (cp == 0)
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
j = atopi(cp);
|
j = atoi(cp);
|
||||||
if (j == 0) {
|
if (j <= 0) {
|
||||||
pr("Bad treaty duration.\n");
|
pr("Bad treaty duration.\n");
|
||||||
return RET_SYN;
|
return RET_SYN;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,17 +35,17 @@ include ../../make.defs
|
||||||
LIB = $(SRCDIR)/lib/libgen.a
|
LIB = $(SRCDIR)/lib/libgen.a
|
||||||
NTLIB = $(SRCDIR)\lib\libgen.lib
|
NTLIB = $(SRCDIR)\lib\libgen.lib
|
||||||
|
|
||||||
OBJS = atoip.o atopi.o bit.o chance.o copy.o disassoc.o dtable.o \
|
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 hpux.o inet.o io.o \
|
||||||
io_mask.o ioqueue.o lock.o mapdist.o minmax.o numstr.o onearg.o \
|
io_mask.o ioqueue.o lock.o mapdist.o minmax.o numstr.o onearg.o \
|
||||||
parse.o plur.o queue.o round.o same.o scthash.o \
|
parse.o plur.o queue.o round.o scthash.o \
|
||||||
strdup.o vsprintf.o
|
strdup.o
|
||||||
|
|
||||||
NTOBJS = atoip.obj atopi.obj bit.obj chance.obj copy.obj disassoc.obj \
|
NTOBJS = atoip.obj bit.obj chance.obj copy.obj disassoc.obj dtable.obj \
|
||||||
dtable.obj emp_config.obj getstarg.obj getstring.obj hpux.obj \
|
emp_config.obj getstarg.obj getstring.obj hpux.obj \
|
||||||
inet.obj io.obj io_mask.obj ioqueue.obj lock.obj mapdist.obj minmax.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 same.obj \
|
numstr.obj onearg.obj parse.obj plur.obj queue.obj round.obj \
|
||||||
scthash.obj strdup.obj vsprintf.obj
|
scthash.obj strdup.obj
|
||||||
|
|
||||||
all: $(LIB)
|
all: $(LIB)
|
||||||
|
|
||||||
|
|
|
@ -1,55 +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.
|
|
||||||
*
|
|
||||||
* ---
|
|
||||||
*
|
|
||||||
* atopi.c: Return positive integer from string.
|
|
||||||
*
|
|
||||||
* Known contributors to this file:
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gen.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* atopi.c
|
|
||||||
*
|
|
||||||
* from PSL Empire, 1985
|
|
||||||
*/
|
|
||||||
|
|
||||||
int
|
|
||||||
atopi(s_char *p)
|
|
||||||
{
|
|
||||||
register int r11;
|
|
||||||
|
|
||||||
if (p) {
|
|
||||||
r11 = atoi(p);
|
|
||||||
if (r11 < 0)
|
|
||||||
r11 = -r11;
|
|
||||||
return r11;
|
|
||||||
} else {
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -37,13 +37,6 @@
|
||||||
#include "gen.h"
|
#include "gen.h"
|
||||||
#include "optlist.h"
|
#include "optlist.h"
|
||||||
|
|
||||||
s_char *
|
|
||||||
copy(register s_char *s1, register s_char *s2)
|
|
||||||
{
|
|
||||||
while ((*s2++ = *s1++) != 0) ;
|
|
||||||
return s2 - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef hpux
|
#ifdef hpux
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
|
|
||||||
|
|
|
@ -1,45 +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.
|
|
||||||
*
|
|
||||||
* ---
|
|
||||||
*
|
|
||||||
* same.c: Return true if strings are the same
|
|
||||||
*
|
|
||||||
* Known contributors to this file:
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "misc.h"
|
|
||||||
#include "gen.h"
|
|
||||||
|
|
||||||
int
|
|
||||||
same(register s_char *s1, register s_char *s2)
|
|
||||||
{
|
|
||||||
while (*s1 == *s2++) {
|
|
||||||
if (*s1++ == 0)
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -1,188 +0,0 @@
|
||||||
#if !defined(_WIN32)
|
|
||||||
#ifndef __STDC__
|
|
||||||
|
|
||||||
/* Portable vsprintf by Robert A. Larson <blarson@skat.usc.edu> */
|
|
||||||
|
|
||||||
/* Copyright 1989 Robert A. Larson.
|
|
||||||
* Distribution in any form is allowed as long as the author
|
|
||||||
* retains credit, changes are noted by their author and the
|
|
||||||
* copyright message remains intact. This program comes as-is
|
|
||||||
* with no warentee of fitness for any purpouse.
|
|
||||||
*
|
|
||||||
* Thanks to Doug Gwen, Chris Torek, and others who helped clarify
|
|
||||||
* the ansi printf specs.
|
|
||||||
*
|
|
||||||
* Please send any bug fixes and improvments to blarson@skat.usc.edu .
|
|
||||||
* The use of goto is NOT a bug.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Feb 7, 1989 blarson First usenet release */
|
|
||||||
|
|
||||||
/* This code implements the vsprintf function, without relying on
|
|
||||||
* the existance of _doprint or other system specific code.
|
|
||||||
*
|
|
||||||
* Define NOVOID if void * is not a supported type.
|
|
||||||
*
|
|
||||||
* Two compile options are available for efficency:
|
|
||||||
* INTSPRINTF should be defined if sprintf is int and returns
|
|
||||||
* the number of chacters formated.
|
|
||||||
* LONGINT should be defined if sizeof(long) == sizeof(int)
|
|
||||||
*
|
|
||||||
* They only make the code smaller and faster, they need not be
|
|
||||||
* defined.
|
|
||||||
*
|
|
||||||
* UNSIGNEDSPECIAL should be defined if unsigned is treated differently
|
|
||||||
* than int in argument passing. If this is definded, and LONGINT is not,
|
|
||||||
* the compiler must support the type unsingned long.
|
|
||||||
*
|
|
||||||
* Most quirks and bugs of the available sprintf fuction are duplicated,
|
|
||||||
* however * in the width and precision fields will work correctly
|
|
||||||
* even if sprintf does not support this, as will the n format.
|
|
||||||
*
|
|
||||||
* Bad format strings, or those with very long width and precision
|
|
||||||
* fields (including expanded * fields) will cause undesired results.
|
|
||||||
*/
|
|
||||||
#include "misc.h"
|
|
||||||
#include "gen.h"
|
|
||||||
|
|
||||||
#ifdef OSK /* os9/68k can take advantage of both */
|
|
||||||
#define LONGINT
|
|
||||||
#define INTSPRINTF
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define NOVOID
|
|
||||||
|
|
||||||
/* This must be a typedef not a #define! */
|
|
||||||
#ifdef NOVOID
|
|
||||||
typedef s_char *pointer;
|
|
||||||
#else
|
|
||||||
typedef void *pointer;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef INTSPRINTF
|
|
||||||
#define Sprintf(string,format,arg) (sprintf((string),(format),(arg)))
|
|
||||||
#else
|
|
||||||
#define Sprintf(string,format,arg) (\
|
|
||||||
sprintf((string),(format),(arg)),\
|
|
||||||
strlen(string)\
|
|
||||||
)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
typedef int *intp;
|
|
||||||
|
|
||||||
int
|
|
||||||
vsprintf(dest, format, args)
|
|
||||||
s_char *dest;
|
|
||||||
register s_char *format;
|
|
||||||
va_list args;
|
|
||||||
{
|
|
||||||
register s_char *dp = dest;
|
|
||||||
register s_char c;
|
|
||||||
register s_char *tp;
|
|
||||||
s_char tempfmt[64];
|
|
||||||
#ifndef LONGINT
|
|
||||||
int longflag;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
tempfmt[0] = '%';
|
|
||||||
while (c = *format++) {
|
|
||||||
if (c == '%') {
|
|
||||||
tp = &tempfmt[1];
|
|
||||||
#ifndef LONGINT
|
|
||||||
longflag = 0;
|
|
||||||
#endif
|
|
||||||
continue_format:
|
|
||||||
switch (c = *format++) {
|
|
||||||
case 's':
|
|
||||||
*tp++ = c;
|
|
||||||
*tp = '\0';
|
|
||||||
dp += Sprintf(dp, tempfmt, va_arg(args, s_char *));
|
|
||||||
break;
|
|
||||||
case 'u':
|
|
||||||
case 'x':
|
|
||||||
case 'o':
|
|
||||||
case 'X':
|
|
||||||
#ifdef UNSIGNEDSPECIAL
|
|
||||||
*tp++ = c;
|
|
||||||
*tp = '\0';
|
|
||||||
#ifndef LONGINT
|
|
||||||
if (longflag)
|
|
||||||
dp +=
|
|
||||||
Sprintf(dp, tempfmt, va_arg(args, unsigned long));
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
dp += Sprintf(dp, tempfmt, va_arg(args, unsigned));
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case 'd':
|
|
||||||
case 'c':
|
|
||||||
case 'i':
|
|
||||||
*tp++ = c;
|
|
||||||
*tp = '\0';
|
|
||||||
#ifndef LONGINT
|
|
||||||
if (longflag)
|
|
||||||
dp += Sprintf(dp, tempfmt, va_arg(args, long));
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
dp += Sprintf(dp, tempfmt, va_arg(args, int));
|
|
||||||
break;
|
|
||||||
case 'f':
|
|
||||||
case 'e':
|
|
||||||
case 'E':
|
|
||||||
case 'g':
|
|
||||||
case 'G':
|
|
||||||
*tp++ = c;
|
|
||||||
*tp = '\0';
|
|
||||||
dp += Sprintf(dp, tempfmt, va_arg(args, double));
|
|
||||||
break;
|
|
||||||
case 'p':
|
|
||||||
*tp++ = c;
|
|
||||||
*tp = '\0';
|
|
||||||
dp += Sprintf(dp, tempfmt, va_arg(args, pointer));
|
|
||||||
break;
|
|
||||||
case '-':
|
|
||||||
case '+':
|
|
||||||
case '0':
|
|
||||||
case '1':
|
|
||||||
case '2':
|
|
||||||
case '3':
|
|
||||||
case '4':
|
|
||||||
case '5':
|
|
||||||
case '6':
|
|
||||||
case '7':
|
|
||||||
case '8':
|
|
||||||
case '9':
|
|
||||||
case '.':
|
|
||||||
case ' ':
|
|
||||||
case '#':
|
|
||||||
case 'h':
|
|
||||||
*tp++ = c;
|
|
||||||
goto continue_format;
|
|
||||||
case 'l':
|
|
||||||
#ifndef LONGINT
|
|
||||||
longflag = 1;
|
|
||||||
*tp++ = c;
|
|
||||||
#endif
|
|
||||||
goto continue_format;
|
|
||||||
case '*':
|
|
||||||
tp += Sprintf(tp, "%d", va_arg(args, int));
|
|
||||||
goto continue_format;
|
|
||||||
case 'n':
|
|
||||||
*va_arg(args, intp) = dp - dest;
|
|
||||||
break;
|
|
||||||
case '%':
|
|
||||||
default:
|
|
||||||
*dp++ = c;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
*dp++ = c;
|
|
||||||
}
|
|
||||||
*dp = '\0';
|
|
||||||
return dp - dest;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* __STDC__ */
|
|
||||||
#endif
|
|
|
@ -84,7 +84,7 @@ getcommand(s_char *combufp)
|
||||||
player_commands_index = 0;
|
player_commands_index = 0;
|
||||||
sprintf(player_commands[player_commands_index], "%3d %3d %s",
|
sprintf(player_commands[player_commands_index], "%3d %3d %s",
|
||||||
player_commands_index, player->cnum, buf);
|
player_commands_index, player->cnum, buf);
|
||||||
copy(buf, combufp);
|
strcpy(combufp, buf);
|
||||||
return (strlen(combufp));
|
return (strlen(combufp));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue