From: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org,
Felipe Contreras <felipe.contreras@gmail.com>,
Nanako Shiraishi <nanako3@lavabit.com>
Subject: Re: [PATCHv4] git apply: option to ignore whitespace differences
Date: Tue, 1 Sep 2009 11:53:54 +0200 [thread overview]
Message-ID: <cb7bb73a0909010253j530814cdqe67872d226b5623a@mail.gmail.com> (raw)
In-Reply-To: <7vocpvvxaw.fsf@alter.siamese.dyndns.org>
On Tue, Sep 1, 2009 at 11:17 AM, Junio C Hamano<gitster@pobox.com> wrote:
>
> Why do you need imglen[] vla here? IOW, can't the above be simply like
> this?
>
> diff --git a/builtin-apply.c b/builtin-apply.c
> index ae11b41..c8372a0 100644
> --- a/builtin-apply.c
> +++ b/builtin-apply.c
> @@ -1874,20 +1874,18 @@ static int match_fragment(struct image *img,
> if (ws_ignore_action == ignore_ws_change) {
> size_t imgoff = 0;
> size_t preoff = 0;
> size_t postlen = postimage->len;
> - size_t imglen[preimage->nr];
> for (i = 0; i < preimage->nr; i++) {
> size_t prelen = preimage->line[i].len;
> + size_t imglen = img->line[try_lno+i].len;
>
> - imglen[i] = img->line[try_lno+i].len;
> - if (!fuzzy_matchlines(
> - img->buf + try + imgoff, imglen[i],
> - preimage->buf + preoff, prelen))
> + if (!fuzzy_matchlines(img->buf + try + imgoff, imglen,
> + preimage->buf + preoff, prelen))
> return 0;
> if (preimage->line[i].flag & LINE_COMMON)
> - postlen += imglen[i] - prelen;
> - imgoff += imglen[i];
> + postlen += imglen - prelen;
> + imgoff += imglen;
> preoff += prelen;
> }
>
> /*
> @@ -1899,9 +1897,9 @@ static int match_fragment(struct image *img,
> */
> fixed_buf = xmalloc(imgoff);
> memcpy(fixed_buf, img->buf + try, imgoff);
> for (i = 0; i < preimage->nr; i++)
> - preimage->line[i].len = imglen[i];
> + preimage->line[i].len = img->line[try_lno+i].len;
Yep, I think that would do it. I'm not sure why I was doing it that
other way. Maybe a leftover from when I was still getting confident
with the code and I hadn't yet found the var that held the initial
match line, or something like that.
--
Giuseppe "Oblomov" Bilotta
next prev parent reply other threads:[~2009-09-01 9:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-04 11:16 [PATCHv4] git apply: option to ignore whitespace differences Giuseppe Bilotta
2009-09-01 9:17 ` Junio C Hamano
2009-09-01 9:53 ` Giuseppe Bilotta [this message]
-- strict thread matches above, loose matches on Subject: below --
2009-07-31 20:40 Giuseppe Bilotta
2009-08-04 7:25 ` Junio C Hamano
2009-08-04 7:33 ` Giuseppe Bilotta
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=cb7bb73a0909010253j530814cdqe67872d226b5623a@mail.gmail.com \
--to=giuseppe.bilotta@gmail.com \
--cc=felipe.contreras@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=nanako3@lavabit.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 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 NNTP newsgroup(s).