/*
* wchar.h
- * This file has no copyright assigned and is placed in the Public Domain.
- * This file is a part of the mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within the package.
*
- * Defines of all functions for supporting wide characters. Actually it
- * just includes all those headers, which is not a good thing to do from a
- * processing time point of view, but it does mean that everything will be
- * in sync.
+ * Declarations relating to support for wide characters; many are simply
+ * inherited by (sub-optimal) inclusion of other header files.
+ *
+ * $Id$
+ *
+ * Unattributed original source.
+ * Adapted by Rob Savoye <rob@cygnus.com>
+ * Copyright (C) 1997, 1999-2009, 2011, 2015, 2016, 2018-2020,
+ * MinGW.org Project.
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice, this permission notice, and the following
+ * disclaimer shall be included in all copies or substantial portions of
+ * the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OF OR OTHER
+ * DEALINGS IN THE SOFTWARE.
*
*/
+#ifndef _WCHAR_H
+#pragma GCC system_header
+
+/* This header declares prototypes for wchar_t string functions, as are
+ * prescribed by ISO-C, but which MSVC also expects, (in contravention of
+ * ISO-C prescriptions), to find in <string.h>. To accommodate this MSVC
+ * anomaly, we make provision for <string.h> to include a selected subset
+ * of <wchar.h>; thus, we do not immediately define _WCHAR_T...
+ */
+#ifndef __STRING_H_SOURCED__
+/* ...but defer it until we have confirmed that this is NOT inclusion for
+ * only this subset of <wchar.h> declarations.
+ */
+#define _WCHAR_H
-#ifndef _WCHAR_H_
-#define _WCHAR_H_
-
-/* All the headers include this file. */
+/* All MinGW headers are required to include <_mingw.h>; in the case of
+ * selective inclusion by <string.h>, we expect it to have already done
+ * so, but since that doesn't apply here, we must do it ourselves.
+ */
#include <_mingw.h>
-#ifndef RC_INVOKED
-
-#define __need_size_t
-#define __need_wint_t
-#define __need_wchar_t
-#define __need_NULL
-#include <stddef.h>
-
-#ifndef __VALIST
-#if defined __GNUC__ && __GNUC__ >= 3
-#define __need___va_list
-#include <stdarg.h>
-#define __VALIST __builtin_va_list
-#else
-#define __VALIST char*
-#endif
-#endif
-
-#endif /* Not RC_INVOKED */
+#ifndef __STRICT_ANSI__
+ /* MSDN says that isw* char classifications appear in both <wchar.h>,
+ * and in <wctype.h>. Although these <wctype.h> classifications are as
+ * prescribed by ISO-C, their exposure in <wchar.h> is not; nonetheless,
+ * we replicate them here, for MSDN conformity.
+ */
+# include <wctype.h>
-/*
- * MSDN says that isw* char classifications are in wchar.h and wctype.h.
- * Although the wctype names are ANSI, their exposure in this header is
- * not.
- */
-#include <wctype.h>
+ /* This is also necessary, to support the non-ANSI wchar.h declarations
+ * which MSDN identifies as being provided here.
+ */
+# include <sys/types.h>
-#ifndef __STRICT_ANSI__
-/* This is necessary to support the the non-ANSI wchar declarations
- here. */
-#include <sys/types.h>
-#endif /* __STRICT_ANSI__ */
+#endif /* !__STRICT_ANSI__ */
#define WCHAR_MIN 0
#define WCHAR_MAX 0xffff
-#ifndef WEOF
-#define WEOF (wchar_t)(0xFFFF)
-#endif
+#define WEOF (wchar_t)(0xffff)
#ifndef RC_INVOKED
+#define __WCHAR_H_SOURCED__
+/* ISO-C, POSIX, and Microsoft specify an overlap of content between
+ * <wchar.h> and other system header files; by inclusion of such other
+ * headers within this "__WCHAR_H_SOURCED__" scope, we may selectively
+ * retrieve the overlapping content, without requiring duplication of
+ * that content here; thus, from...
+ */
+#include "stdio.h"
+/* ...we obtain (possibly indirect) definitions and declarations for:
+ *
+ * macros NULL, FILENAME_MAX
+ * types size_t, wchar_t, wint_t, va_list (a.k.a. __VALIST), FILE
+ * types ssize_t, off_t, __off64_t, (conditionally, as needed)
+ *
+ * int fwprintf (FILE *, const wchar_t *, ...);
+ * int wprintf (const wchar_t *, ...);
+ * int vfwprintf (FILE *, const wchar_t *, __VALIST);
+ * int vwprintf (const wchar_t *, __VALIST);
+ * int snwprintf (wchar_t *, size_t, const wchar_t *, ...);
+ * int _snwprintf (wchar_t *, size_t, const wchar_t *, ...);
+ * int _vscwprintf (const wchar_t *, __VALIST);
+ * int _vsnwprintf (wchar_t *, size_t, const wchar_t *, __VALIST);
+ * int vsnwprintf (wchar_t *, size_t, const wchar_t *, __VALIST);
+ * int fwscanf (FILE *, const wchar_t *, ...);
+ * int wscanf (const wchar_t *, ...);
+ * int swscanf (const wchar_t *, const wchar_t *, ...);
+ * int vwscanf (const wchar_t *, __VALIST);
+ * int vfwscanf (FILE *, const wchar_t *, __VALIST);
+ * int vswscanf (const wchar_t *, const wchar_t *, __VALIST);
+ * wint_t fgetwc (FILE *);
+ * wint_t fputwc (wchar_t, FILE *);
+ * wint_t ungetwc (wchar_t, FILE *);
+ *
+ * The following pair of Microsoft functions conflict with their
+ * corresponding ISO-C prototypes; consequently they will not be
+ * declared when "__STRICT_ANSI__" checking is in effect:
+ *
+ * int swprintf (wchar_t *, const wchar_t *, ...);
+ * int vswprintf (wchar_t *, const wchar_t *, __VALIST);
+ *
+ * The following group of functions is specified by ISO-C, but
+ * their Microsoft implementations are available only if use of
+ * "__MSVCRT__" is specified:
+ *
+ * wchar_t * fgetws (wchar_t *, int, FILE *);
+ * int fputws (const wchar_t *, FILE *);
+ * wint_t getwc (FILE *);
+ * wint_t getwchar (void);
+ * wint_t putwc (wint_t, FILE *);
+ * wint_t putwchar (wint_t);
+ *
+ * The following group of functions is also dependent on use of
+ * "__MSVCRT__"; however, these are Microsoft specific, so they
+ * are not declared if "__STRICT_ANSI__" checking is specified:
+ *
+ * wchar_t * _getws (wchar_t *);
+ * int _putws (const wchar_t *);
+ * FILE * _wfdopen (int, const wchar_t *);
+ * FILE * _wfopen (const wchar_t *, const wchar_t *);
+ * FILE * _wfreopen (const wchar_t *, const wchar_t *, FILE *);
+ * FILE * _wfsopen (const wchar_t *, const wchar_t *, int);
+ * wchar_t * _wtmpnam (wchar_t *);
+ * wchar_t * _wtempnam (const wchar_t *, const wchar_t *);
+ * int _wrename (const wchar_t *, const wchar_t *);
+ * int _wremove (const wchar_t *);
+ * void _wperror (const wchar_t *);
+ * FILE * _wpopen (const wchar_t *, const wchar_t *);
+ *
+ *
+ * In similar fashion, from...
+ */
+#include "stdlib.h"
+/* ...we obtain prototypes for universally supported functions:
+ *
+ * long wcstol (const wchar_t *, wchar_t **, int);
+ * unsigned long wcstoul (const wchar_t *, wchar_t **, int);
+ * double wcstod (const wchar_t *, wchar_t **);
+ *
+ * The following are Microsoft specific, and require MSCVRT.DLL,
+ * or any of its non-free derivatives; they are not available to
+ * applications which use CRTDLL.DLL:
+ *
+ * wchar_t *_wgetenv (const wchar_t *);
+ * int _wputenv (const wchar_t *);
+ * void _wsearchenv (const wchar_t *, const wchar_t *, wchar_t *);
+ * int _wsystem (const wchar_t *);
+ * void _wmakepath (wchar_t *, const wchar_t *, const wchar_t *,
+ * const wchar_t *, const wchar_t *
+ * );
+ * void _wsplitpath (const wchar_t *, wchar_t *, wchar_t *,
+ * wchar_t *, wchar_t *
+ * );
+ * wchar_t *_wfullpath (wchar_t *, const wchar_t *, size_t);
+ *
+ * ...with this pair requiring either WinXP (or later), or one of
+ * the non-free MSVC runtimes from MSVCR70.DLL onwards:
+ *
+ * __int64 _wcstoi64 (const wchar_t *, wchar_t **, int);
+ * unsigned __int64 _wcstoui64 (const wchar_t *, wchar_t **, int);
+ *
+ * ...and this pair requiring Win-Vista (or later), or a non-free
+ * MSVC runtime from MSVCR80.DLL onwards:
+ *
+ * __int64 _wcstoi64_l (const wchar_t *, wchar_t **, int, _locale_t);
+ * unsigned __int64 _wcstoui64_l (const wchar_t *, wchar_t **,
+ * int, _locale_t);
+ * );
+ *
+ * ...while this pair are ISO-C99 standards, which are available
+ * in libmingwex.a, but not in any version of MSVCRT.DLL, (nor in
+ * any of its non-free derivatives prior to MSVCR120.DLL), nor in
+ * CRTDLL.DLL:
+ *
+ * float wcstof (const wchar_t *restrict, wchar_t **restrict);
+ * long double wcstold (const wchar_t *restrict, wchar_t **restrict);
+ *
+ *
+ * while...
+ */
+#ifndef __STRICT_ANSI__
+/* ...when NOT compiling with "__STRICT_ANSI__" conformity checking,
+ * from...
+ */
+#include "direct.h"
+/* ...we obtain prototypes for each of the following functions,
+ * (none of which are available when using CRTDLL.DLL):
+ *
+ * int _wchdir (const wchar_t *);
+ * wchar_t *_wgetcwd (wchar_t *, int);
+ * wchar_t *_wgetdcwd (int, wchar_t *, int);
+ * int _wmkdir (const wchar_t *);
+ * int _wrmdir (const wchar_t *);
+ *
+ *
+ * while from...
+ */
+#include "sys/stat.h"
+/* ...we obtain function prototypes, and all associated data type
+ * definitions for this pair of actual functions, in all versions of
+ * MSVCRT.DLL, and its non-free derivatives preceding MSVCR80.DLL, (or
+ * inline replacement implementations for MSVCR80.DLL and later):
+ *
+ * int _wstat (const wchar_t *, struct _stat *);
+ * int _wstati64 (const wchar_t *, struct _stati64 *);
+ *
+ * ...this additional actual function, available in MSVCRT.DLL from
+ * Win2K onwards, or in non-free MSVCR61.DLL and again requiring an
+ * inline replacement from MSVCR80.DLL onwards:
+ *
+ * int _wstat64 (const wchar_t *, struct __stat64 *);
+ *
+ * ...and these actual functions, which are available only in non-free
+ * MSVCR80.DLL, and its later derivatives:
+ *
+ * int _wstat32 (const wchar_t *, struct __stat32 *);
+ * int _wstat32i64 (const wchar_t *, struct _stat32i64 *);
+ * int _wstat64i32 (const wchar_t *, struct _stat64i32 *);
+ *
+ *
+ * from...
+ */
+#include "conio.h"
+/* ...we obtain, depending on active MSVCRT.DLL version conformity,
+ * or non-free run-time version selection, an appropriate subset of:
+ *
+ * wint_t _getwch (void);
+ * wint_t _getwche (void);
+ * wint_t _ungetwch (wint_t);
+ *
+ * ...and for non-free run-times from MSVCR80.DLL onwards only:
+ *
+ * wint_t _getwch_nolock (void);
+ * wint_t _getwche_nolock (void);
+ * wint_t _ungetwch_nolock (wint_t);
+ *
+ *
+ * and from...
+ */
+#include "io.h"
+/* ...we obtain function prototypes for each of the following, which
+ * are available in all versions of MSVCRT.DLL, (and all its non-free
+ * derivatives), but are not supported by CRTDLL.DLL:
+ *
+ * int _waccess (const wchar_t *, int);
+ * int _wchmod (const wchar_t *, int);
+ * int _wcreat (const wchar_t *, int);
+ * int _wopen (const wchar_t *, int, ...);
+ * int _wsopen (const wchar_t *, int, int, ...);
+ * int _wunlink (const wchar_t *);
+ * wchar_t *_wmktemp (wchar_t *);
+ *
+ * ...and also function prototypes and definitions of all associated
+ * data types and manifest constants for the following, each of which
+ * is physically implemented in all versions of MSVCRT.DLL, and in each
+ * of its non-free variants prior to MSVCR80.DLL, or emulated by inline
+ * replacement functions for MSVCR80.DLL and later:
+ *
+ * intptr_t _wfindfirst (wchar_t *, struct _wfinddata_t *);
+ * int _wfindnext (intptr_t, struct _wfinddata_t *);
+ *
+ * intptr_t _wfindfirsti64 (wchar_t *, struct _wfinddatai64_t *);
+ * int _wfindnexti64 (intptr_t, struct _wfinddatai64_t *);
+ *
+ * ...this additional pair of functions, available in all versions of
+ * MSVCRT.DLL from Win2K, and non-free variants from MSVCR61.DLL:
+ *
+ * intptr_t _wfindfirst64 (wchar_t *, struct __wfinddata64_t *);
+ * int _wfindnext64 (intptr_t, struct __wfinddata64_t *);
+ *
+ * ...and these, which are only available in the non-free run-times
+ * from MSVCR80.DLL onwards:
+ *
+ * intptr_t _wfindfirst32 (wchar_t *, struct _wfinddata32_t *);
+ * int _wfindnext32 (intptr_t, struct _wfinddata32_t *);
+ *
+ * intptr_t _wfindfirst32i64 (wchar_t *, struct _wfinddata32i64_t *);
+ * int _wfindnext32i64 (intptr_t, struct _wfinddata32i64_t *);
+ *
+ * intptr_t _wfindfirst64i32 (wchar_t *, struct _wfinddata64i32_t *);
+ * int _wfindnext64i32 (intptr_t, struct _wfinddata64i32_t *);
+ *
+ * Additionally, although Microsoft's <wchar.h> may not declare it,
+ * this is required to complement all variants of the _wfindfirst()
+ * and _wfindnext() API, so we also declare the prototype for:
+ *
+ * int _findclose (intptr_t);
+ */
+#endif /* !__STRICT_ANSI__ */
-#ifdef __cplusplus
-extern "C" {
-#endif
+/* From...
+ */
+#include "time.h"
+/* ...we always obtain an opaque forward declaration of:
+ *
+ * struct tm
+ *
+ * ...and prototype declarations for the following ISO-C99 function,
+ * (which is always provided):
+ *
+ * size_t wcsftime (wchar_t *, size_t, const wchar_t *, const struct tm *);
+ *
+ * ...together with the following non-ISO-C functions, (which are
+ * NOT exposed when "__STRICT_ANSI__" checking is enabled):
+ *
+ * wchar_t *_wctime (const time_t *);
+ * wchar_t *_wasctime (const struct tm *);
+ * wchar_t *_wstrdate (wchar_t *);
+ * wchar_t *_wstrtime (wchar_t *);
+ *
+ * Of the preceding group, we also note that, while it remains in
+ * all versions of MSVCRT.DLL, (using a strictly 32-bit data type
+ * to represent its "time_t" argument), the _wctime() function is
+ * NOT present in MSVCR80.DLL, and later versions of the non-free
+ * MSVC runtime libraries, in which it is replaced by either of:
+ *
+ * wchar_t *_wctime64 (const __time64_t *);
+ * wchar_t *_wctime32 (const __time32_t *);
+ *
+ * ...with the actual replacement being chosen at compile time, on
+ * the basis of the user specified "_USE_32BIT_TIME_T" feature test
+ * macro, (a Microsoft specific, brain damaged concept), which maps
+ * _wctime() itself, as an in-line alias for its corresponding
+ * replacement library function.
+ *
+ */
+#ifndef __STRICT_ANSI__
+/* Once again, when NOT compiling with "__STRICT_ANSI__" conformity
+ * checking, from...
+ */
+#include "locale.h"
+/* ...we obtain the declaration for:
+ *
+ * wchar_t *_wsetlocale (int, const wchar_t *);
+ *
+ *
+ * and from...
+ */
+#include "process.h"
+/* ...we obtain function prototypes for:
+ *
+ * intptr_t _wexecl (const wchar_t *, const wchar_t *, ...);
+ * intptr_t _wexecle (const wchar_t *, const wchar_t *, ...);
+ * intptr_t _wexeclp (const wchar_t *, const wchar_t *, ...);
+ * intptr_t _wexeclpe (const wchar_t *, const wchar_t *, ...);
+ *
+ * intptr_t _wexecv (const wchar_t *, const wchar_t * const *);
+ * intptr_t _wexecve (
+ * const wchar_t *, const wchar_t * const *, const wchar_t * const *
+ * );
+ * intptr_t _wexecvp (const wchar_t *, const wchar_t * const *);
+ * intptr_t _wexecvpe (
+ * const wchar_t *, const wchar_t * const *, const wchar_t * const *
+ * );
+ *
+ * intptr_t _wspawnl (int, const wchar_t *, const wchar_t *, ...);
+ * intptr_t _wspawnle (int, const wchar_t *, const wchar_t *, ...);
+ * intptr_t _wspawnlp (int, const wchar_t *, const wchar_t *, ...);
+ * intptr_t _wspawnlpe (int, const wchar_t *, const wchar_t *, ...);
+ *
+ * intptr_t _wspawnv (int, const wchar_t *, const wchar_t * const *);
+ * intptr_t _wspawnve (
+ * int, const wchar_t *, const wchar_t * const *, const wchar_t * const *
+ * );
+ * intptr_t _wspawnvp (int, const wchar_t *, const wchar_t * const *);
+ * intptr_t _wspawnvpe (
+ * int, const wchar_t *, const wchar_t * const *, const wchar_t * const *
+ * );
+ *
+ */
+#endif /* !__STRICT_ANSI__ */
-#ifndef _FILE_DEFINED /* Also in stdio.h */
-#define _FILE_DEFINED
-typedef struct _iobuf
-{
- char* _ptr;
- int _cnt;
- char* _base;
- int _flag;
- int _file;
- int _charbuf;
- int _bufsiz;
- char* _tmpfname;
-} FILE;
-#endif /* Not _FILE_DEFINED */
-
-#ifndef _TIME_T_DEFINED /* Also in time.h */
-typedef long time_t;
-#define _TIME_T_DEFINED
-#endif
+_BEGIN_C_DECLS
-#ifndef _TM_DEFINED /* Also in time.h */
-struct tm {
- int tm_sec; /* seconds after the minute - [0,59] */
- int tm_min; /* minutes after the hour - [0,59] */
- int tm_hour; /* hours since midnight - [0,23] */
- int tm_mday; /* day of the month - [1,31] */
- int tm_mon; /* months since January - [0,11] */
- int tm_year; /* years since 1900 */
- int tm_wday; /* days since Sunday - [0,6] */
- int tm_yday; /* days since January 1 - [0,365] */
- int tm_isdst; /* daylight savings time flag */
- };
-#define _TM_DEFINED
-#endif
+/* Wide character string functions must be specified here, as required
+ * by the ISO-C Standard; however, MSVC contravenes this standard by also
+ * requiring them to appear in <string.h>. We declare them here, where
+ * they rightfully belong, but we also arrange for them to be available
+ * for selective inclusion by <string.h>; to facilitate this, we must
+ * change the declarative condition...
+ */
+#endif /* ! RC_INVOKED */
+#endif /* !__STRING_H_SOURCED__ */
+#if ! defined RC_INVOKED
+#if !(defined _WCHAR_H && (defined _STRING_H && ! defined __STRICT_ANSI__))
+/* ...such that these declarations are exposed when either _WCHAR_H is defined,
+ * or when _STRING_H is defined and __STRICT_ANSI__ is not, but NOT when BOTH of
+ * these apply, since that indicates that this group of declarations has already
+ * been processed, during partial inclusion of <wchar.h> by <string.h>, whereas
+ * we are now including <wchar.h> in its own right.
+ *
+ *
+ * Wide character versions of the ISO-C standard string functions.
+ */
+_CRTIMP __cdecl __MINGW_NOTHROW wchar_t *wcscat (wchar_t *, const wchar_t *);
+_CRTIMP __cdecl __MINGW_NOTHROW wchar_t *wcschr (const wchar_t *, wchar_t);
+_CRTIMP __cdecl __MINGW_NOTHROW int wcscmp (const wchar_t *, const wchar_t *);
+_CRTIMP __cdecl __MINGW_NOTHROW int wcscoll (const wchar_t *, const wchar_t *);
+_CRTIMP __cdecl __MINGW_NOTHROW wchar_t *wcscpy (wchar_t *, const wchar_t *);
+_CRTIMP __cdecl __MINGW_NOTHROW size_t wcscspn (const wchar_t *, const wchar_t *);
+_CRTIMP __cdecl __MINGW_NOTHROW size_t wcslen (const wchar_t *);
+_CRTIMP __cdecl __MINGW_NOTHROW wchar_t *wcsncat (wchar_t *, const wchar_t *, size_t);
+_CRTIMP __cdecl __MINGW_NOTHROW int wcsncmp (const wchar_t *, const wchar_t *, size_t);
+_CRTIMP __cdecl __MINGW_NOTHROW wchar_t *wcsncpy (wchar_t *, const wchar_t *, size_t);
+_CRTIMP __cdecl __MINGW_NOTHROW wchar_t *wcspbrk (const wchar_t *, const wchar_t *);
+_CRTIMP __cdecl __MINGW_NOTHROW wchar_t *wcsrchr (const wchar_t *, wchar_t);
+_CRTIMP __cdecl __MINGW_NOTHROW size_t wcsspn (const wchar_t *, const wchar_t *);
+_CRTIMP __cdecl __MINGW_NOTHROW wchar_t *wcsstr (const wchar_t *, const wchar_t *);
+_CRTIMP __cdecl __MINGW_NOTHROW wchar_t *wcstok (wchar_t *, const wchar_t *);
+_CRTIMP __cdecl __MINGW_NOTHROW size_t wcsxfrm (wchar_t *, const wchar_t *, size_t);
-#ifndef _WSTDIO_DEFINED
-/* Also in stdio.h - keep in sync */
-_CRTIMP int __cdecl __MINGW_NOTHROW fwprintf (FILE*, const wchar_t*, ...);
-_CRTIMP int __cdecl __MINGW_NOTHROW wprintf (const wchar_t*, ...);
-_CRTIMP int __cdecl __MINGW_NOTHROW _snwprintf (wchar_t*, size_t, const wchar_t*, ...);
-_CRTIMP int __cdecl __MINGW_NOTHROW vfwprintf (FILE*, const wchar_t*, __VALIST);
-_CRTIMP int __cdecl __MINGW_NOTHROW vwprintf (const wchar_t*, __VALIST);
-_CRTIMP int __cdecl __MINGW_NOTHROW _vsnwprintf (wchar_t*, size_t, const wchar_t*, __VALIST);
-_CRTIMP int __cdecl __MINGW_NOTHROW fwscanf (FILE*, const wchar_t*, ...);
-_CRTIMP int __cdecl __MINGW_NOTHROW wscanf (const wchar_t*, ...);
-_CRTIMP int __cdecl __MINGW_NOTHROW swscanf (const wchar_t*, const wchar_t*, ...);
-_CRTIMP wint_t __cdecl __MINGW_NOTHROW fgetwc (FILE*);
-_CRTIMP wint_t __cdecl __MINGW_NOTHROW fputwc (wchar_t, FILE*);
-_CRTIMP wint_t __cdecl __MINGW_NOTHROW ungetwc (wchar_t, FILE*);
-
-/* These differ from the ISO C prototypes, which have a maxlen parameter like snprintf. */
#ifndef __STRICT_ANSI__
-_CRTIMP int __cdecl __MINGW_NOTHROW swprintf (wchar_t*, const wchar_t*, ...);
-_CRTIMP int __cdecl __MINGW_NOTHROW vswprintf (wchar_t*, const wchar_t*, __VALIST);
-#endif
+/* UTF-16LE versions of non-ANSI string functions provided by CRTDLL.DLL
+ */
+_CRTIMP __cdecl __MINGW_NOTHROW wchar_t *_wcsdup (const wchar_t *);
+_CRTIMP __cdecl __MINGW_NOTHROW int _wcsicmp (const wchar_t *, const wchar_t *);
+_CRTIMP __cdecl __MINGW_NOTHROW int _wcsicoll (const wchar_t *, const wchar_t *);
+_CRTIMP __cdecl __MINGW_NOTHROW wchar_t *_wcslwr (wchar_t*);
+_CRTIMP __cdecl __MINGW_NOTHROW int _wcsnicmp (const wchar_t *, const wchar_t *, size_t);
+_CRTIMP __cdecl __MINGW_NOTHROW wchar_t *_wcsnset (wchar_t *, wchar_t, size_t);
+_CRTIMP __cdecl __MINGW_NOTHROW wchar_t *_wcsrev (wchar_t *);
+_CRTIMP __cdecl __MINGW_NOTHROW wchar_t *_wcsset (wchar_t *, wchar_t);
+_CRTIMP __cdecl __MINGW_NOTHROW wchar_t *_wcsupr (wchar_t *);
#ifdef __MSVCRT__
-_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW fgetws (wchar_t*, int, FILE*);
-_CRTIMP int __cdecl __MINGW_NOTHROW fputws (const wchar_t*, FILE*);
-_CRTIMP wint_t __cdecl __MINGW_NOTHROW getwc (FILE*);
-_CRTIMP wint_t __cdecl __MINGW_NOTHROW getwchar (void);
-_CRTIMP wint_t __cdecl __MINGW_NOTHROW putwc (wint_t, FILE*);
-_CRTIMP wint_t __cdecl __MINGW_NOTHROW putwchar (wint_t);
-#ifndef __STRICT_ANSI__
-_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _getws (wchar_t*);
-_CRTIMP int __cdecl __MINGW_NOTHROW _putws (const wchar_t*);
-_CRTIMP FILE* __cdecl __MINGW_NOTHROW _wfdopen(int, const wchar_t *);
-_CRTIMP FILE* __cdecl __MINGW_NOTHROW _wfopen (const wchar_t*, const wchar_t*);
-_CRTIMP FILE* __cdecl __MINGW_NOTHROW _wfreopen (const wchar_t*, const wchar_t*, FILE*);
-_CRTIMP FILE* __cdecl __MINGW_NOTHROW _wfsopen (const wchar_t*, const wchar_t*, int);
-_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wtmpnam (wchar_t*);
-_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wtempnam (const wchar_t*, const wchar_t*);
-_CRTIMP int __cdecl __MINGW_NOTHROW _wrename (const wchar_t*, const wchar_t*);
-_CRTIMP int __cdecl __MINGW_NOTHROW _wremove (const wchar_t*);
-_CRTIMP void __cdecl __MINGW_NOTHROW _wperror (const wchar_t*);
-_CRTIMP FILE* __cdecl __MINGW_NOTHROW _wpopen (const wchar_t*, const wchar_t*);
-#endif /* __STRICT_ANSI__ */
+_CRTIMP __cdecl __MINGW_NOTHROW int _wcsncoll (const wchar_t *, const wchar_t *, size_t);
+_CRTIMP __cdecl __MINGW_NOTHROW int _wcsnicoll (const wchar_t *, const wchar_t *, size_t);
+
+/* A wide character counterpart to the strerror() API was introduced in
+ * MSVCR70.DLL, and subsequently back-ported to MSVCRT.DLL in WinXP.
+ */
+#if __MSVCRT_VERSION__ >= __MSVCR70_DLL || NTDDI_VERSION >= NTDDI_WINXP
+ /*
+ * These are are the wide character counterparts to the strerror()
+ * function itself, and the _strerror() function, respectively.
+ */
+_CRTIMP __cdecl __MINGW_NOTHROW wchar_t *_wcserror (int);
+_CRTIMP __cdecl __MINGW_NOTHROW wchar_t *__wcserror (const wchar_t *);
+
+#endif /* MSVCR70.DLL || WinXP */
#endif /* __MSVCRT__ */
-#ifndef __NO_ISOCEXT /* externs in libmingwex.a */
-int __cdecl __MINGW_NOTHROW snwprintf (wchar_t*, size_t, const wchar_t*, ...);
-int __cdecl __MINGW_NOTHROW vsnwprintf (wchar_t*, size_t, const wchar_t*, __VALIST);
+/* MSVCRT.DLL provides neither _wcscmpi() nor wcscmpi(); the heritage
+ * is uncertain, but for the convenience, (and portability), of legacy
+ * applications which assume wcscmpi() should be available:
+ */
+#define _wcscmpi _wcsicmp
+int __cdecl __MINGW_NOTHROW wcscmpi (const wchar_t *, const wchar_t *);
+
#ifndef __NO_INLINE__
-__CRT_INLINE int __cdecl __MINGW_NOTHROW
-vsnwprintf (wchar_t* s, size_t n, const wchar_t* format, __VALIST arg)
- { return _vsnwprintf ( s, n, format, arg);}
-#endif
-int __cdecl __MINGW_NOTHROW vwscanf (const wchar_t * __restrict__, __VALIST);
-int __cdecl __MINGW_NOTHROW vfwscanf (FILE * __restrict__,
- const wchar_t * __restrict__, __VALIST);
-int __cdecl __MINGW_NOTHROW vswscanf (const wchar_t * __restrict__,
- const wchar_t * __restrict__, __VALIST);
+__CRT_ALIAS __JMPSTUB__(( FUNCTION = wcscmpi, REMAPPED = _wcsicmp ))
+ int wcscmpi (const wchar_t *__ws1, const wchar_t *__ws2)
+ { return _wcsicmp (__ws1, __ws2); }
+#endif /* __NO_INLINE__ */
+
+#ifndef _NO_OLDNAMES
+/* Older CRTDLL.DLL versions may have provided these alternatively named
+ * functions; we continue to support them, via the OLDNAME libraries:
+ */
+_CRTIMP __cdecl __MINGW_NOTHROW wchar_t *wcsdup (const wchar_t *);
+_CRTIMP __cdecl __MINGW_NOTHROW int wcsicmp (const wchar_t *, const wchar_t *);
+_CRTIMP __cdecl __MINGW_NOTHROW int wcsicoll (const wchar_t *, const wchar_t *);
+_CRTIMP __cdecl __MINGW_NOTHROW wchar_t *wcslwr (wchar_t *);
+_CRTIMP __cdecl __MINGW_NOTHROW int wcsnicmp (const wchar_t *, const wchar_t *, size_t);
+_CRTIMP __cdecl __MINGW_NOTHROW wchar_t *wcsnset (wchar_t *, wchar_t, size_t);
+_CRTIMP __cdecl __MINGW_NOTHROW wchar_t *wcsrev (wchar_t *);
+_CRTIMP __cdecl __MINGW_NOTHROW wchar_t *wcsset (wchar_t *, wchar_t);
+_CRTIMP __cdecl __MINGW_NOTHROW wchar_t *wcsupr (wchar_t *);
+
+#endif /* !_NO_OLDNAMES */
+#endif /* !__STRICT_ANSI__ */
+
+#if _POSIX_C_SOURCE >= 200809L
+#if __MSVCRT_VERSION__ >= __MSVCR80_DLL
+/* MSVCR80.DLL adds a (mostly) POSIX.1-2008 conforming wcsnlen(); (it's
+ * also available in MSVCRT.DLL from _WIN32_WINNT_VISTA onwards, but we
+ * pretend otherwise, since recent GCC will try to use the function when
+ * it can be found in libmsvcrt.a, so breaking it for use on WinXP and
+ * earlier).
+ */
+#ifndef __STRICT_ANSI__ /* N.B.: this is not an ISO-C function */
+_CRTIMP __cdecl __MINGW_NOTHROW char *wcsnlen (const wchar_t *, size_t);
#endif
-#define _WSTDIO_DEFINED
-#endif /* _WSTDIO_DEFINED */
-
-#ifndef _WSTDLIB_DEFINED /* also declared in stdlib.h */
-_CRTIMP long __cdecl __MINGW_NOTHROW wcstol (const wchar_t*, wchar_t**, int);
-_CRTIMP unsigned long __cdecl __MINGW_NOTHROW wcstoul (const wchar_t*, wchar_t**, int);
-_CRTIMP double __cdecl __MINGW_NOTHROW wcstod (const wchar_t*, wchar_t**);
-#if !defined __NO_ISOCEXT /* in libmingwex.a */
-float __cdecl __MINGW_NOTHROW wcstof (const wchar_t * __restrict__, wchar_t ** __restrict__);
-long double __cdecl __MINGW_NOTHROW wcstold (const wchar_t * __restrict__, wchar_t ** __restrict__);
-#endif /* __NO_ISOCEXT */
-#ifdef __MSVCRT__
-_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wgetenv(const wchar_t*);
-_CRTIMP int __cdecl __MINGW_NOTHROW _wputenv(const wchar_t*);
-_CRTIMP void __cdecl __MINGW_NOTHROW _wsearchenv(const wchar_t*, const wchar_t*, wchar_t*);
-_CRTIMP int __cdecl __MINGW_NOTHROW _wsystem(const wchar_t*);
-_CRTIMP void __cdecl __MINGW_NOTHROW _wmakepath(wchar_t*, const wchar_t*, const wchar_t*, const wchar_t*, const wchar_t*);
-_CRTIMP void __cdecl __MINGW_NOTHROW _wsplitpath (const wchar_t*, wchar_t*, wchar_t*, wchar_t*, wchar_t*);
-_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wfullpath (wchar_t*, const wchar_t*, size_t);
-#endif
-#define _WSTDLIB_DEFINED
-#endif /* _WSTDLIB_DEFINED */
+#else /* MSVCRT.DLL || pre-MSVCR80.DLL */
+/* Emulation, to support recent POSIX.1; we prefer this for ALL versions
+ * of MSVCRT.DLL, (even those which already provide wcsnlen()); to avoid
+ * the GCC breakage noted above. (Note that we implement wcsnlen() with
+ * the alternative external name, __mingw_wcsnlen() in libmingwex.a, to
+ * avoid possible link time collision with MSVCR80.DLL's implementation,
+ * then map this to wcsnlen() via a __CRT_ALIAS, with stubs designated
+ * for linking from within the appropriate oldname libraries.
+ */
+extern size_t __mingw_wcsnlen (const wchar_t *, size_t);
+
+__JMPSTUB__(( LIB=coldname; FUNCTION=wcsnlen ))
+__CRT_ALIAS size_t wcsnlen (const wchar_t *__text, size_t __maxlen)
+{ return __mingw_wcsnlen (__text, __maxlen); }
+
+#endif /* MSVCRT.DLL || pre-MSVCR80.DLL */
+#endif /* _POSIX_C_SOURCE >= 200809L */
+
+/* This completes the set of declarations which are to be duplicated by
+ * inclusion of <string.h>; revert the declarative condition, to make it
+ * specific to <wchar.h> alone.
+ */
+#endif /* !(_WCHAR_H && (_STRING_H && !__STRICT_ANSI__)) */
+#endif /* ! RC_INVOKED */
-#ifndef _WTIME_DEFINED
+#if defined _WCHAR_H && ! defined RC_INVOKED
#ifndef __STRICT_ANSI__
-#ifdef __MSVCRT__
-/* wide function prototypes, also declared in time.h */
-_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wasctime (const struct tm*);
-#if __MSVCRT_VERSION__ < 0x0800
-_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wctime (const time_t*);
-#endif
-_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wstrdate (wchar_t*);
-_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wstrtime (wchar_t*);
-#if __MSVCRT_VERSION__ >= 0x601
-_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wctime64 (const __time64_t*);
-#endif
-#if __MSVCRT_VERSION__ >= 0x0800
-_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wctime32 (const __time32_t*);
-#ifndef _USE_32BIT_TIME_T
-_CRTALIAS wchar_t* __cdecl __MINGW_NOTHROW _wctime (const time_t* _v) { return(_wctime64 (_v)); }
-#else
-_CRTALIAS wchar_t* __cdecl __MINGW_NOTHROW _wctime (const time_t* _v) { return(_wctime32 (_v)); }
-#endif
+typedef wchar_t _Wint_t;
#endif
-#endif /* __MSVCRT__ */
-#endif /* __STRICT_ANSI__ */
-_CRTIMP size_t __cdecl __MINGW_NOTHROW wcsftime (wchar_t*, size_t, const wchar_t*, const struct tm*);
-#define _WTIME_DEFINED
-#endif /* _WTIME_DEFINED */
+typedef int mbstate_t;
+/* The following multi-byte character conversion functions have been
+ * implemented by Microsoft, in non-free MSVCR80.DLL and later, (and
+ * maybe also in some earlier non-free DLLs, such as MSVCP60.DLL and
+ * later); they are also available in MSVCRT.DLL, from Vista onward,
+ * but to provide continuing support for earlier Windows versions,
+ * we invoke them via MinGW specific wrappers, defined below.
+ */
+__cdecl __MINGW_NOTHROW wint_t btowc (int);
+__cdecl __MINGW_NOTHROW int wctob (wint_t);
-#ifndef _WSTRING_DEFINED
-/*
- * Unicode versions of the standard string calls.
- * Also in string.h.
- */
-_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW wcscat (wchar_t*, const wchar_t*);
-_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW wcschr (const wchar_t*, wchar_t);
-_CRTIMP int __cdecl __MINGW_NOTHROW wcscmp (const wchar_t*, const wchar_t*);
-_CRTIMP int __cdecl __MINGW_NOTHROW wcscoll (const wchar_t*, const wchar_t*);
-_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW wcscpy (wchar_t*, const wchar_t*);
-_CRTIMP size_t __cdecl __MINGW_NOTHROW wcscspn (const wchar_t*, const wchar_t*);
-/* Note: _wcserror requires __MSVCRT_VERSION__ >= 0x0700. */
-_CRTIMP size_t __cdecl __MINGW_NOTHROW wcslen (const wchar_t*);
-_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW wcsncat (wchar_t*, const wchar_t*, size_t);
-_CRTIMP int __cdecl __MINGW_NOTHROW wcsncmp(const wchar_t*, const wchar_t*, size_t);
-_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW wcsncpy(wchar_t*, const wchar_t*, size_t);
-_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW wcspbrk(const wchar_t*, const wchar_t*);
-_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW wcsrchr(const wchar_t*, wchar_t);
-_CRTIMP size_t __cdecl __MINGW_NOTHROW wcsspn(const wchar_t*, const wchar_t*);
-_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW wcsstr(const wchar_t*, const wchar_t*);
-_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW wcstok(wchar_t*, const wchar_t*);
-_CRTIMP size_t __cdecl __MINGW_NOTHROW wcsxfrm(wchar_t*, const wchar_t*, size_t);
-
-#ifndef __STRICT_ANSI__
-/*
- * Unicode versions of non-ANSI functions provided by CRTDLL.
+__cdecl __MINGW_NOTHROW size_t mbrlen
+(const char *__restrict__, size_t, mbstate_t *__restrict__);
+
+__cdecl __MINGW_NOTHROW size_t mbrtowc
+(wchar_t *__restrict__, const char *__restrict__, size_t, mbstate_t *__restrict__);
+
+__cdecl __MINGW_NOTHROW size_t mbsrtowcs
+(wchar_t *__restrict__, const char **__restrict__, size_t, mbstate_t *__restrict__);
+
+__cdecl __MINGW_NOTHROW size_t wcrtomb
+(char * __restrict__, wchar_t, mbstate_t *__restrict__);
+
+__cdecl __MINGW_NOTHROW size_t wcsrtombs
+(char *__restrict__, const wchar_t **__restrict__, size_t, mbstate_t *__restrict__);
+
+/* To provide support for the above, on legacy Windows versions,
+ * we implement fall back wrappers in libmingwex.a; each of these
+ * will delegate to the corresponding Microsoft implementation, if
+ * it exists in the process address space; otherwise, execution
+ * will fall back to a MinGW implementation...
*/
+__cdecl __MINGW_NOTHROW wint_t __msvcrt_btowc (int);
-/* NOTE: _wcscmpi not provided by CRTDLL, this define is for portability */
-#define _wcscmpi _wcsicmp
+__cdecl __MINGW_NOTHROW size_t __msvcrt_mbrlen
+(const char *__restrict__, size_t, mbstate_t *__restrict__);
-_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wcsdup (const wchar_t*);
-_CRTIMP int __cdecl __MINGW_NOTHROW _wcsicmp (const wchar_t*, const wchar_t*);
-_CRTIMP int __cdecl __MINGW_NOTHROW _wcsicoll (const wchar_t*, const wchar_t*);
-_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wcslwr (wchar_t*);
-_CRTIMP int __cdecl __MINGW_NOTHROW _wcsnicmp (const wchar_t*, const wchar_t*, size_t);
-_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wcsnset (wchar_t*, wchar_t, size_t);
-_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wcsrev (wchar_t*);
-_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wcsset (wchar_t*, wchar_t);
-_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wcsupr (wchar_t*);
+__cdecl __MINGW_NOTHROW size_t __msvcrt_mbrtowc
+(wchar_t *__restrict__, const char *__restrict__, size_t, mbstate_t *__restrict__);
-#ifdef __MSVCRT__
-_CRTIMP int __cdecl __MINGW_NOTHROW _wcsncoll(const wchar_t*, const wchar_t*, size_t);
-_CRTIMP int __cdecl __MINGW_NOTHROW _wcsnicoll(const wchar_t*, const wchar_t*, size_t);
-#if __MSVCRT_VERSION__ >= 0x0700
-_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wcserror(int);
-_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW __wcserror(const wchar_t*);
-#endif
-#endif
+__cdecl __MINGW_NOTHROW size_t __msvcrt_mbsrtowcs
+(wchar_t *__restrict__, const char **__restrict__, size_t, mbstate_t *__restrict__);
-#ifndef _NO_OLDNAMES
-/* NOTE: There is no _wcscmpi, but this is for compatibility. */
-int __cdecl __MINGW_NOTHROW wcscmpi (const wchar_t *, const wchar_t *);
-#ifndef __NO_INLINE__
-__CRT_INLINE int __cdecl __MINGW_NOTHROW
-wcscmpi (const wchar_t * __ws1, const wchar_t * __ws2)
- {return _wcsicmp (__ws1, __ws2);}
-#endif
-_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW wcsdup (const wchar_t*);
-_CRTIMP int __cdecl __MINGW_NOTHROW wcsicmp (const wchar_t*, const wchar_t*);
-_CRTIMP int __cdecl __MINGW_NOTHROW wcsicoll (const wchar_t*, const wchar_t*);
-_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW wcslwr (wchar_t*);
-_CRTIMP int __cdecl __MINGW_NOTHROW wcsnicmp (const wchar_t*, const wchar_t*, size_t);
-_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW wcsnset (wchar_t*, wchar_t, size_t);
-_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW wcsrev (wchar_t*);
-_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW wcsset (wchar_t*, wchar_t);
-_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW wcsupr (wchar_t*);
-#endif /* Not _NO_OLDNAMES */
-
-#endif /* Not strict ANSI */
-
-#define _WSTRING_DEFINED
-#endif /* _WSTRING_DEFINED */
-
-/* These are resolved by -lmingwex. Alternatively, they can be resolved by
- adding -lmsvcp60 to your command line, which will give you the VC++
- versions of these functions. If you want the latter and don't have
- msvcp60.dll in your windows system directory, you can easily obtain
- it with a search from your favorite search engine. */
-#ifndef __STRICT_ANSI__
-typedef wchar_t _Wint_t;
-#endif
+__cdecl __MINGW_NOTHROW int __msvcrt_wctob (wint_t);
-typedef int mbstate_t;
+__cdecl __MINGW_NOTHROW size_t __msvcrt_wcrtomb
+(char * __restrict__, wchar_t, mbstate_t *__restrict__);
+
+__cdecl __MINGW_NOTHROW size_t __msvcrt_wcsrtombs
+(char *__restrict__, const wchar_t **__restrict__, size_t, mbstate_t *__restrict__);
+
+/* ...whereas, these alternatives will always invoke the MinGW
+ * fall back implementations, without considering any possible
+ * reference to MSVCRT.DLL or MSVCR80.DLL implementations.
+ */
+__cdecl __MINGW_NOTHROW wint_t __mingw_btowc (int);
+
+__cdecl __MINGW_NOTHROW size_t __mingw_mbrlen
+(const char *__restrict__, size_t, mbstate_t *__restrict__);
+
+__cdecl __MINGW_NOTHROW size_t __mingw_mbrtowc
+(wchar_t *__restrict__, const char *__restrict__, size_t, mbstate_t *__restrict__);
+
+__cdecl __MINGW_NOTHROW size_t __mingw_mbsrtowcs
+(wchar_t *__restrict__, const char **__restrict__, size_t, mbstate_t *__restrict__);
+
+__cdecl __MINGW_NOTHROW int __mingw_wctob (wint_t);
+
+__cdecl __MINGW_NOTHROW size_t __mingw_wcrtomb
+(char * __restrict__, wchar_t, mbstate_t *__restrict__);
+
+__cdecl __MINGW_NOTHROW size_t __mingw_wcsrtombs
+(char *__restrict__, const wchar_t **__restrict__, size_t, mbstate_t *__restrict__);
+
+#if __MSVCRT_VERSION__ < __MSVCR80_DLL
+/* FIXME: Maybe consider these mappings, even for linking with the
+ * non-free MSVCR80.DLL, and its descendants.
+ *
+ * For linking with all versions of MSVCRT.DLL, and with non-free
+ * alternatives predating MSVCR80.DLL, we enforce inline mapping to
+ * the libmingwex.a implementations, (which will delegate the calls
+ * to the Microsoft DLL implementations, when they are available).
+ */
+__CRT_ALIAS __cdecl __MINGW_NOTHROW wint_t btowc (int __c)
+{ return __msvcrt_btowc( __c ); }
+
+__CRT_ALIAS __cdecl __MINGW_NOTHROW size_t mbrlen
+(const char *__mbc, size_t __n, mbstate_t *__ps)
+{ return __msvcrt_mbrlen( __mbc, __n, __ps ); }
+
+__CRT_ALIAS __cdecl __MINGW_NOTHROW size_t mbrtowc
+(wchar_t *__wc, const char *__mbc, size_t __n, mbstate_t *__ps)
+{ return __msvcrt_mbrtowc( __wc, __mbc, __n, __ps ); }
+
+__CRT_ALIAS __cdecl __MINGW_NOTHROW size_t mbsrtowcs
+(wchar_t *__wcs, const char **__mbs, size_t __n, mbstate_t *__ps)
+{ return __msvcrt_mbsrtowcs( __wcs, __mbs, __n, __ps ); }
+
+__CRT_ALIAS __cdecl __MINGW_NOTHROW int wctob (wint_t __wc)
+{ return __msvcrt_wctob( __wc ); }
+
+__CRT_ALIAS __cdecl __MINGW_NOTHROW size_t wcrtomb
+(char * __mbc, wchar_t __wc, mbstate_t *__ps)
+{ return __msvcrt_wcrtomb(__mbc, __wc, __ps); }
+
+__CRT_ALIAS __cdecl __MINGW_NOTHROW size_t wcsrtombs
+(char *__mbs, const wchar_t **__wcs, size_t __len, mbstate_t *__ps)
+{ return __msvcrt_wcsrtombs(__mbs, __wcs, __len, __ps); }
+
+#endif /* ! MSVCR80.DLL or later */
+
+#if defined _ISOC99_SOURCE || defined __cplusplus
+/* These ISO-C99 functions are implemented in libmingwex.a,
+ * or, in some cases, as inline stubs; while provided as MinGW
+ * extensions to support ISO-C99, they are also required by
+ * GNU C++.
+ */
+__cdecl __MINGW_NOTHROW int fwide (FILE *, int);
+__cdecl __MINGW_NOTHROW int mbsinit (const mbstate_t *);
-wint_t __cdecl __MINGW_NOTHROW btowc(int);
-size_t __cdecl __MINGW_NOTHROW mbrlen(const char * __restrict__, size_t,
- mbstate_t * __restrict__);
-size_t __cdecl __MINGW_NOTHROW mbrtowc(wchar_t * __restrict__, const char * __restrict__,
- size_t, mbstate_t * __restrict__);
-size_t __cdecl __MINGW_NOTHROW mbsrtowcs(wchar_t * __restrict__, const char ** __restrict__,
- size_t, mbstate_t * __restrict__);
-size_t __cdecl __MINGW_NOTHROW wcrtomb(char * __restrict__, wchar_t,
- mbstate_t * __restrict__);
-size_t __cdecl __MINGW_NOTHROW wcsrtombs(char * __restrict__, const wchar_t ** __restrict__,
- size_t, mbstate_t * __restrict__);
-int __cdecl __MINGW_NOTHROW wctob(wint_t);
-
-#ifndef __NO_ISOCEXT /* these need static lib libmingwex.a */
-int __cdecl __MINGW_NOTHROW fwide(FILE*, int);
-int __cdecl __MINGW_NOTHROW mbsinit(const mbstate_t*);
#ifndef __NO_INLINE__
-__CRT_INLINE int __cdecl __MINGW_NOTHROW fwide(FILE* __UNUSED_PARAM(stream),
- int mode)
- {return mode;} /* Nothing to do */
-__CRT_INLINE int __cdecl __MINGW_NOTHROW mbsinit(const mbstate_t* __UNUSED_PARAM(ps))
- {return 1;}
-#endif
-wchar_t* __cdecl __MINGW_NOTHROW wmemset(wchar_t *, wchar_t, size_t);
-wchar_t* __cdecl __MINGW_NOTHROW wmemchr(const wchar_t*, wchar_t, size_t);
-int wmemcmp(const wchar_t*, const wchar_t *, size_t);
-wchar_t* __cdecl __MINGW_NOTHROW wmemcpy(wchar_t* __restrict__,
- const wchar_t* __restrict__,
- size_t);
-wchar_t* __cdecl __MINGW_NOTHROW wmemmove(wchar_t* s1, const wchar_t *, size_t);
-long long __cdecl __MINGW_NOTHROW wcstoll(const wchar_t * __restrict__,
- wchar_t** __restrict__, int);
-unsigned long long __cdecl __MINGW_NOTHROW wcstoull(const wchar_t * __restrict__,
- wchar_t ** __restrict__, int);
-#endif /* __NO_ISOCEXT */
-
-#ifndef __STRICT_ANSI__
-/* non-ANSI wide char functions from io.h, direct.h, sys/stat.h and locale.h. */
-
-#ifndef _FSIZE_T_DEFINED
-typedef unsigned long _fsize_t;
-#define _FSIZE_T_DEFINED
-#endif
+__CRT_INLINE __cdecl __MINGW_NOTHROW
+int fwide (FILE *__UNUSED_PARAM(stream), int mode)
+ { return mode; } /* Nothing to do */
-#ifndef _WFINDDATA_T_DEFINED
-struct _wfinddata_t {
- unsigned attrib;
- time_t time_create; /* -1 for FAT file systems */
- time_t time_access; /* -1 for FAT file systems */
- time_t time_write;
- _fsize_t size;
- wchar_t name[260]; /* may include spaces. */
-};
-struct _wfinddatai64_t {
- unsigned attrib;
- time_t time_create;
- time_t time_access;
- time_t time_write;
- __int64 size;
- wchar_t name[260];
-};
-#if __MSVCRT_VERSION__ >= 0x0601
-struct __wfinddata64_t {
- unsigned attrib;
- __time64_t time_create;
- __time64_t time_access;
- __time64_t time_write;
-/* 8 bytes are returned so it can't be _fsize_t */
- __int64 size;
- wchar_t name[260];
-};
-#endif
-#if __MSVCRT_VERSION__ >= 0x0800
-#include <stdio.h>
-struct __wfinddata32_t {
- unsigned attrib;
- __time32_t time_create;
- __time32_t time_access;
- __time32_t time_write;
- __int32 size;
- wchar_t name[FILENAME_MAX];
-};
-
-struct _wfinddata32i64_t {
- unsigned attrib;
- __time32_t time_create;
- __time32_t time_access;
- __time32_t time_write;
- __int64 size;
- wchar_t name[FILENAME_MAX];
-};
-
-struct _wfinddata64i32_t {
- unsigned attrib;
- __time64_t time_create;
- __time64_t time_access;
- __time64_t time_write;
- __int32 size;
- wchar_t name[FILENAME_MAX];
-};
-#endif /* __MSVCRT_VERSION__ >= 0x0800 */
-#define _WFINDDATA_T_DEFINED
+__CRT_INLINE __cdecl __MINGW_NOTHROW
+int mbsinit (const mbstate_t *__UNUSED_PARAM(ps))
+ { return 1; }
#endif
-/* Wide character versions. Also defined in io.h. */
-/* CHECK: I believe these only exist in MSVCRT, and not in CRTDLL. Also
- applies to other wide character versions? */
-#if !defined (_WIO_DEFINED)
-#if defined (__MSVCRT__)
-#include <stdint.h> /* For intptr_t. */
-_CRTIMP int __cdecl __MINGW_NOTHROW _waccess (const wchar_t*, int);
-_CRTIMP int __cdecl __MINGW_NOTHROW _wchmod (const wchar_t*, int);
-_CRTIMP int __cdecl __MINGW_NOTHROW _wcreat (const wchar_t*, int);
-#if __MSVCRT_VERSION__ < 0x0800
-_CRTIMP long __cdecl __MINGW_NOTHROW _wfindfirst (const wchar_t*, struct _wfinddata_t *);
-_CRTIMP int __cdecl __MINGW_NOTHROW _wfindnext (long, struct _wfinddata_t *);
-#endif
-_CRTIMP int __cdecl __MINGW_NOTHROW _wunlink (const wchar_t*);
-_CRTIMP int __cdecl __MINGW_NOTHROW _wopen (const wchar_t*, int, ...);
-_CRTIMP int __cdecl __MINGW_NOTHROW _wsopen (const wchar_t*, int, int, ...);
-_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wmktemp (wchar_t*);
-#if __MSVCRT_VERSION__ < 0x0800
-_CRTIMP long __cdecl __MINGW_NOTHROW _wfindfirsti64 (const wchar_t*, struct _wfinddatai64_t*);
-_CRTIMP int __cdecl __MINGW_NOTHROW _wfindnexti64 (long, struct _wfinddatai64_t*);
-#else
-_CRTIMP long __cdecl __MINGW_NOTHROW _wfindfirst32i64 (const wchar_t*, struct _wfinddata32i64_t*);
-_CRTIMP long __cdecl __MINGW_NOTHROW _wfindfirst64i32 (const wchar_t*, struct _wfinddata64i32_t*);
-_CRTIMP int __cdecl __MINGW_NOTHROW _wfindnext32i64 (long, struct _wfinddata32i64_t*);
-_CRTIMP int __cdecl __MINGW_NOTHROW _wfindnext64i32 (long, struct _wfinddata64i32_t*);
-#endif /* __MSVCRT_VERSION__ < 0x0800 */
-#if __MSVCRT_VERSION__ >= 0x0601
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _wfindfirst64(const wchar_t*, struct __wfinddata64_t*);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _wfindnext64(intptr_t, struct __wfinddata64_t*);
-#endif /* __MSVCRT_VERSION__ >= 0x0601 */
-#if __MSVCRT_VERSION__ >= 0x0800
-_CRTIMP long __cdecl __MINGW_NOTHROW _wfindfirst32 (const wchar_t*, struct __wfinddata32_t*);
-_CRTIMP int __cdecl __MINGW_NOTHROW _wfindnext32 (long, struct __wfinddata32_t*);
-#ifndef _USE_32BIT_TIME_T
-_CRTALIAS long __cdecl __MINGW_NOTHROW _wfindfirst (const wchar_t* _v1, struct _wfinddata_t* _v2) { return(_wfindfirst64i32 (_v1,(struct _wfinddata64i32_t*)_v2)); }
-_CRTALIAS int __cdecl __MINGW_NOTHROW _wfindnext (long _v1, struct _wfinddata_t* _v2) { return(_wfindnext64i32 (_v1,(struct _wfinddata64i32_t*)_v2)); }
-_CRTALIAS long __cdecl __MINGW_NOTHROW _wfindfirsti64 (const wchar_t* _v1, struct _wfinddatai64_t* _v2) { return(_wfindfirst64 (_v1,(struct __wfinddata64_t*)_v2)); }
-_CRTALIAS int __cdecl __MINGW_NOTHROW _wfindnexti64 (long _v1, struct _wfinddatai64_t* _v2) { return(_wfindnext64 (_v1,(struct __wfinddata64_t*)_v2)); }
-#else
-_CRTALIAS long __cdecl __MINGW_NOTHROW _wfindfirst (const wchar_t* _v1, struct _wfinddata_t* _v2) { return(_wfindfirst32 (_v1,(struct __wfinddata32_t*)_v2)); }
-_CRTALIAS int __cdecl __MINGW_NOTHROW _wfindnext (long _v1, struct _wfinddata_t* _v2) { return(_wfindnext32 (_v1,(struct __wfinddata32_t*)_v2)); }
-_CRTALIAS long __cdecl __MINGW_NOTHROW _wfindfirsti64 (const wchar_t* _v1, struct _wfinddatai64_t* _v2) { return(_wfindfirst32i64 (_v1,(struct _wfinddata32i64_t*)_v2)); }
-_CRTALIAS int __cdecl __MINGW_NOTHROW _wfindnexti64 (long _v1, struct _wfinddatai64_t* _v2) { return(_wfindnext32i64 (_v1,(struct _wfinddata32i64_t*)_v2)); }
-#endif /* !_USE_32BIT_TIME_T*/
-#endif /* __MSVCRT_VERSION__ >= 0x0800 */
-
-#endif /* defined (__MSVCRT__) */
-#define _WIO_DEFINED
-#endif /* _WIO_DEFINED */
-
-#ifndef _WDIRECT_DEFINED
-/* Also in direct.h */
-#ifdef __MSVCRT__
-_CRTIMP int __cdecl __MINGW_NOTHROW _wchdir (const wchar_t*);
-_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wgetcwd (wchar_t*, int);
-_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wgetdcwd (int, wchar_t*, int);
-_CRTIMP int __cdecl __MINGW_NOTHROW _wmkdir (const wchar_t*);
-_CRTIMP int __cdecl __MINGW_NOTHROW _wrmdir (const wchar_t*);
-#endif /* __MSVCRT__ */
-#define _WDIRECT_DEFINED
-#endif /* _WDIRECT_DEFINED */
+__cdecl __MINGW_NOTHROW wchar_t *wmemset (wchar_t *, wchar_t, size_t);
+__cdecl __MINGW_NOTHROW wchar_t *wmemchr (const wchar_t *, wchar_t, size_t);
-#ifndef _STAT_DEFINED
-/*
- * The structure manipulated and returned by stat and fstat.
- *
- * NOTE: If called on a directory the values in the time fields are not only
- * invalid, they will cause localtime et. al. to return NULL. And calling
- * asctime with a NULL pointer causes an Invalid Page Fault. So watch it!
- */
-struct _stat
-{
- _dev_t st_dev; /* Equivalent to drive number 0=A 1=B ... */
- _ino_t st_ino; /* Always zero ? */
- _mode_t st_mode; /* See above constants */
- short st_nlink; /* Number of links. */
- short st_uid; /* User: Maybe significant on NT ? */
- short st_gid; /* Group: Ditto */
- _dev_t st_rdev; /* Seems useless (not even filled in) */
- _off_t st_size; /* File size in bytes */
- time_t st_atime; /* Accessed date (always 00:00 hrs local
- * on FAT) */
- time_t st_mtime; /* Modified time */
- time_t st_ctime; /* Creation time */
-};
-
-#ifndef _NO_OLDNAMES
-/* NOTE: Must be the same as _stat above. */
-struct stat
-{
- dev_t st_dev; /* Equivalent to drive number 0=A 1=B ... */
- ino_t st_ino; /* Always zero ? */
- mode_t st_mode; /* See above constants */
- short st_nlink; /* Number of links. */
- short st_uid; /* User: Maybe significant on NT ? */
- short st_gid; /* Group: Ditto */
- dev_t st_rdev; /* Seems useless (not even filled in) */
- off_t st_size; /* File size in bytes */
- time_t st_atime; /* Accessed date (always 00:00 hrs local
- * on FAT) */
- time_t st_mtime; /* Modified time */
- time_t st_ctime; /* Creation time */
-};
-#endif /* _NO_OLDNAMES */
-
-#if defined (__MSVCRT__)
-struct _stati64 {
- _dev_t st_dev;
- _ino_t st_ino;
- unsigned short st_mode;
- short st_nlink;
- short st_uid;
- short st_gid;
- _dev_t st_rdev;
- __int64 st_size;
- time_t st_atime;
- time_t st_mtime;
- time_t st_ctime;
-};
-
-#if __MSVCRT_VERSION__ >= 0x0601
-struct __stat64
-{
- _dev_t st_dev;
- _ino_t st_ino;
- _mode_t st_mode;
- short st_nlink;
- short st_uid;
- short st_gid;
- _dev_t st_rdev;
- __int64 st_size;
- __time64_t st_atime;
- __time64_t st_mtime;
- __time64_t st_ctime;
-};
-#endif /* __MSVCRT_VERSION__ >= 0x0601*/
-
-#if __MSVCRT_VERSION__ >= 0x0800
-struct __stat32
-{
- _dev_t st_dev;
- _ino_t st_ino;
- _mode_t st_mode;
- short st_nlink;
- short st_uid;
- short st_gid;
- _dev_t st_rdev;
- __int32 st_size;
- __time32_t st_atime;
- __time32_t st_mtime;
- __time32_t st_ctime;
-};
-struct _stat32i64 {
- _dev_t st_dev;
- _ino_t st_ino;
- _mode_t st_mode;
- short st_nlink;
- short st_uid;
- short st_gid;
- _dev_t st_rdev;
- __int64 st_size;
- __time32_t st_atime;
- __time32_t st_mtime;
- __time32_t st_ctime;
-};
-struct _stat64i32 {
- _dev_t st_dev;
- _ino_t st_ino;
- _mode_t st_mode;
- short st_nlink;
- short st_uid;
- short st_gid;
- _dev_t st_rdev;
- __int32 st_size;
- __time64_t st_atime;
- __time64_t st_mtime;
- __time64_t st_ctime;
-};
-#endif /* __MSVCRT_VERSION__ >= 0x0800 */
-
-#endif /* __MSVCRT__ */
-#define _STAT_DEFINED
-#endif /* _STAT_DEFINED */
-
-#if !defined ( _WSTAT_DEFINED)
-/* also declared in sys/stat.h */
-#if defined __MSVCRT__
-#if __MSVCRT_VERSION__ < 0x0800
-_CRTIMP int __cdecl __MINGW_NOTHROW _wstat (const wchar_t*, struct _stat*);
-_CRTIMP int __cdecl __MINGW_NOTHROW _wstati64 (const wchar_t*, struct _stati64*);
-#endif /* __MSVCRT_VERSION__ < 0x0800 */
-#if __MSVCRT_VERSION__ >= 0x0601
-_CRTIMP int __cdecl __MINGW_NOTHROW _wstat64 (const wchar_t*, struct __stat64*);
-#endif /* __MSVCRT_VERSION__ >= 0x0601 */
-#if __MSVCRT_VERSION__ >= 0x0800
-_CRTIMP int __cdecl __MINGW_NOTHROW _wstat32 (const wchar_t*, struct __stat32*);
-_CRTIMP int __cdecl __MINGW_NOTHROW _wstat32i64 (const wchar_t*, struct _stat32i64*);
-_CRTIMP int __cdecl __MINGW_NOTHROW _wstat64i32 (const wchar_t*, struct _stat64i32*);
-#ifndef _USE_32BIT_TIME_T
-_CRTALIAS int __cdecl __MINGW_NOTHROW _wstat (const wchar_t* _v1, struct _stat* _v2) { return(_wstat64i32 (_v1,(struct _stat64i32*)_v2)); }
-_CRTALIAS int __cdecl __MINGW_NOTHROW _wstati64 (const wchar_t* _v1, struct _stati64* _v2) { return(_wstat64 (_v1,(struct __stat64*)_v2)); }
-#else
-_CRTALIAS int __cdecl __MINGW_NOTHROW _wstat (const wchar_t* _v1, struct _stat* _v2) { return(_wstat32 (_v1,(struct __stat32*)_v2)); }
-_CRTALIAS int __cdecl __MINGW_NOTHROW _wstati64 (const wchar_t* _v1, struct _stati64* _v2) { return(_wstat32i64 (_v1,(struct _stat32i64*)_v2)); }
-#endif /* !_USE_32BIT_TIME_T */
-#endif /* __MSVCRT_VERSION__ >= 0x0800 */
-#endif /* __MSVCRT__ */
-#define _WSTAT_DEFINED
-#endif /* ! _WSTAT_DEFIND */
-
-#ifndef _WLOCALE_DEFINED /* also declared in locale.h */
-_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wsetlocale (int, const wchar_t*);
-#define _WLOCALE_DEFINED
-#endif
+/* FIXME: what makes this so different from every other function
+ * in this group? Why is it not qualified with the __cdecl, and
+ * __MINGW_NOTHROW attributes?
+ */
+int wmemcmp (const wchar_t *, const wchar_t *, size_t);
-#ifndef _WPROCESS_DEFINED /* also declared in process.h */
-#include <stdint.h> /* For intptr_t. */
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _wexecl (const wchar_t*, const wchar_t*, ...);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _wexecle (const wchar_t*, const wchar_t*, ...);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _wexeclp (const wchar_t*, const wchar_t*, ...);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _wexeclpe (const wchar_t*, const wchar_t*, ...);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _wexecv (const wchar_t*, const wchar_t* const*);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _wexecve (const wchar_t*, const wchar_t* const*, const wchar_t* const*);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _wexecvp (const wchar_t*, const wchar_t* const*);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _wexecvpe (const wchar_t*, const wchar_t* const*, const wchar_t* const*);
-
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _wspawnl (int, const wchar_t*, const wchar_t*, ...);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _wspawnle (int, const wchar_t*, const wchar_t*, ...);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _wspawnlp (int, const wchar_t*, const wchar_t*, ...);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _wspawnlpe (int, const wchar_t*, const wchar_t*, ...);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _wspawnv (int, const wchar_t*, const wchar_t* const*);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _wspawnve (int, const wchar_t*, const wchar_t* const*, const wchar_t* const*);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _wspawnvp (int, const wchar_t*, const wchar_t* const*);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _wspawnvpe (int, const wchar_t*, const wchar_t* const*, const wchar_t* const*);
-
-#define _WPROCESS_DEFINED
-#endif
-#endif /* not __STRICT_ANSI__ */
+__cdecl __MINGW_NOTHROW
+wchar_t *wmemcpy (wchar_t *__restrict__, const wchar_t *__restrict__, size_t);
-#ifdef __cplusplus
-} /* end of extern "C" */
-#endif
+__cdecl __MINGW_NOTHROW wchar_t *wmemmove (wchar_t *, const wchar_t *, size_t);
+
+__cdecl __MINGW_NOTHROW
+long long wcstoll (const wchar_t *__restrict__, wchar_t **__restrict__, int);
-#endif /* Not RC_INVOKED */
+__cdecl __MINGW_NOTHROW unsigned long long wcstoull
+(const wchar_t *__restrict__, wchar_t **__restrict__, int);
+#endif /* _ISOC99_SOURCE */
-#endif /* not _WCHAR_H_ */
+_END_C_DECLS
+#undef __WCHAR_H_SOURCED__
+#endif /* _WCHAR_H && ! RC_INVOKED */
+#endif /* !_WCHAR_H: $RCSfile$: end of file */