Re: [PATCH xrandr v4 2/5] xrandr: stricter --scale argument parsing

2018-02-06 Thread Keith Packard
Giuseppe Bilotta writes: > Actually, it just occurred to me that a negative scaling factor could > be interpreted as a reflection in that direction (i.e. --scale -2x1 > could be aliased to --scale 2x1 --reflect x). Or is it not worth it? Not worth it in my eye --

Re: [PATCH xrandr v4 2/5] xrandr: stricter --scale argument parsing

2018-02-06 Thread Giuseppe Bilotta
On Tue, Feb 6, 2018 at 8:03 PM, Keith Packard wrote: > Giuseppe Bilotta writes: >> I'll add the positive check for both scale and gamma and respin the patch. > > Thanks. Actually, it just occurred to me that a negative scaling factor could be

Re: [PATCH xrandr v4 2/5] xrandr: stricter --scale argument parsing

2018-02-06 Thread Keith Packard
Giuseppe Bilotta writes: > Joking aside, this does mean that strtod could be a good option when > parsing the single value. The check would be more verbose though, so I > think I'll stick with sscanf. Sure, your sscanf pattern is pretty simple to understand. > I'll

Re: [PATCH xrandr v4 2/5] xrandr: stricter --scale argument parsing

2018-02-06 Thread Giuseppe Bilotta
On Tue, Feb 6, 2018 at 3:43 AM, Keith Packard wrote: > No, strtod requires a non-empty sequence of digits. Woah. My whole life is a lie … (I guess it's my fault for never bothering to actually verify this.) > strtod is actually not a terrible function (surprising for libc, I

Re: [PATCH xrandr v4 2/5] xrandr: stricter --scale argument parsing

2018-02-05 Thread Keith Packard
Giuseppe Bilotta writes: > Not in the sense I mean above. If the string is a sequences of > whitespace characters, strtod would return 0 as value (no conversion), > and set endptr to the end of the string, because it would gobble the > whitespace. This would be

Re: [PATCH xrandr v4 2/5] xrandr: stricter --scale argument parsing

2018-02-05 Thread Giuseppe Bilotta
On Tue, Feb 6, 2018 at 1:01 AM, Keith Packard wrote: > Giuseppe Bilotta writes: > >> I'm not a big fan of strtod because with it it's impossible to know if >> a conversion actually happened. xrandr --scale ' ' would actually be >> accepted

Re: [PATCH xrandr v4 2/5] xrandr: stricter --scale argument parsing

2018-02-05 Thread Keith Packard
Giuseppe Bilotta writes: > I'm not a big fan of strtod because with it it's impossible to know if > a conversion actually happened. xrandr --scale ' ' would actually be > accepted (resulting in a scale value of 0), while the scanf catches > it. strtod takes an

Re: [PATCH xrandr v4 2/5] xrandr: stricter --scale argument parsing

2018-02-05 Thread walter harms
Am 05.02.2018 11:24, schrieb Giuseppe Bilotta: > On Mon, Feb 5, 2018 at 10:44 AM, walter harms wrote: >> >> Am 05.02.2018 02:47, schrieb Giuseppe Bilotta: >>> { >>> double sx, sy; >>> + char junk; >>> if (!config_output) argerr ("%s must be used

Re: [PATCH xrandr v4 2/5] xrandr: stricter --scale argument parsing

2018-02-05 Thread Giuseppe Bilotta
On Mon, Feb 5, 2018 at 10:44 AM, walter harms wrote: > > Am 05.02.2018 02:47, schrieb Giuseppe Bilotta: >> { >> double sx, sy; >> + char junk; >> if (!config_output) argerr ("%s must be used after --output\n", >> argv[i]); >> if (++i >=

Re: [PATCH xrandr v4 2/5] xrandr: stricter --scale argument parsing

2018-02-05 Thread walter harms
Am 05.02.2018 02:47, schrieb Giuseppe Bilotta: > We used to accept something like --scale 2x3junk as a valid input > (scaling x by 2 and y by 3), even though this isn't really a valid > scaling factor. > > Fix by making sure there is nothing after the parsed number(s). > > Signed-off-by: