public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Arjun Shankar <arjun.is@lostca.se>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH] Rewrite iconv option parsing [BZ #19519]
Date: Wed, 18 Dec 2019 11:18:00 -0000	[thread overview]
Message-ID: <87y2v9287h.fsf@oldenburg2.str.redhat.com> (raw)
In-Reply-To: <20191217235029.GA34814@aloka.lostca.se> (Arjun Shankar's message of "Tue, 17 Dec 2019 23:50:30 +0000")

* 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

  reply	other threads:[~2019-12-18 11:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-17 23:50 Arjun Shankar
2019-12-18 11:18 ` Florian Weimer [this message]
2019-12-18 11:58   ` Arjun Shankar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y2v9287h.fsf@oldenburg2.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=arjun.is@lostca.se \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).