(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:
parent
543b0cba4f
commit
5d302eaad5
6 changed files with 131 additions and 150 deletions
|
@ -32,13 +32,14 @@
|
|||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include "misc.h"
|
||||
#include "xy.h"
|
||||
#include "nat.h"
|
||||
#include "sect.h"
|
||||
#include "file.h"
|
||||
#include <stdio.h>
|
||||
#include "common.h"
|
||||
#include "optlist.h"
|
||||
|
||||
|
@ -117,14 +118,42 @@ xyabsrange(struct natstr *np, struct range *src, struct range *dst)
|
|||
dst->height = src->height;
|
||||
}
|
||||
|
||||
void
|
||||
inputxy(coord *xp, coord *yp, natid cn)
|
||||
/*
|
||||
* Convert initial part of STR to normalized x-coordinate.
|
||||
* Return -1 on error. This works, as normalized coordinates are
|
||||
* non-negative.
|
||||
* Assign pointer to first character after the coordinate to *END,
|
||||
* unless END is a null pointer.
|
||||
*/
|
||||
coord
|
||||
strtox(char *str, char **end)
|
||||
{
|
||||
struct natstr *np;
|
||||
long l;
|
||||
|
||||
np = getnatp(cn);
|
||||
*xp = xabs(np, *xp);
|
||||
*yp = yabs(np, *yp);
|
||||
errno = 0;
|
||||
l = strtol(str, end, 10);
|
||||
if (*end == str || errno != 0)
|
||||
return -1;
|
||||
return XNORM(l);
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert initial part of STR to normalized y-coordinate.
|
||||
* Return -1 on error. This works, as normalized coordinates are
|
||||
* non-negative.
|
||||
* Assign pointer to first character after the coordinate to *END,
|
||||
* unless END is a null pointer.
|
||||
*/
|
||||
coord
|
||||
strtoy(char *str, char **end)
|
||||
{
|
||||
long l;
|
||||
|
||||
errno = 0;
|
||||
l = strtol(str, end, 10);
|
||||
if (*end == str || errno != 0)
|
||||
return -1;
|
||||
return YNORM(l);
|
||||
}
|
||||
|
||||
coord
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue