OK - there are (at least) two issues here:
1. Fixing parsepoint and parsepoints to return truncated integer values. This is easy.
2. Changing MCU_strtol to return the true value rather than a truncated integer.
Without #2, parsepoint and parsepoints can only work with truncated values, not rounded values. That was my first attempt, and it works as designed. No other side-effects into other functions. Rounding rather than truncating can't happen without changing MCU_strtol or without changing parsepoint and parsepoints to use a different function that allows for the parsing of non-integer numbers.
graphic points
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, LCMark
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: graphic points
Looked at the code again last night, made a couple of changes, and pushed to github. Looks like I need to integrate the docs changes before I'm ready to issue a pull request, but
The change to MCU_strtol rounds up or down if a non-integer value is entered, and does this properly for both positive and negative values.
This change is *necessary* to keep the parser from stopping on encountering a decimal point. Otherwise "42.43,44.45" becomes
42
43,44
45
which completely screws up setting the points of a graphic.
After that, parsepoint and parsepoints just allow real numbers and cast the result from an int4 to an int2.
The change to MCU_strtol rounds up or down if a non-integer value is entered, and does this properly for both positive and negative values.
This change is *necessary* to keep the parser from stopping on encountering a decimal point. Otherwise "42.43,44.45" becomes
42
43,44
45
which completely screws up setting the points of a graphic.
After that, parsepoint and parsepoints just allow real numbers and cast the result from an int4 to an int2.
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: graphic points
Pull request submitted ("fix-integer-points").
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev