Re: [PATCHv4] git apply: option to ignore whitespace differences
- From
Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
- Date
- Sep 1, 2009, 09:53 UTC
- Message-ID
- <cb7bb73a0909010253j530814cdqe67872d226b5623a@mail.gmail.com>
- 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:
Show 41 quoted lines
>
> 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