mirror of
https://github.com/transmission/transmission
synced 2025-02-22 14:10:34 +00:00
(trunk libT) #5316 'UMR in quark, tr-getopt code': fixed.
This commit is contained in:
parent
908af43d99
commit
f1d616d37c
2 changed files with 8 additions and 5 deletions
|
@ -399,7 +399,7 @@ compareKeys (const void * va, const void * vb)
|
|||
const struct tr_key_struct * a = va;
|
||||
const struct tr_key_struct * b = vb;
|
||||
|
||||
ret = memcmp (a->str, b->str, a->len);
|
||||
ret = memcmp (a->str, b->str, MIN (a->len, b->len));
|
||||
|
||||
if (!ret && (a->len != b->len))
|
||||
ret = a->len < b->len ? -1 : 1;
|
||||
|
|
|
@ -149,8 +149,10 @@ findOption (const tr_option * opts,
|
|||
{
|
||||
size_t len = o->longName ? strlen (o->longName) : 0;
|
||||
|
||||
if ((matchlen < len) && !memcmp (str, "--", 2)
|
||||
&& !memcmp (str + 2, o->longName, len)
|
||||
if ((matchlen < len)
|
||||
&& (str[0] == '-')
|
||||
&& (str[1] == '-')
|
||||
&& !strncmp (str+2, o->longName, len)
|
||||
&& (str[len + 2] == '\0' || (o->has_arg && str[len + 2] == '=')))
|
||||
{
|
||||
matchlen = len;
|
||||
|
@ -160,8 +162,9 @@ findOption (const tr_option * opts,
|
|||
|
||||
len = o->shortName ? strlen (o->shortName) : 0;
|
||||
|
||||
if ((matchlen < len) && !memcmp (str, "-", 1)
|
||||
&& !memcmp (str + 1, o->shortName, len)
|
||||
if ((matchlen < len)
|
||||
&& (str[0] == '-')
|
||||
&& !strncmp (str+1, o->shortName, len)
|
||||
&& (str[len + 1] == '\0' || o->has_arg))
|
||||
{
|
||||
matchlen = len;
|
||||
|
|
Loading…
Reference in a new issue