From: Pierre Habouzit <madcoder@debian.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [SUPERSEDES PATCH 2/7] nfv?asprintf are broken without va_copy, workaround them.
Date: Fri, 21 Sep 2007 09:02:15 +0200 [thread overview]
Message-ID: <20070921070215.GA5689@artemis.corp> (raw)
In-Reply-To: <7vejgsk0ev.fsf@gitster.siamese.dyndns.org>
[-- Attachment #1: Type: text/plain, Size: 2660 bytes --]
On Fri, Sep 21, 2007 at 06:17:12AM +0000, Junio C Hamano wrote:
> Pierre Habouzit <madcoder@debian.org> writes:
>
> > This reinstates the trace_argv_printf API. The implementation is
> > stupid, but is rewritten in a latter commit. I didn't wanted to bother
> > optimizing it.
> > ...
> > cache.h | 2 -
> > imap-send.c | 13 ++++++++
> > merge-recursive.c | 74 ++++++++++++++++++++-----------------------
> > trace.c | 90 ++++++++++++++++-------------------------------------
> > 4 files changed, 74 insertions(+), 105 deletions(-)
> > ...
> > diff --git a/merge-recursive.c b/merge-recursive.c
> > index 14b56c2..4e27549 100644
> > --- a/merge-recursive.c
> > +++ b/merge-recursive.c
> > @@ -85,63 +85,57 @@ struct stage_data
> > +static void flush_output(void)
> > {
> > + if (obuf.len) {
> > + fputs(obuf.buf, stdout);
> > + strbuf_reset(&obuf);
> > }
> > }
>
> This assumes obuf.buf has necessary indentations and line
> breaks, which is sensible. However...
>
> > +static void output(int v, const char *fmt, ...)
> > {
> > + if (show(v)) {
> > + int len;
> > + va_list ap;
>
> Yuck, this single if statement covers the entirety of the
> function. Let's do
>
> if (!show(v))
> return;
>
> > + strbuf_grow(&obuf, call_depth);
> > + memset(obuf.buf + obuf.len, ' ', call_depth);
> > + strbuf_setlen(&obuf, obuf.len + call_depth);
>
> Per depth indentation used to be two whitespaces.
>
> > + va_start(ap, fmt);
> > + len = vsnprintf(obuf.buf, strbuf_avail(&obuf) + 1, fmt, ap);
> > + va_end(ap);
>
> And you overwrite whatever used to be in the buffer, including
> the previous buffered message and indentation you added. Not
> nice...
ooops, I wrote it too quickly.
> I'll squash this on top of yours for now.
works for me except the little remark in the end :)
> merge-recursive.c | 45 +++++++++++++++++++++++----------------------
> 1 files changed, 23 insertions(+), 22 deletions(-)
>
> + strbuf_setlen(&obuf, obuf.len + len);
> + strbuf_add(&obuf, "\n", 1);
rather use strbuf_addch(&obuf, '\n')
> + if (!buffer_output)
> + flush_output();
> }
>
> static void output_commit_title(struct commit *commit)
> -
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
·O· Pierre Habouzit
··O madcoder@debian.org
OOO http://www.madism.org
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
next prev parent reply other threads:[~2007-09-21 7:02 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-19 22:42 quote/strbuf series, take 3 Pierre Habouzit
[not found] ` <1190241736-30449-2-git-send-email-madcoder@debian.org>
[not found] ` <1190241736-30449-3-git-send-email-madcoder@debian.org>
2007-09-20 4:27 ` [PATCH 2/7] nfv?asprintf are broken without va_copy, workaround them Junio C Hamano
2007-09-20 4:53 ` Christian Couder
2007-09-20 8:27 ` Pierre Habouzit
2007-09-20 8:43 ` [SUPERSEDES PATCH " Pierre Habouzit
2007-09-21 6:17 ` Junio C Hamano
2007-09-21 7:02 ` Pierre Habouzit [this message]
2007-09-20 8:44 ` [SUPERSEDES PATCH 4/7] sq_quote_argv and add_to_string rework with strbuf's Pierre Habouzit
[not found] ` <1190241736-30449-4-git-send-email-madcoder@debian.org>
[not found] ` <1190241736-30449-5-git-send-email-madcoder@debian.org>
[not found] ` <1190241736-30449-6-git-send-email-madcoder@debian.org>
[not found] ` <1190241736-30449-7-git-send-email-madcoder@debian.org>
[not found] ` <1190241736-30449-8-git-send-email-madcoder@debian.org>
2007-09-20 22:05 ` [PATCH 7/7] Avoid duplicating memory, and use xmemdupz instead of xstrdup Pierre Habouzit
2007-09-21 7:03 ` Pierre Habouzit
2007-09-21 7:39 ` [DON'T MERGE PATCH 7/7] Pierre Habouzit
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=20070921070215.GA5689@artemis.corp \
--to=madcoder@debian.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.