Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
cleanup precompose_utf8
author
Robin Rosenberg
<robin.rosenberg@dewire.com>
Fri, 17 Aug 2012 14:53:10 +0000
(16:53 +0200)
committer
Junio C Hamano
<gitster@pobox.com>
Fri, 17 Aug 2012 17:29:56 +0000
(10:29 -0700)
- Remove extraneous parentheses and braces;
- Remove redundant NUL-termination before strcpy();
- Check result of unlink when probing for decomposed file names;
- Adjust for the coding style by adding missing whitespaces;
- Move storage class "static" at the beginning of the decl.
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
compat/precompose_utf8.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
76759c7
)
diff --git
a/compat/precompose_utf8.c
b/compat/precompose_utf8.c
index d40d1b38076d690faaf7e77e590c0d6245ad1139..3190d502bb553d425bfb2b0d8a1b5df6bde98b20 100644
(file)
--- a/
compat/precompose_utf8.c
+++ b/
compat/precompose_utf8.c
@@
-1,8
+1,7
@@
/*
* Converts filenames from decomposed unicode into precomposed unicode.
* Used on MacOS X.
/*
* Converts filenames from decomposed unicode into precomposed unicode.
* Used on MacOS X.
-*/
-
+ */
#define PRECOMPOSE_UNICODE_C
#define PRECOMPOSE_UNICODE_C
@@
-11,21
+10,19
@@
#include "precompose_utf8.h"
typedef char *iconv_ibp;
#include "precompose_utf8.h"
typedef char *iconv_ibp;
-const static char *repo_encoding = "UTF-8";
-const static char *path_encoding = "UTF-8-MAC";
-
+static const char *repo_encoding = "UTF-8";
+static const char *path_encoding = "UTF-8-MAC";
static size_t has_utf8(const char *s, size_t maxlen, size_t *strlen_c)
{
static size_t has_utf8(const char *s, size_t maxlen, size_t *strlen_c)
{
- const uint8_t *utf8p = (const uint8_t
*)
s;
+ const uint8_t *utf8p = (const uint8_t
*)
s;
size_t strlen_chars = 0;
size_t ret = 0;
size_t strlen_chars = 0;
size_t ret = 0;
- if (
(!utf8p) || (!*utf8p)) {
+ if (
!utf8p || !*utf8p)
return 0;
return 0;
- }
- while
((*utf8p)
&& maxlen) {
+ while
(*utf8p
&& maxlen) {
if (*utf8p & 0x80)
ret++;
strlen_chars++;
if (*utf8p & 0x80)
ret++;
strlen_chars++;
@@
-41,26
+38,24
@@
static size_t has_utf8(const char *s, size_t maxlen, size_t *strlen_c)
void probe_utf8_pathname_composition(char *path, int len)
{
void probe_utf8_pathname_composition(char *path, int len)
{
-
const static
char *auml_nfc = "\xc3\xa4";
-
const static
char *auml_nfd = "\x61\xcc\x88";
+
static const
char *auml_nfc = "\xc3\xa4";
+
static const
char *auml_nfd = "\x61\xcc\x88";
int output_fd;
if (precomposed_unicode != -1)
return; /* We found it defined in the global config, respect it */
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);
strcpy(path + len, auml_nfc);
output_fd = open(path, O_CREAT|O_EXCL|O_RDWR, 0600);
- if (output_fd >=0) {
+ if (output_fd >=
0) {
close(output_fd);
close(output_fd);
- path[len] = 0;
strcpy(path + len, auml_nfd);
/* Indicate to the user, that we can configure it to true */
strcpy(path + len, auml_nfd);
/* Indicate to the user, that we can configure it to true */
- if (
0 ==
access(path, R_OK))
+ if (
!
access(path, R_OK))
git_config_set("core.precomposeunicode", "false");
git_config_set("core.precomposeunicode", "false");
-
/* To be backward compatible, set precomposed_unicode to 0 */
+ /* To be backward compatible, set precomposed_unicode to 0 */
precomposed_unicode = 0;
precomposed_unicode = 0;
- path[len] = 0;
strcpy(path + len, auml_nfc);
strcpy(path + len, auml_nfc);
- unlink(path);
+ if (unlink(path))
+ die_errno(_("failed to unlink '%s'"), path);
}
}
}
}
@@
-160,8
+155,7
@@
struct dirent_prec_psx *precompose_utf8_readdir(PREC_DIR *prec_dir)
namelenz = 0; /* trigger strlcpy */
}
}
namelenz = 0; /* trigger strlcpy */
}
}
- }
- else
+ } else
namelenz = 0;
if (!namelenz)
namelenz = 0;
if (!namelenz)