Skip to content

Commit 5020774

Browse files
tboegigitster
authored andcommitted
precompose_utf8: make precompose_string_if_needed() public
commit 5c32750 (MacOS: precompose_argv_prefix(), 2021-02-03) uses the function precompose_string_if_needed() internally. It is only used from precompose_argv_prefix() and therefore static in compat/precompose_utf8.c Expose this function, it will be used in the next commit. While there, allow passing a NULL pointer, which will return NULL. Signed-off-by: Torsten Bögershausen <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5c32750 commit 5020774

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

compat/precompose_utf8.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,12 @@ void probe_utf8_pathname_composition(void)
6060
strbuf_release(&path);
6161
}
6262

63-
static inline const char *precompose_string_if_needed(const char *in)
63+
const char *precompose_string_if_needed(const char *in)
6464
{
6565
size_t inlen;
6666
size_t outlen;
67+
if (!in)
68+
return NULL;
6769
if (has_non_ascii(in, (size_t)-1, &inlen)) {
6870
iconv_t ic_prec;
6971
char *out;
@@ -96,10 +98,7 @@ const char *precompose_argv_prefix(int argc, const char **argv, const char *pref
9698
argv[i] = precompose_string_if_needed(argv[i]);
9799
i++;
98100
}
99-
if (prefix) {
100-
prefix = precompose_string_if_needed(prefix);
101-
}
102-
return prefix;
101+
return precompose_string_if_needed(prefix);
103102
}
104103

105104

compat/precompose_utf8.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ typedef struct {
2929
} PREC_DIR;
3030

3131
const char *precompose_argv_prefix(int argc, const char **argv, const char *prefix);
32+
const char *precompose_string_if_needed(const char *in);
3233
void probe_utf8_pathname_composition(void);
3334

3435
PREC_DIR *precompose_utf8_opendir(const char *dirname);

git-compat-util.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,11 @@ static inline const char *precompose_argv_prefix(int argc, const char **argv, co
256256
{
257257
return prefix;
258258
}
259+
static inline const char *precompose_string_if_needed(const char *in)
260+
{
261+
return in;
262+
}
263+
259264
#define probe_utf8_pathname_composition()
260265
#endif
261266

0 commit comments

Comments
 (0)