> $ pacman -Uh > options: > -b, --dbpath <path> set an alternate database location > -d, --nodeps skip dependency checks > -f, --force force install, overwrite conflicting files > -k, --dbonly only modify database entries, not package files > -r, --root <path> set an alternate installation root > -v, --verbose be verbose > --arch <arch> set an alternate architecture > --asdeps install packages as non-explicitly installed > --asexplicit install packages as explicitly installed > --cachedir <dir> set an alternate package cache location > --config <path> set an alternate configuration file > --debug display debug messages > --ignore <pkg> ignore a package upgrade (can be used more than once) > --ignoregroup <grp> > ignore a group upgrade (can be used more than once) > --logfile <path> set an alternate log file > --noconfirm do not ask for any confirmation > --noprogressbar do not show a progress bar when downloading files > --noscriptlet do not execute the install scriptlet if one exists > --print only print the targets instead of performing the > operation > --print-format <string> > specify how the targets should be printed > > Signed-off-by: Xavier Chantry <chantry.xav...@gmail.com>
I like this. > +/* Used to sort the options in --help */ > +static int options_cmp(const void *p1, const void *p2) > +{ > + const char *s1 = p1; > + const char *s2 = p2; > + int ret = 0; > + > + /* 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. > + } else if (*(s2+1) != '-' && *(s1+1) == '-') { > + ret = 1; > + } else { > + ret = strcmp(s1, s2); > + } > + return(ret); > +} NG