1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-06-30 19:12:48 -05:00

dup_mb_to_wc, dup_wc_to_mb: remove the 'flags' parameter.

This parameter was undocumented, and Windows-specific: its semantics
date from before PuTTY was cross-platform, and are "Pass this flags
parameter straight through to the Win32 API's conversion functions".
So in Windows platform code you can pass flags like MB_USEGLYPHCHARS,
but in cross-platform code, you dare not pass anything nonzero at all
because the Unix frontend won't recognise it (or, likely, even
compile).

I've kept the flag for now in the underlying mb_to_wc / wc_to_mb
functions. Partly that's because there's one place in the Windows code
where the parameter _is_ used; mostly, it's because I'm about to
replace those functions anyway, so there's no point in editing all the
call sites twice.
This commit is contained in:
Simon Tatham
2024-09-24 08:46:39 +01:00
parent ed621590b0
commit c4c4d2c5cb
10 changed files with 31 additions and 32 deletions

View File

@ -9,14 +9,14 @@
#include "putty.h"
#include "misc.h"
wchar_t *dup_mb_to_wc_c(int codepage, int flags, const char *string,
wchar_t *dup_mb_to_wc_c(int codepage, const char *string,
size_t inlen, size_t *outlen_p)
{
assert(inlen <= INT_MAX);
size_t mult;
for (mult = 1 ;; mult++) {
wchar_t *ret = snewn(mult*inlen + 2, wchar_t);
size_t outlen = mb_to_wc(codepage, flags, string, inlen, ret,
size_t outlen = mb_to_wc(codepage, 0, string, inlen, ret,
mult*inlen + 1);
if (outlen < mult*inlen+1) {
if (outlen_p)
@ -28,7 +28,7 @@ wchar_t *dup_mb_to_wc_c(int codepage, int flags, const char *string,
}
}
wchar_t *dup_mb_to_wc(int codepage, int flags, const char *string)
wchar_t *dup_mb_to_wc(int codepage, const char *string)
{
return dup_mb_to_wc_c(codepage, flags, string, strlen(string), NULL);
return dup_mb_to_wc_c(codepage, string, strlen(string), NULL);
}

View File

@ -11,7 +11,7 @@
#include "putty.h"
#include "misc.h"
char *dup_wc_to_mb_c(int codepage, int flags, const wchar_t *string,
char *dup_wc_to_mb_c(int codepage, const wchar_t *string,
size_t inlen, const char *defchr, size_t *outlen_p)
{
assert(inlen <= INT_MAX);
@ -20,7 +20,7 @@ char *dup_wc_to_mb_c(int codepage, int flags, const wchar_t *string,
char *out = snewn(outsize, char);
while (true) {
size_t outlen = wc_to_mb(codepage, flags, string, inlen, out, outsize,
size_t outlen = wc_to_mb(codepage, 0, string, inlen, out, outsize,
defchr);
/* We can only be sure we've consumed the whole input if the
* output is not within a multibyte-character-length of the
@ -36,9 +36,8 @@ char *dup_wc_to_mb_c(int codepage, int flags, const wchar_t *string,
}
}
char *dup_wc_to_mb(int codepage, int flags, const wchar_t *string,
char *dup_wc_to_mb(int codepage, const wchar_t *string,
const char *defchr)
{
return dup_wc_to_mb_c(codepage, flags, string, wcslen(string),
defchr, NULL);
return dup_wc_to_mb_c(codepage, string, wcslen(string), defchr, NULL);
}