Re: [PATCHv4] git apply: option to ignore whitespace differences

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Sep 1, 2009 at 11:17 AM, Junio C Hamano<gitster@xxxxxxxxx> 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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]