Re: [PATCH v3 3/4] Provide a dirname() function when NO_LIBGEN_H=YesPlease
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Jan 12, 2016, 07:57 UTC
- Message-ID
- <alpine.DEB.2.20.1601120856270.2964@virtualbox>
- In-Reply-To
- <xmqqtwmjvi75.fsf@gitster.mtv.corp.google.com>
Hi Eric & Junio,
On Mon, 11 Jan 2016, Junio C Hamano wrote:
Show 33 quoted lines
> Eric Sunshine <sunshine@sunshineco.com> writes:
>
> > I wonder if this would be a bit easier to follow if it was structured
> > something like this:
> >
> > static struct strbuf buf = STRBUF_INIT;
> >
> > if ((dos_drive_prefix = skip_dos_drive_prefix(&p)) && !*p)
> > goto dot;
> >
> > ...
> > if (is_dir_sep(*p)) {
> > ...
> > }
> > ...
> > while ((c = *(p++)))
> > ...
> >
> > if (slash) {
> > *slash = '\0';
> > return path;
> > }
> >
> > dot:
> > strbuf_reset(&buf);
> > strbuf_addf(&buf, "%.*s.", dos_drive_prefix, path);
> > return buf.buf;
>
> I'll queue the one from Dscho as-is for today, but avoiding the
> "jump back to a place where it happens to have an identical clean-up
> that need to happen" and defining the clean-up path at the end like
> this would probably be easier to follow. It certainly would have
> saved one comment in the previous review cycle from me.Thanks! I changed it and will mail out v4 shortly.
Ciao, Dscho