find multi-byte comment chars in NUL-terminated strings
Several parts of the code need to identify lines that begin with the comment character, and do so with a simple byte equality check. As part of the transition to handling multi-byte characters, we need to match all of the bytes. For cases where we are looking in a NUL-terminated string, we can just use starts_with(), which checks all of the characters in comment_line_str. Note that we can drop the "line.len" check in wt-status.c's read_rebase_todolist(). The starts_with() function handles the case of an empty haystack buffer (it will always return false for a non-empty prefix). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
f99e1d94f5
commit
600559b716
@@ -1139,7 +1139,7 @@ static int edit_hunk_manually(struct add_p_state *s, struct hunk *hunk)
|
||||
for (i = 0; i < s->buf.len; ) {
|
||||
size_t next = find_next_line(&s->buf, i);
|
||||
|
||||
if (s->buf.buf[i] != comment_line_char)
|
||||
if (!starts_with(s->buf.buf + i, comment_line_str))
|
||||
strbuf_add(&s->plain, s->buf.buf + i, next - i);
|
||||
i = next;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user