pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: Fix nfs_mount --help output
Posted by Anonymous on Wed 27th Nov 2024 09:39
raw | new post

  1. From 0adf0953de799580c470d26975a1b81ba54db045 Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Wed, 27 Nov 2024 10:16:12 +0100
  4. Subject: [PATCH] mount: nfs_mount.exe --help no longer works with wide-char
  5.  stream mode
  6.  
  7. nfs_mount.exe --help no longer works with wide-char stream mode.
  8. It seems all attemps to use single-byte functions like |printf()|
  9. after |_setmode(_fileno(stdout), _O_WTEXT);| will trigger an
  10. exception.
  11.  
  12. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  13. ---
  14. mount/mount.c | 21 ++++++++++++++-------
  15.  1 file changed, 14 insertions(+), 7 deletions(-)
  16.  
  17. diff --git a/mount/mount.c b/mount/mount.c
  18. index 7c8b0db..6537502 100644
  19. --- a/mount/mount.c
  20. +++ b/mount/mount.c
  21. @@ -79,11 +79,11 @@ void PrintErrorMessage(
  22.  static
  23.  void PrintMountUsage(LPWSTR pProcess)
  24.  {
  25. -    (void)fprintf(stderr,
  26. -        "Usage: %S [options] <drive letter|*> <hostname>:<path>\n"
  27. -        "Usage: %S [options] <hostname>:<path>\n"
  28. -        "Usage: %S -d [options] <drive letter>\n"
  29. -        "Usage: %S\n"
  30. +    (void)fwprintf(stderr,
  31. +        L"Usage: %s [options] <drive letter|*> <hostname>:<path>\n"
  32. +        "Usage: %s [options] <hostname>:<path>\n"
  33. +        "Usage: %s -d [options] <drive letter>\n"
  34. +        "Usage: %s\n"
  35.  
  36.          "* Options:\n"
  37.          "\t-h, --help, /?\thelp\n"
  38. @@ -173,8 +173,8 @@ void PrintMountUsage(LPWSTR pProcess)
  39.  static
  40.  void PrintUmountUsage(LPWSTR pProcess)
  41.  {
  42. -    (void)fprintf(stderr,
  43. -        "Usage: %S [options] <drive letter>\n"
  44. +    (void)fwprintf(stderr,
  45. +        L"Usage: %s [options] <drive letter>\n"
  46.  
  47.          "* Options:\n"
  48.          "\t-h, --help, /?\thelp\n"
  49. @@ -568,6 +568,13 @@ int __cdecl wmain(int argc, wchar_t *argv[])
  50.      int crtsetdbgflags = 0;
  51.  
  52.      (void)setlocale(LC_ALL, "");
  53. +    /*
  54. +     * |_O_WTEXT| - set streams to wide-char mode so we print
  55. +     * non-ASCII characters like Japanese or Chinese/GB18030
  56. +     * correctly.
  57. +     * Note that in CRT/UCRT any attempt to use single-byte
  58. +     * functions like |printf()| will trigger an exception
  59. +     */
  60.      (void)_setmode(_fileno(stdout), _O_WTEXT);
  61.      (void)_setmode(_fileno(stderr), _O_WTEXT);
  62.  
  63. --
  64. 2.45.1

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at