Git development
 help / color / mirror / Atom feed
From: Dirk Gouders <dirk@gouders.net>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
	Dirk Gouders <dirk@gouders.net>,
	Andy Koppe <andy.koppe@gmail.com>
Subject: [PATCH v4 2/5] utf8: fix comment for utf8_strnwidth()
Date: Fri, 20 Nov 2026 16:11:25 +0100	[thread overview]
Message-ID: <20261120-master-v4-2-5ff523db7285@gouders.net> (raw)
In-Reply-To: <20261120-master-v4-0-5ff523db7285@gouders.net>

The comment for utf8_strnwidth() states it works on a NUL terminated
string whereas the string is bounded by len.
It also states it returns strlen() for cases when the given string
doesn't look like valid utf8, but it returns its argument len in such
cases.

Fix the comment accordingly.

Helped-by: Andy Koppe <andy.koppe@gmail.com>
Signed-off-by: Dirk Gouders <dirk@gouders.net>
---
 utf8.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/utf8.c b/utf8.c
index 48aa189624..35b2bb8290 100644
--- a/utf8.c
+++ b/utf8.c
@@ -213,8 +213,8 @@ int utf8_width(const char **start, size_t *remainder_p)
 }
 
 /*
- * Returns the total number of columns required by a null-terminated
- * string, assuming that the string is utf8.  Returns strlen() instead
+ * Returns the total number of columns required by a string terminated by len,
+ * assuming that the string is utf8.  Returns len instead
  * if the string does not look like a valid utf8 string.
  */
 int utf8_strnwidth(const char *string, size_t len, int skip_ansi)

-- 
2.55.0


  parent reply	other threads:[~2026-11-20 15:11 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 18:56 [PATCH 0/2] utf8: two minor fixes Dirk Gouders
2026-11-16 18:57 ` [PATCH 1/2] utf8: respect bounds in utf8_strnwidth() Dirk Gouders
2026-11-17  0:02   ` Junio C Hamano
2026-11-17 15:15     ` Dirk Gouders
2026-11-17 16:18     ` Junio C Hamano
2026-11-17 17:57       ` Dirk Gouders
2026-11-17 18:11         ` Junio C Hamano
2026-11-16 18:57 ` [PATCH 2/2] utf8: fix comment for utf8_strnwidth() Dirk Gouders
2026-11-18 21:08 ` [PATCH v2 0/4] utf8: bounds-related fixes and a doc fix Dirk Gouders
2026-11-18 21:08   ` [PATCH v2 1/4] utf8: add display_mode_esc_sequence_len_counted() Dirk Gouders
2026-11-19  5:54     ` Andy Koppe
2026-11-19  7:43       ` Dirk Gouders
2026-11-19 20:58         ` Andy Koppe
2026-11-19 21:04           ` Andy Koppe
2026-11-19 21:33             ` Dirk Gouders
2026-11-19 22:32       ` Dirk Gouders
2026-11-19 22:59         ` Dirk Gouders
2026-11-20 10:16         ` Andy Koppe
2026-11-20 16:36           ` Junio C Hamano
2026-11-20 18:03             ` Andy Koppe
2026-11-19 19:59     ` Junio C Hamano
2026-11-19 20:28       ` Dirk Gouders
2026-11-18 21:08   ` [PATCH v2 2/4] utf8: fix comment for utf8_strnwidth() Dirk Gouders
2026-11-18 22:40     ` Andy Koppe
2026-11-19  5:58       ` Dirk Gouders
2026-11-18 21:08   ` [PATCH v2 3/4] utf8: respect string boundaries after skipping ANSI escape sequences Dirk Gouders
2026-11-18 21:49     ` Junio C Hamano
2026-11-18 21:08   ` [PATCH v2 4/4] utf8: respect boundaries in utf8_strnwidth() Dirk Gouders
2026-11-18 21:50     ` Junio C Hamano
2026-11-20 14:44 ` [PATCH v3 0/4] utf8: bounds-related fixes and a doc fix Dirk Gouders
2026-11-20 14:44   ` [PATCH v3 1/4] utf8: introduce bounds for display_mode_esc_sequence_len() Dirk Gouders
2026-11-20 14:44   ` [PATCH v3 2/4] utf8: fix comment for utf8_strnwidth() Dirk Gouders
2026-11-20 14:44   ` [PATCH v3 3/4] utf8: respect string boundaries after skipping ANSI escape sequences Dirk Gouders
2026-11-20 14:44   ` [PATCH v3 4/4] utf8: respect boundaries in utf8_strnwidth() Dirk Gouders
2026-11-20 15:09   ` [PATCH v3 0/4] utf8: bounds-related fixes and a doc fix Dirk Gouders
2026-11-20 15:11 ` [PATCH v4 0/5] " Dirk Gouders
2026-11-20 15:11   ` [PATCH v4 1/5] utf8: introduce bounds for display_mode_esc_sequence_len() Dirk Gouders
2026-11-20 15:11   ` Dirk Gouders [this message]
2026-11-20 15:11   ` [PATCH v4 3/5] utf8: respect string boundaries after skipping ANSI escape sequences Dirk Gouders
2026-11-20 15:11   ` [PATCH v4 4/5] utf8: respect boundaries in utf8_strnwidth() Dirk Gouders
2026-11-20 15:11   ` [PATCH v4 5/5] utf8: introduce display_mode_esc_sequence_len_all() Dirk Gouders

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261120-master-v4-2-5ff523db7285@gouders.net \
    --to=dirk@gouders.net \
    --cc=andy.koppe@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox