| 68 | } |
| 69 | |
| 70 | const char *precompose_string_if_needed(const char *in) |
| 71 | { |
| 72 | size_t inlen; |
| 73 | size_t outlen; |
| 74 | struct repo_config_values *cfg = repo_config_values(the_repository); |
| 75 | |
| 76 | if (!in) |
| 77 | return NULL; |
| 78 | if (has_non_ascii(in, (size_t)-1, &inlen)) { |
| 79 | iconv_t ic_prec; |
| 80 | char *out; |
| 81 | if (cfg->precomposed_unicode < 0) |
| 82 | repo_config_get_bool(the_repository, "core.precomposeunicode", &cfg->precomposed_unicode); |
| 83 | if (cfg->precomposed_unicode != 1) |
| 84 | return in; |
| 85 | ic_prec = iconv_open(repo_encoding, path_encoding); |
| 86 | if (ic_prec == (iconv_t) -1) |
| 87 | return in; |
| 88 | |
| 89 | out = reencode_string_iconv(in, inlen, ic_prec, 0, &outlen); |
| 90 | if (out) { |
| 91 | if (outlen == inlen && !memcmp(in, out, outlen)) |
| 92 | free(out); /* no need to return identical */ |
| 93 | else |
| 94 | in = out; |
| 95 | } |
| 96 | iconv_close(ic_prec); |
| 97 | |
| 98 | } |
| 99 | return in; |
| 100 | } |
| 101 | |
| 102 | const char *precompose_argv_prefix(int argc, const char **argv, const char *prefix) |
| 103 | { |
no test coverage detected