(strtox, strtoy): New. Use it instead of inputxy() to avoid the

double-remainder problem: x-coordinate SHRT_MAX+1 is truncated to 0 by
cast to coord, then converted by xabs().  This is wrong unless WORLD_X
divides SHRT_MAX+1.
(sarg_xy, sarg_getrange, sarg_range): Use them.
(inputxy): No longer used, remove.

(sarg_type): Use NS_UNDEF instead of 0.

(sarg_list): Change confusing loop control.  Properly diagnose
overlong lists; used to silently ignore list tail and return MAX+1,
which made a later snxtitem_list() fail.

(atoip): No longer used, remove.  Parsing was broken anyway.

(sarg_type, sarg_xy, sarg_area, sarg_range, sarg_list, sarg_getrange):
Use plain char * instead of s_char *.
This commit is contained in:
Markus Armbruster 2004-04-07 17:13:47 +00:00
parent 543b0cba4f
commit 5d302eaad5
6 changed files with 131 additions and 150 deletions

View file

@ -35,13 +35,13 @@ include ../../make.defs
LIB = $(SRCDIR)/lib/libgen.a
NTLIB = $(SRCDIR)\lib\libgen.lib
OBJS = atoip.o chance.o copy.o disassoc.o \
OBJS = chance.o copy.o disassoc.o \
emp_config.o getstarg.o getstring.o io.o \
ioqueue.o mapdist.o minmax.o numstr.o onearg.o \
parse.o plur.o queue.o round.o scthash.o \
strdup.o
NTOBJS = atoip.obj chance.obj copy.obj disassoc.obj \
NTOBJS = chance.obj copy.obj disassoc.obj \
emp_config.obj getstarg.obj getstring.obj \
io.obj ioqueue.obj mapdist.obj minmax.obj \
numstr.obj onearg.obj parse.obj plur.obj queue.obj round.obj \

View file

@ -1,60 +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.
*
* ---
*
* atoip.c: Convert from decimal string to integer.
*
* Known contributors to this file:
*
*/
#include "gen.h"
int
atoip(s_char **ptrptr)
{
register int num;
register s_char *cp;
register int neg;
if (ptrptr == 0 || *ptrptr == 0)
return 0;
cp = *ptrptr;
num = 0;
neg = 0;
loop:
while (*cp == ' ' || *cp == '\t')
cp++;
if (*cp == '-') {
neg++;
cp++;
goto loop;
}
while (*cp >= '0' && *cp <= '9')
num = num * 10 + *cp++ - '0';
*ptrptr = cp;
return (neg ? -num : num);
}