Re: [PATCH v15 07/13] ref-filter: add support for %(contents:lines=X)

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH v15 07/13] ref-filter: add support for %(contents:lines=X)

From: Matthieu Moy <hidden>
Date: 2016-06-15 23:06:25

Karthik Nayak [off-list ref] writes:
On Thu, Sep 3, 2015 at 7:04 PM, Karthik Nayak [off-list ref] wrote:
quoted
quoted
                        struct strbuf s = STRBUF_INIT;
                        if (strtoul_ui(valp, 10, &v->u.contents.lines))
                                die(_("positive width expected contents:lines=%s"), valp);
-                       append_lines(&s, subpos, sublen + bodylen - siglen, v->u.contents.lines);
+                       append_lines(&s, subpos, bodypos + bodylen - subpos, v->u.contents.lines);
                        v->s = strbuf_detach(&s, NULL);
                }
        }
append_lines(&s, subpos, bodylen + bodypos - subpos - siglen,
v->u.contents.lines);

We need to eliminate the signature if existing also.
Indeed. I thought body did not include the signature.

I'd write it as

  bodylen + bodypos - siglen - subpos

or even

  char *contents_end = bodylen + bodypos - siglen;
  ...
  append_lines(&s, subpos, contents_end - subpos, ...);

to make it self-explanatory.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

Re: [PATCH v15 07/13] ref-filter: add support for %(contents:lines=X)

From: Karthik Nayak <hidden>
Date: 2016-06-15 23:06:25

On Thu, Sep 3, 2015 at 8:17 PM, Matthieu Moy
[off-list ref] wrote:
Karthik Nayak [off-list ref] writes:
quoted
On Thu, Sep 3, 2015 at 7:04 PM, Karthik Nayak [off-list ref] wrote:
quoted
quoted
                        struct strbuf s = STRBUF_INIT;
                        if (strtoul_ui(valp, 10, &v->u.contents.lines))
                                die(_("positive width expected contents:lines=%s"), valp);
-                       append_lines(&s, subpos, sublen + bodylen - siglen, v->u.contents.lines);
+                       append_lines(&s, subpos, bodypos + bodylen - subpos, v->u.contents.lines);
                        v->s = strbuf_detach(&s, NULL);
                }
        }
append_lines(&s, subpos, bodylen + bodypos - subpos - siglen,
v->u.contents.lines);

We need to eliminate the signature if existing also.
Indeed. I thought body did not include the signature.

I'd write it as

  bodylen + bodypos - siglen - subpos

or even

  char *contents_end = bodylen + bodypos - siglen;
  ...
  append_lines(&s, subpos, contents_end - subpos, ...);

to make it self-explanatory.
I was thinking of adding a comment but a self explanatory comment
seems like a good idea. Thanks.

-- 
Regards,
Karthik Nayak
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help