git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] convert: fix handling of dashless UTF prefix in validate_encoding()

From
René Scharfe <l.s.r@web.de>
Date
Oct 4, 2019, 19:25 UTC
Message-ID
<c886671c-7753-6ac8-fefc-277e76019cd4@web.de>

Strip "UTF" and an optional dash from the start of 'upper' without passing a NULL pointer to skip_prefix() in the second call, as it cannot handle that.

Signed-off-by: René Scharfe <l.s.r@web.de>
---
 convert.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/convert.c b/convert.c
index deb6f71b2d..25ac525d5f 100644
--- a/convert.c
+++ b/convert.c
@@ -290,8 +290,8 @@ static int validate_encoding(const char *path, const char *enc,
 			const char *stripped = NULL;
 			char *upper = xstrdup_toupper(enc);
 			upper[strlen(upper)-2] = '\0';
-			if (!skip_prefix(upper, "UTF-", &stripped))
-				skip_prefix(stripped, "UTF", &stripped);
+			if (skip_prefix(upper, "UTF", &stripped))
+				skip_prefix(stripped, "-", &stripped);
 			advise(advise_msg, path, stripped);
 			free(upper);
 			if (die_on_error)
@@ -310,8 +310,8 @@ static int validate_encoding(const char *path, const char *enc,
 				"working-tree-encoding.");
 			const char *stripped = NULL;
 			char *upper = xstrdup_toupper(enc);
-			if (!skip_prefix(upper, "UTF-", &stripped))
-				skip_prefix(stripped, "UTF", &stripped);
+			if (skip_prefix(upper, "UTF", &stripped))
+				skip_prefix(stripped, "-", &stripped);
 			advise(advise_msg, path, stripped, stripped);
 			free(upper);
 			if (die_on_error)
--
2.23.0
Next: Junio C Hamano
Message 1 of 2 in “convert: fix handling of dashless UTF prefix in validate_encoding()”
  1. convert: fix handling of dashless UTF prefix in validate_encoding()René Scharfe, Oct 4, 2019
  2. Junio C HamanoOct 6, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.