summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Allsopp <david.allsopp@metastack.com>2022-01-19 19:46:19 +0000
committerDavid Allsopp <david.allsopp@metastack.com>2022-06-13 11:31:50 +0100
commit5f4859b8c8c08c9ab8a888a90f81435a1facc462 (patch)
tree05ace867df3fd4985983412322184c73729186e2
parenta3023cd9b63607c637f03924d0c0a9ceed099eec (diff)
downloadocaml-5f4859b8c8c08c9ab8a888a90f81435a1facc462.tar.gz
Rename the two Windows unicode C functions
-rw-r--r--Changes4
-rw-r--r--otherlibs/unix/createprocess.c8
-rw-r--r--otherlibs/unix/readlink_win32.c4
-rw-r--r--runtime/caml/osdeps.h20
-rw-r--r--runtime/startup_byt.c4
-rw-r--r--runtime/win32.c20
-rwxr-xr-xtools/check-symbol-names3
-rw-r--r--yacc/wstr.c8
8 files changed, 38 insertions, 33 deletions
diff --git a/Changes b/Changes
index 3b69b41448..5446aee6af 100644
--- a/Changes
+++ b/Changes
@@ -428,6 +428,10 @@ OCaml 4.14.0
- #10730, 10731: Fix bug in `Obj.reachable_words` causing a slowdown when called
multiple time (Alain Frisch, report by ygrek, review by Xavier Leroy)
+- #10926: Rename the two internal Windows Unicode functions with `caml_` prefix
+ instead of `win_`.
+ (David Allsopp, review by Kate Deplaix and Xavier Leroy)
+
### Code generation and optimizations:
- #10578: Increase the number of integer registers used for
diff --git a/otherlibs/unix/createprocess.c b/otherlibs/unix/createprocess.c
index 57d91863c7..7473af30ad 100644
--- a/otherlibs/unix/createprocess.c
+++ b/otherlibs/unix/createprocess.c
@@ -120,11 +120,11 @@ value win_create_process_native(value cmd, value cmdline, value env,
if (Is_some(env)) {
env = Some_val(env);
size =
- win_multi_byte_to_wide_char(String_val(env),
- caml_string_length(env), NULL, 0);
+ caml_win32_multi_byte_to_wide_char(String_val(env),
+ caml_string_length(env), NULL, 0);
wenv = caml_stat_alloc((size + 1)*sizeof(wchar_t));
- win_multi_byte_to_wide_char(String_val(env),
- caml_string_length(env), wenv, size);
+ caml_win32_multi_byte_to_wide_char(String_val(env),
+ caml_string_length(env), wenv, size);
wenv[size] = 0;
} else {
wenv = NULL;
diff --git a/otherlibs/unix/readlink_win32.c b/otherlibs/unix/readlink_win32.c
index 205ff6e7fb..cbe1ba83bd 100644
--- a/otherlibs/unix/readlink_win32.c
+++ b/otherlibs/unix/readlink_win32.c
@@ -77,11 +77,11 @@ CAMLprim value unix_readlink(value opath)
int cbLen = point->SymbolicLinkReparseBuffer.SubstituteNameLength / sizeof(WCHAR);
int len;
len =
- win_wide_char_to_multi_byte(
+ caml_win32_wide_char_to_multi_byte(
point->SymbolicLinkReparseBuffer.PathBuffer + point->SymbolicLinkReparseBuffer.SubstituteNameOffset / sizeof(WCHAR),
cbLen, NULL, 0);
result = caml_alloc_string(len);
- win_wide_char_to_multi_byte(
+ caml_win32_wide_char_to_multi_byte(
point->SymbolicLinkReparseBuffer.PathBuffer + point->SymbolicLinkReparseBuffer.SubstituteNameOffset / sizeof(WCHAR),
cbLen,
(char *)String_val(result),
diff --git a/runtime/caml/osdeps.h b/runtime/caml/osdeps.h
index b7db75da6b..adf33b7c04 100644
--- a/runtime/caml/osdeps.h
+++ b/runtime/caml/osdeps.h
@@ -121,14 +121,18 @@ extern wchar_t *caml_win32_getenv(wchar_t const *);
/* Windows Unicode support */
-CAMLextern int win_multi_byte_to_wide_char(const char* s,
- int slen,
- wchar_t *out,
- int outlen);
-CAMLextern int win_wide_char_to_multi_byte(const wchar_t* s,
- int slen,
- char *out,
- int outlen);
+CAMLextern int caml_win32_multi_byte_to_wide_char(const char* s,
+ int slen,
+ wchar_t *out,
+ int outlen);
+CAMLextern int caml_win32_wide_char_to_multi_byte(const wchar_t* s,
+ int slen,
+ char *out,
+ int outlen);
+
+/* Legacy names */
+#define win_multi_byte_to_wide_char caml_win32_multi_byte_to_wide_char
+#define win_wide_char_to_multi_byte caml_win32_wide_char_to_multi_byte
CAMLextern int caml_win32_isatty(int fd);
diff --git a/runtime/startup_byt.c b/runtime/startup_byt.c
index a7061ebae2..235605fb9c 100644
--- a/runtime/startup_byt.c
+++ b/runtime/startup_byt.c
@@ -235,9 +235,9 @@ static char_os * read_section_to_os(int fd, struct exec_trailer *trail,
if (read(fd, data, len) != len)
caml_fatal_error("error reading section %s", name);
data[len] = 0;
- wlen = win_multi_byte_to_wide_char(data, len, NULL, 0);
+ wlen = caml_win32_multi_byte_to_wide_char(data, len, NULL, 0);
wdata = caml_stat_alloc((wlen + 1)*sizeof(wchar_t));
- win_multi_byte_to_wide_char(data, len, wdata, wlen);
+ caml_win32_multi_byte_to_wide_char(data, len, wdata, wlen);
wdata[wlen] = 0;
caml_stat_free(data);
return wdata;
diff --git a/runtime/win32.c b/runtime/win32.c
index 5212fe1f62..cad1aa9070 100644
--- a/runtime/win32.c
+++ b/runtime/win32.c
@@ -864,8 +864,8 @@ static uintnat windows_unicode_strict = 1;
the argument string is encoded in the local codepage. */
static uintnat windows_unicode_fallback = 1;
-CAMLexport int win_multi_byte_to_wide_char(const char *s, int slen,
- wchar_t *out, int outlen)
+CAMLexport int caml_win32_multi_byte_to_wide_char(const char *s, int slen,
+ wchar_t *out, int outlen)
{
int retcode;
@@ -896,8 +896,8 @@ CAMLexport int win_multi_byte_to_wide_char(const char *s, int slen,
#define WC_ERR_INVALID_CHARS 0
#endif
-CAMLexport int win_wide_char_to_multi_byte(const wchar_t *s, int slen,
- char *out, int outlen)
+CAMLexport int caml_win32_wide_char_to_multi_byte(const wchar_t *s, int slen,
+ char *out, int outlen)
{
int retcode;
@@ -928,9 +928,9 @@ CAMLexport value caml_copy_string_of_utf16(const wchar_t *s)
slen = wcslen(s);
/* Do not include final NULL */
- retcode = win_wide_char_to_multi_byte(s, slen, NULL, 0);
+ retcode = caml_win32_wide_char_to_multi_byte(s, slen, NULL, 0);
v = caml_alloc_string(retcode);
- win_wide_char_to_multi_byte(s, slen, (char *)String_val(v), retcode);
+ caml_win32_wide_char_to_multi_byte(s, slen, (char *)String_val(v), retcode);
return v;
}
@@ -940,9 +940,9 @@ CAMLexport wchar_t* caml_stat_strdup_to_utf16(const char *s)
wchar_t * ws;
int retcode;
- retcode = win_multi_byte_to_wide_char(s, -1, NULL, 0);
+ retcode = caml_win32_multi_byte_to_wide_char(s, -1, NULL, 0);
ws = caml_stat_alloc_noexc(retcode * sizeof(*ws));
- win_multi_byte_to_wide_char(s, -1, ws, retcode);
+ caml_win32_multi_byte_to_wide_char(s, -1, ws, retcode);
return ws;
}
@@ -952,9 +952,9 @@ CAMLexport caml_stat_string caml_stat_strdup_of_utf16(const wchar_t *s)
caml_stat_string out;
int retcode;
- retcode = win_wide_char_to_multi_byte(s, -1, NULL, 0);
+ retcode = caml_win32_wide_char_to_multi_byte(s, -1, NULL, 0);
out = caml_stat_alloc(retcode);
- win_wide_char_to_multi_byte(s, -1, out, retcode);
+ caml_win32_wide_char_to_multi_byte(s, -1, out, retcode);
return out;
}
diff --git a/tools/check-symbol-names b/tools/check-symbol-names
index 73aab89f32..74f01f3e55 100755
--- a/tools/check-symbol-names
+++ b/tools/check-symbol-names
@@ -34,9 +34,6 @@ $2 ~ /^_?uerror$/ { next }
$2 ~ /^__x86.get_pc_thunk./ { next }
# for mingw32
$2 ~ /^.debug_/ { next }
-# windows unicode support
-$2 ~ /^_win_multi_byte_to_wide_char$/ { next }
-$2 ~ /^_win_wide_char_to_multi_byte$/ { next }
# print the rest
{ found=1; print $1 " " $2 " " $3 }
# fail if there were any results
diff --git a/yacc/wstr.c b/yacc/wstr.c
index c22feeeccd..78c334e691 100644
--- a/yacc/wstr.c
+++ b/yacc/wstr.c
@@ -22,8 +22,8 @@ static int windows_unicode_enabled = WINDOWS_UNICODE;
static int windows_unicode_strict = 1;
/* Adapted from runtime/win32.c */
-int win_wide_char_to_multi_byte(const wchar_t *s, int slen,
- char *out, int outlen)
+int caml_win32_wide_char_to_multi_byte(const wchar_t *s, int slen,
+ char *out, int outlen)
{
int retcode;
@@ -50,10 +50,10 @@ char* caml_stat_strdup_of_utf16(const wchar_t *s)
char *out = NULL;
int retcode;
- retcode = win_wide_char_to_multi_byte(s, -1, NULL, 0);
+ retcode = caml_win32_wide_char_to_multi_byte(s, -1, NULL, 0);
if (retcode >= 0) {
out = (char *)malloc(retcode);
- win_wide_char_to_multi_byte(s, -1, out, retcode);
+ caml_win32_wide_char_to_multi_byte(s, -1, out, retcode);
}
return out;