CRT getopt() function should use CRT's getenv function instead of WinAPI
GetEnvironmentVariableW because CRT env does not have to be in sync with
WinAPI (e.g. when changing 3rd argument of main() or when changing global
environ variable).

Usage of CRT getenv() is not suitable for UWP builds as in UWP it is
mostly impossible to implement getenv-like function. But CRT has
getenv_s() API which can be implemented by both UWP and mingw-w64.

So use getenv_s() in mingw-w64 getopt() which fixes both issues.

Pali Rohár (4):
  crt: Provide mingw-w64 emulation of getenv_s function for all CRT
    import libraries
  winstorecompat: Provide getenv_s() function
  Revert "crt: use GetEnvironmentVariableW in getopt"
  crt: getopt: Use getenv_s() instead of getenv()

 mingw-w64-crt/Makefile.am                     |  2 +
 mingw-w64-crt/lib-common/msvcrt.def.in        |  2 +-
 mingw-w64-crt/misc/getopt.c                   |  3 +-
 mingw-w64-crt/secapi/getenv_s.c               | 61 ++++++++++++++++
 .../winstorecompat/Makefile.am                |  1 +
 .../winstorecompat/src/getenv_s.c             | 73 +++++++++++++++++++
 6 files changed, 140 insertions(+), 2 deletions(-)
 create mode 100644 mingw-w64-crt/secapi/getenv_s.c
 create mode 100644 mingw-w64-libraries/winstorecompat/src/getenv_s.c

-- 
2.20.1



_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to