[PATCH 01/12] Fixes to parse_options

Bill Spitzak spitzak at gmail.com
Wed Aug 20 12:07:31 PDT 2014



On 08/20/2014 05:27 AM, Pekka Paalanen wrote:

>> The old code basically did *(string+strlen(string)+1) if the string did
>> not have an = sign in it, passing that pointer to the argument parser.
>> Probably this always fails parsing without a segfault but technically it
>> is wrong, it could segfault, or it could get some text at that point
>> that actually parses, producing an unexpected value.
>
> Aah, maybe that was hack to try and use the argv[i+1] as the value if
> argv[i] was the option?

I suspect it was a typo. It just called the parser with a pointer to 
where the text would have been if the keyword had an = sign at it's end.

I'm not sure there is any guarantee that argv[i+1] == 
argv[i]+strlen(argv[i])+1. It certainly is false if a function such as 
parse_options has already been run on the argv.

> Looks like 'weston --width 500' won't work at the moment anyway, and
> I'm not sure if it ever was meant to, so I think requiring the '=' is
> ok.

That might be nice, however. Not sure how hard it is to add that.



More information about the wayland-devel mailing list