[comp.windows.x] XParseGeometry bug: let's try this again

bilbo.geoff@LOCUS.UCLA.EDU.UUCP (02/12/87)

You would think that people who know better wouldn't put out untested
bug fixes.  Nevertheless, I did, and of course it was wrong.

Disregard my previous bug fix (which added a ++ to an atoi call) for
XParseGeometry.  A corrected (and tested!) fix follows, which also
fixes other problems.

Description:  XParseGeometry does not correctly handle specifications that
	include a negative number in the position specification.  Also,
	there are some indentation problems in the routine.

Repeat-By:  Run 'xclock -bw 8 =100x100+-4+-4'.  The clock should come up
	in the upper-left corner with the top and left borders half-size.
	Instead, the clock will come up slightly offset from the lower-left
	corner.

Fix:  Apply the following patch with Larry Wall's "patch" program.

Index: XParseGeometry.c

18,19c18,20
< 	for (i = 0; i < len; i++)
< 	if (c == what [i]) return (--search);
---
> 		for (i = 0; i < len; i++)
> 			if (c == what [i])
> 				return (--search);
40c41
< 	char *strind;
---
> 	register char *strind;
45c46
< 	string++;  /* ignore possible '=' at beginning of geometry spec */
---
> 		string++;  /* ignore possible '=' at beg of geometry spec */
60,61c61,66
< 		if (*strind == '-') mask |= XNegative;
< 		*x = atoi (strind++);
---
> 		if (*strind++ == '-') {
> 			mask |= XNegative;
> 			*x = -atoi (strind);
> 		}
> 		else
> 			*x = atoi (strind);
63,65c68,74
< 		if (strind = strscan (strind, "+-")) {
< 			if (*strind == '-') mask |= YNegative;
< 			*y = atoi (strind);
---
> 		if (strind = strscan (++strind, "+-")) {
> 			if (*strind++ == '-') {
> 				mask |= YNegative;
> 				*y = -atoi (strind);
> 			}
> 			else
> 				*y = atoi (strind);

	Geoff Kuenning
	Interrupt Technology Corporation
	geoff@ITCorp.com