Re: [PATCH v9] git on Mac OS and precomposed unicode

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH v9] git on Mac OS and precomposed unicode

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:54:30

Junio C Hamano [off-list ref] writes:
Robin Rosenberg [off-list ref] writes:
quoted
Just a couple of nitpicks.
Polishing is always good and better late than never, but for a topic
that has long been graduated to 'master' already, it would be easier
to review and discuss if it came as a patch form relative to the
codebase _after_ the topic has been applied.
Mild ping for a possible follow-ups that didn't seem to have
happened...

[PATCH] cleanup precompose_utf8

From: Robin Rosenberg <hidden>
Date: 2016-06-15 22:54:30

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

Signed-off-by: Robin Rosenberg <redacted>
---
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help