Re: [PATCH 22/25] diff.c: color moved lines differently
From: Junio C Hamano <hidden>
Date: 2017-06-30 18:41:24
Stefan Beller [off-list ref] writes:
On Fri, Jun 30, 2017 at 10:54 AM, Junio C Hamano [off-list ref] wrote:quoted
Stefan Beller [off-list ref] writes:quoted
+static int next_byte(const char **cp, const char **endp, + const struct diff_options *diffopt) +{ + int retval; + + if (DIFF_XDL_TST(diffopt, IGNORE_WHITESPACE_AT_EOL)) { + while (*endp > *cp && isspace(**endp)) + (*endp)--; + }This should be done by the callers (both moved_entry_cmp() and get_string_hash()) before starting to iterate over the bytes from the beginning, no?Good point.quoted
quoted
+ + retval = **cp;The char could be signed, and byte 0xff may become indistinguishable from the EOF (i.e. -1) you returned earlier.Ah, I messed up there. I think EOF is wrong, too. So maybe we'll just return 256 to indicate the end of memory chunk to not have to deal with signedness
I would just say that next_byte() returns -1 (at end of string) or 0-255 if it is returning a byte that matters.