From: Robin Rosenberg <robin.rosenberg@dewire.com>
To: gitster@pobox.com
Cc: tboegi@web.de, git@vger.kernel.org,
Robin Rosenberg <robin.rosenberg@dewire.com>
Subject: [PATCH] cleanup precompose_utf8
Date: Fri, 17 Aug 2012 16:53:10 +0200 [thread overview]
Message-ID: <1345215190-95976-1-git-send-email-robin.rosenberg@dewire.com> (raw)
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
next prev parent reply other threads:[~2012-08-17 14:53 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-08 13:50 [PATCH v9] git on Mac OS and precomposed unicode Torsten Bögershausen
2012-07-26 20:49 ` Robin Rosenberg
2012-07-26 23:04 ` Junio C Hamano
2012-08-17 3:26 ` Junio C Hamano
2012-08-17 14:53 ` Robin Rosenberg [this message]
2012-08-17 17:20 ` [PATCH] cleanup precompose_utf8 Junio C Hamano
2012-08-17 17:30 ` Junio C Hamano
2012-08-19 17:10 ` Torsten Bögershausen
2012-08-20 18:13 ` [PATCH] precompose-utf8: do not call checks for non-ascii "utf8" Junio C Hamano
2012-08-20 19:46 ` Torsten Bögershausen
2012-08-20 22:02 ` Junio C Hamano
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=1345215190-95976-1-git-send-email-robin.rosenberg@dewire.com \
--to=robin.rosenberg@dewire.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=tboegi@web.de \
/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;
as well as URLs for NNTP newsgroup(s).