diff options
| author | Eli Zaretskii | 2025-11-16 09:36:03 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2025-11-16 09:36:03 +0200 |
| commit | 2ab07033ea7c92c7f2f0bbc465d6729e1f2dcfbc (patch) | |
| tree | 6636f810585491b502f3a2e770b102f27275a8b2 /src | |
| parent | cc9ec87e537f890d8fb91c84578c3963c5d92f62 (diff) | |
| download | emacs-2ab07033ea7c92c7f2f0bbc465d6729e1f2dcfbc.tar.gz emacs-2ab07033ea7c92c7f2f0bbc465d6729e1f2dcfbc.zip | |
Workaround for MSVCRT stdio on MS-Windows for CJK locales
MSVCRT implementation of stdio functions which output
characters one by one fails for CJK double-byte encodings.
Gnulib provides replacement functions which work around
those bugs. This change makes Emacs and lib-src programs
use the replacements when Emacs is linked against MSVCRT.
* src/conf_post.h (fwrite, fprintf, printf, vfprintf, vprintf)
[WINDOWSNT]: Redirect to Gnulib replacements when Emacs is linked
against MSVCRT (as opposed to UCRT). Suggested by Bruno Haible
<bruno@clisp.org>.
Diffstat (limited to 'src')
| -rw-r--r-- | src/conf_post.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/conf_post.h b/src/conf_post.h index aaf4fb59ffb..e946f6fc90b 100644 --- a/src/conf_post.h +++ b/src/conf_post.h | |||
| @@ -396,3 +396,41 @@ extern int emacs_setenv_TZ (char const *); | |||
| 396 | : S_ISCHR (mode) ? DT_CHR : S_ISFIFO (mode) ? DT_FIFO \ | 396 | : S_ISCHR (mode) ? DT_CHR : S_ISFIFO (mode) ? DT_FIFO \ |
| 397 | : S_ISSOCK (mode) ? DT_SOCK : DT_UNKNOWN) | 397 | : S_ISSOCK (mode) ? DT_SOCK : DT_UNKNOWN) |
| 398 | #endif /* MSDOS */ | 398 | #endif /* MSDOS */ |
| 399 | |||
| 400 | #if defined WINDOWSNT | ||
| 401 | # if !defined _UCRT | ||
| 402 | # include <stdarg.h> | ||
| 403 | # include <stdio.h> | ||
| 404 | # include <stddef.h> | ||
| 405 | |||
| 406 | /* Workarounds for MSVCRT bugs. | ||
| 407 | |||
| 408 | The functions below are in Gnulib, but their prototypes and | ||
| 409 | redirections must be here because the MS-Windows build omits the | ||
| 410 | Gnulib stdio-h module, which does the below in Gnulib's stdio.h | ||
| 411 | file, which is not used by the MS-Windows build. */ | ||
| 412 | |||
| 413 | extern size_t gl_consolesafe_fwrite (const void *ptr, size_t size, | ||
| 414 | size_t nmemb, FILE *fp) | ||
| 415 | ARG_NONNULL ((1, 4)); | ||
| 416 | extern int gl_consolesafe_fprintf (FILE *restrict fp, | ||
| 417 | const char *restrict format, ...) | ||
| 418 | ATTRIBUTE_FORMAT_PRINTF (2, 3) | ||
| 419 | ARG_NONNULL ((1, 2)); | ||
| 420 | extern int gl_consolesafe_printf (const char *restrict format, ...) | ||
| 421 | ATTRIBUTE_FORMAT_PRINTF (1, 2) | ||
| 422 | ARG_NONNULL ((1)); | ||
| 423 | extern int gl_consolesafe_vfprintf (FILE *restrict fp, | ||
| 424 | const char *restrict format, va_list args) | ||
| 425 | ATTRIBUTE_FORMAT_PRINTF (2, 0) | ||
| 426 | ARG_NONNULL ((1, 2)); | ||
| 427 | extern int gl_consolesafe_vprintf (const char *restrict format, va_list args) | ||
| 428 | ATTRIBUTE_FORMAT_PRINTF (1, 0) | ||
| 429 | ARG_NONNULL ((1)); | ||
| 430 | # define fwrite gl_consolesafe_fwrite | ||
| 431 | # define fprintf gl_consolesafe_fprintf | ||
| 432 | # define printf gl_consolesafe_printf | ||
| 433 | # define vfprintf gl_consolesafe_vfprintf | ||
| 434 | # define vprintf gl_consolesafe_vprintf | ||
| 435 | # endif /* !_UCRT */ | ||
| 436 | #endif /* WINDOWSNT */ | ||