All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
To: Duy Nguyen <pclouds@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>,
	GIT Mailing-list <git@vger.kernel.org>
Subject: Re: [PATCH] pretty: Fix bug in truncation support for %>, %< and %><
Date: Mon, 29 Apr 2013 22:29:00 +0100	[thread overview]
Message-ID: <517EE61C.5040802@ramsay1.demon.co.uk> (raw)
In-Reply-To: <CACsJy8Dx2tKdQDLw9=i1aM6=uqVBvHYpzq-q+rQE-e7-oJTRcg@mail.gmail.com>

Duy Nguyen wrote:
> On Sun, Apr 28, 2013 at 2:43 AM, Ramsay Jones
> <ramsay@ramsay1.demon.co.uk> wrote:
>> The truncation support was implemented with the assistance of a
>> new strbuf function (strbuf_utf8_replace). This function contains
>> the following code:
>>
>>        strbuf_attach(sb_src, strbuf_detach(&sb_dst, NULL),
>>                      sb_dst.len, sb_dst.alloc);
>>
>> Unfortunately, this code is subject to unspecified behaviour. In
>> particular, the order of evaluation of the argument expressions
>> (along with the associated side effects) is not specified by the
>> C standard.
> 
> Thanks for noticing and fixing it.

I didn't notice it; your test noticed it and nagged me to take a look!
;-)

The verbose output from the test made it clear that, rather than the
expected truncated output, it was returning an empty string. A quick
trip to the debugger clearly showed strbuf_detach() clearing the len
and alloc fields of sb_dst, which was then passed to strbuf_attach().
So, I didn't really do much. :-D

>                                   What compiler did you use by the way?

The compiler was gcc, but that doesn't really matter much.

ATB,
Ramsay Jones

  reply	other threads:[~2013-04-29 23:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-27 19:43 [PATCH] pretty: Fix bug in truncation support for %>, %< and %>< Ramsay Jones
2013-04-27 23:59 ` Duy Nguyen
2013-04-29 21:29   ` Ramsay Jones [this message]
2013-04-29 17:55 ` Jonathan Nieder

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=517EE61C.5040802@ramsay1.demon.co.uk \
    --to=ramsay@ramsay1.demon.co.uk \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=pclouds@gmail.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.