From: tboegi@web.de
To: git@vger.kernel.org, d.torilov@gmail.com
Subject: [PATCH v3 1/2] precompose_utf8: Make precompose_string_if_needed() public
Date: Sun, 4 Apr 2021 19:14:09 +0200 [thread overview]
Message-ID: <20210404171409.32265-1-tboegi@web.de> (raw)
In-Reply-To: <xmqqtuotfre5.fsf@gitster.g>
From: Torsten Bögershausen <tboegi@web.de>
commit 5c327502, MacOS: precompose_argv_prefix()
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 <tboegi@web.de>
---
compat/precompose_utf8.c | 9 ++++-----
compat/precompose_utf8.h | 1 +
git-compat-util.h | 5 +++++
3 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/compat/precompose_utf8.c b/compat/precompose_utf8.c
index ec560565a8..cce1d57a46 100644
--- a/compat/precompose_utf8.c
+++ b/compat/precompose_utf8.c
@@ -60,10 +60,12 @@ void probe_utf8_pathname_composition(void)
strbuf_release(&path);
}
-static inline const char *precompose_string_if_needed(const char *in)
+const char *precompose_string_if_needed(const char *in)
{
size_t inlen;
size_t outlen;
+ if (!in)
+ return NULL;
if (has_non_ascii(in, (size_t)-1, &inlen)) {
iconv_t ic_prec;
char *out;
@@ -96,10 +98,7 @@ const char *precompose_argv_prefix(int argc, const char **argv, const char *pref
argv[i] = precompose_string_if_needed(argv[i]);
i++;
}
- if (prefix) {
- prefix = precompose_string_if_needed(prefix);
- }
- return prefix;
+ return precompose_string_if_needed(prefix);
}
diff --git a/compat/precompose_utf8.h b/compat/precompose_utf8.h
index d70b84665c..fea06cf28a 100644
--- a/compat/precompose_utf8.h
+++ b/compat/precompose_utf8.h
@@ -29,6 +29,7 @@ typedef struct {
} PREC_DIR;
const char *precompose_argv_prefix(int argc, const char **argv, const char *prefix);
+const char *precompose_string_if_needed(const char *in);
void probe_utf8_pathname_composition(void);
PREC_DIR *precompose_utf8_opendir(const char *dirname);
diff --git a/git-compat-util.h b/git-compat-util.h
index 9ddf9d7044..a508dbe5a3 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -256,6 +256,11 @@ static inline const char *precompose_argv_prefix(int argc, const char **argv, co
{
return prefix;
}
+static inline const char *precompose_string_if_needed(const char *in)
+{
+ return in;
+}
+
#define probe_utf8_pathname_composition()
#endif
--
2.30.0.155.g66e871b664
next prev parent reply other threads:[~2021-04-04 17:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-29 22:33 [PATCH] chore: use prefix from startup_info Dmitry Torilov via GitGitGadget
2021-03-29 23:53 ` Junio C Hamano
2021-03-31 5:04 ` Torsten Bögershausen
2021-04-04 6:17 ` [PATCH v2 1/2] precompose_utf8: Make precompose_string_if_needed() public tboegi
2021-04-04 6:17 ` [PATCH v2 2/2] MacOs: Precompose startup_info->prefix tboegi
2021-04-04 7:58 ` Junio C Hamano
2021-04-04 17:14 ` tboegi [this message]
2021-04-04 17:14 ` [PATCH v3 " tboegi
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210404171409.32265-1-tboegi@web.de \
--to=tboegi@web.de \
--cc=d.torilov@gmail.com \
--cc=git@vger.kernel.org \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).