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

[PATCH] cleanup precompose_utf8

From
Robin Rosenberg <robin.rosenberg@dewire.com>
Date
Aug 17, 2012, 14:53 UTC
Message-ID
<1345215190-95976-1-git-send-email-robin.rosenberg@dewire.com>
In-Reply-To
<7v393mxkpk.fsf@alter.siamese.dyndns.org>

Remove extraneous parentheses and braces Remove redundant NUL-termination Check result of unlink when probing for decomposed file names

Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
 compat/precompose_utf8.c | 11 ++++-------
 1 fil ändrad, 4 tillägg(+), 7 borttagningar(-)
diff --git a/compat/precompose_utf8.c b/compat/precompose_utf8.c
index d40d1b3..9563760 100644
--- a/compat/precompose_utf8.c
+++ b/compat/precompose_utf8.c
@@ -21,11 +21,10 @@ static size_t has_utf8(const char *s, size_t maxlen, size_t *strlen_c)
 	size_t strlen_chars = 0;
 	size_t ret = 0;
 
-	if ((!utf8p) || (!*utf8p)) {
+	if (!utf8p || !*utf8p)
 		return 0;
-	}
 
-	while((*utf8p) && maxlen) {
+	while(*utf8p && maxlen) {
 		if (*utf8p & 0x80)
 			ret++;
 		strlen_chars++;
@@ -46,21 +45,19 @@ void probe_utf8_pathname_composition(char *path, int len)
 	int output_fd;
 	if (precomposed_unicode != -1)
 		return; /* We found it defined in the global config, respect it */
-	path[len] = 0;
 	strcpy(path + len, auml_nfc);
 	output_fd = open(path, O_CREAT|O_EXCL|O_RDWR, 0600);
 	if (output_fd >=0) {
 		close(output_fd);
-		path[len] = 0;
 		strcpy(path + len, auml_nfd);
 		/* Indicate to the user, that we can configure it to true */
 		if (0 == access(path, R_OK))
 			git_config_set("core.precomposeunicode", "false");
 			/* To be backward compatible, set precomposed_unicode to 0 */
 		precomposed_unicode = 0;
-		path[len] = 0;
 		strcpy(path + len, auml_nfc);
-		unlink(path);
+		if (unlink(path))
+			die_errno(_("failed to unlink '%s'"), path);
 	}
 }
 
-- 
1.7.12.rc3.4.ga867a5c
Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 11 in “git on Mac OS and precomposed unicode”
  1. git on Mac OS and precomposed unicodeTorsten Bögershausen, Jul 8, 2012
  2. Robin RosenbergJul 26, 2012
  3. Junio C HamanoJul 26, 2012
  4. Junio C HamanoAug 17, 2012
  5. cleanup precompose_utf8Robin Rosenberg, Aug 17, 2012
  6. Junio C HamanoAug 17, 2012
  7. Junio C HamanoAug 17, 2012
  8. Torsten BögershausenAug 19, 2012
  9. precompose-utf8: do not call checks for non-ascii "utf8"Junio C Hamano, Aug 20, 2012
  10. Torsten BögershausenAug 20, 2012
  11. Junio C HamanoAug 20, 2012

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.