From 600559b7169c1353e3d46f773f39cf018d38ebbc Mon Sep 17 00:00:00 2001 From: Jeff King Date: Tue, 12 Mar 2024 05:17:37 -0400 Subject: 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 Signed-off-by: Junio C Hamano --- sequencer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sequencer.c') diff --git a/sequencer.c b/sequencer.c index 241e185f87..991a2dbe96 100644 --- a/sequencer.c +++ b/sequencer.c @@ -2003,7 +2003,7 @@ static int update_squash_messages(struct repository *r, return error(_("could not read '%s'"), rebase_path_squash_msg()); - eol = buf.buf[0] != comment_line_char ? + eol = !starts_with(buf.buf, comment_line_str) ? buf.buf : strchrnul(buf.buf, '\n'); strbuf_addf(&header, "%s ", comment_line_str); -- cgit v1.3-6-g1900