[pacman-dev] [PATCH] Sort short options before long options in --help

Xavier Chantry chantry.xavier at gmail.com
Thu Oct 14 08:56:31 EDT 2010


On Thu, Oct 14, 2010 at 1:55 PM, Nagy Gabor <ngaba at bibl.u-szeged.hu> wrote:
>
> I like this.
>

Cool :)

>> +     /* First skip all spaces in both strings */
>> +     while(isspace((unsigned char)*s1))
>> +             s1++;
>> +     while(isspace((unsigned char)*s2))
>> +             s2++;
>> +     /* If we compare a long option (--abcd) and a short one (-a),
>> +      * the short one always wins */
>> +     if (*(s1+1) != '-' && *(s2+1) == '-') {
>> +             ret = -1;
>
> I hope you don't pass invalid string arguments (e.g. empty string),
> otherwise we can get a segfault here.
>

I missed something very important. I thought we had complete controls
on these strings, while in fact we don't have any control at all,
since it's the gettext-ed strings that I sort :P
I will make a safer version, thanks.


More information about the pacman-dev mailing list