This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Rewrite iconv option parsing [BZ #19519]


* Arjun Shankar:

> +/* This function returns a pointer to the last suffix in a conversion code
> +   string.  Valid suffixes matched by this function are of the form: '/' or ','
> +   followed by arbitrary text that doesn't contain '/' or ','.  It does not
> +   edit the string in any way.  The caller is expected to parse the suffix and
> +   advance the string terminator before the next call.  */
> +static char *
> +find_suffix (char *s)
> +{
> +  /* The conversion code is in the form of a triplet, separated by '/' chars.
> +     The third component of the triplet contains suffixes. If we don't have two
> +     slashes, we don't have a suffix.  */
> +
> +  int slash_count = 0;
> +
> +  for (int i = 0; s[i] != '\0'; i++)
> +    if (s[i] == '/')
> +      slash_count++;
> +
> +  if (slash_count < 2)
> +    return NULL;

If the caller advances the string, as described in the function comment,
does this still work?  Won't slash_count drop below 2, causing suffixes
to be ignored?

> +             && (isspace(pc->code[len - 1])

Missing space after isspace.

Thanks,
Florian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]