@@ -8,6 +8,7 @@
#include "cache.h"
#include "utf8.h"
#include "precompose_utf8.h"
+#include "strbuf.h"
typedef char *iconv_ibp;
static const char *repo_encoding = "UTF-8";
@@ -36,28 +37,33 @@ static size_t has_non_ascii(const char *s, size_t maxlen, size_t *strlen_c)
}
-void probe_utf8_pathname_composition(struct strbuf *path)
+void probe_utf8_pathname_composition(char *path, int len)
{
static const char *auml_nfc = "\xc3\xa4";
static const char *auml_nfd = "\x61\xcc\x88";
- size_t baselen = path->len;
+ struct strbuf sbuf;
int output_fd;
if (precomposed_unicode != -1)
return; /* We found it defined in the global config, respect it */
- strbuf_addstr(path, auml_nfc);
- output_fd = open(path, O_CREAT|O_EXCL|O_RDWR, 0600);
+ strbuf_init(&sbuf, len+3);
+ strbuf_add(&sbuf, path, len);
+ strbuf_addstr(&sbuf, auml_nfc);
+ output_fd = open(sbuf.buf, O_CREAT|O_EXCL|O_RDWR, 0600);
+ fprintf(stderr, "%s/%s:%d sbuf.buf=%s\n",
+ __FILE__, __FUNCTION__, __LINE__, sbuf.buf);
if (output_fd >= 0) {
close(output_fd);
- strbuf_setlen(path, baselen);
- strbuf_addstr(path, auml_nfd);
+ strbuf_setlen(&sbuf, len);
+ strbuf_addstr(&sbuf, auml_nfd);
+ fprintf(stderr, "%s/%s:%d sbuf.buf=%s\n",
+ __FILE__, __FUNCTION__, __LINE__, sbuf.buf);
precomposed_unicode = access(path, R_OK) ? 0 : 1;
git_config_set("core.precomposeunicode", precomposed_unicode ? "true" : "false");
- strbuf_setlen(path, baselen);
- strbuf_addstr(path, auml_nfc);
+ strcpy(path + len, auml_nfc);
if (unlink(path))
die_errno(_("failed to unlink '%s'"), path);
}
- strbuf_setlen(path, baselen);
+ strbuf_release(&sbuf);
}
@@ -27,7 +27,7 @@ typedef struct {
} PREC_DIR;
void precompose_argv(int argc, const char **argv);
-void probe_utf8_pathname_composition(struct strbuf *path);
+void probe_utf8_pathname_composition(char *, int);
PREC_DIR *precompose_utf8_opendir(const char *dirname);
struct dirent_prec_psx *precompose_utf8_readdir(PREC_DIR *dirp);