This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Rewrite iconv option parsing [BZ #19519]
- From: Florian Weimer <fweimer at redhat dot com>
- To: Arjun Shankar <arjun dot is at lostca dot se>
- Cc: libc-alpha at sourceware dot org
- Date: Wed, 18 Dec 2019 12:18:10 +0100
- Subject: Re: [PATCH] Rewrite iconv option parsing [BZ #19519]
- References: <20191217235029.GA34814@aloka.lostca.se>
* 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