2007-12-12 20:12:24 +08:00
|
|
|
/* wchar.h: Extra wchar defs
|
|
|
|
|
|
|
|
This file is part of Cygwin.
|
|
|
|
|
|
|
|
This software is a copyrighted work licensed under the terms of the
|
|
|
|
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
|
|
|
details. */
|
|
|
|
|
|
|
|
#ifndef _CYGWIN_WCHAR_H
|
|
|
|
#define _CYGWIN_WCHAR_H
|
|
|
|
|
|
|
|
#include_next <wchar.h>
|
|
|
|
|
2016-07-21 04:05:59 +08:00
|
|
|
/* Internal headers from newlib */
|
|
|
|
#include "../locale/setlocale.h"
|
|
|
|
|
2009-04-07 20:13:37 +08:00
|
|
|
#define ENCODING_LEN 31
|
|
|
|
|
2007-12-12 20:12:24 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2009-03-24 20:18:34 +08:00
|
|
|
typedef int mbtowc_f (struct _reent *, wchar_t *, const char *, size_t,
|
2016-07-21 04:05:59 +08:00
|
|
|
mbstate_t *);
|
2009-03-24 20:18:34 +08:00
|
|
|
typedef mbtowc_f *mbtowc_p;
|
2007-12-12 20:12:24 +08:00
|
|
|
|
2009-03-24 21:21:23 +08:00
|
|
|
extern mbtowc_f __ascii_mbtowc;
|
|
|
|
extern mbtowc_f __utf8_mbtowc;
|
2016-07-21 04:05:59 +08:00
|
|
|
extern mbtowc_p __iso_mbtowc (int);
|
|
|
|
extern mbtowc_p __cp_mbtowc (int);
|
|
|
|
|
|
|
|
#define __MBTOWC (__get_current_locale ()->mbtowc)
|
|
|
|
|
|
|
|
typedef int wctomb_f (struct _reent *, char *, wchar_t, mbstate_t *);
|
2009-04-07 20:13:37 +08:00
|
|
|
typedef wctomb_f *wctomb_p;
|
|
|
|
|
2009-05-15 03:49:37 +08:00
|
|
|
extern wctomb_f __ascii_wctomb;
|
2009-04-07 20:13:37 +08:00
|
|
|
extern wctomb_f __utf8_wctomb;
|
|
|
|
|
2016-07-21 04:05:59 +08:00
|
|
|
#define __WCTOMB (__get_current_locale ()->wctomb)
|
2009-03-24 20:18:34 +08:00
|
|
|
|
2007-12-12 20:12:24 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2009-04-07 20:13:37 +08:00
|
|
|
|
2009-04-08 00:22:55 +08:00
|
|
|
#ifdef __INSIDE_CYGWIN__
|
2010-02-04 20:35:49 +08:00
|
|
|
#ifdef __cplusplus
|
2013-01-21 12:34:52 +08:00
|
|
|
size_t __reg3 sys_wcstombs (char *dst, size_t len, const wchar_t * src,
|
2016-07-21 04:05:59 +08:00
|
|
|
size_t nwc = (size_t) -1);
|
Do not treat the command line or environment like paths
* dcrt0.cc (dll_crt0_1), environ.cc (environ_init, getwinenveq,
build_env), strfuncs.cc (sys_wcstombs, sys_wcstombs_alloc),
wchar.c (sys_wcstombs, sys_wcstombs_alloc): avoid mis-conversions
of text that does not, actually, refer to a path or file name
Detailed explanation:
Our WCS -> UTF conversion handles the private Unicode page specially
to allow for otherwise invalid file names. However, this handling makes
no sense for command-lines, nor environment variables, which we would
rather convert verbatim.
As a stop-gap solution, let's just introduce a version of the
sys_wcstombs() function that specifically excludes that file name
conversion magic.
The proper solution is to change sys_wcstombs() to assume that it is not
a path that wants to be converted, and introduce sys_wcstombs_path()
that does, but that is a bigger task which we leave for another patch.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-12-17 23:22:49 +08:00
|
|
|
size_t __reg3 sys_wcstombs_no_path (char *dst, size_t len,
|
2016-07-21 04:05:59 +08:00
|
|
|
const wchar_t * src,
|
|
|
|
size_t nwc = (size_t) -1);
|
2013-01-21 12:34:52 +08:00
|
|
|
size_t __reg3 sys_wcstombs_alloc (char **, int, const wchar_t *,
|
2016-07-21 04:05:59 +08:00
|
|
|
size_t = (size_t) -1);
|
Do not treat the command line or environment like paths
* dcrt0.cc (dll_crt0_1), environ.cc (environ_init, getwinenveq,
build_env), strfuncs.cc (sys_wcstombs, sys_wcstombs_alloc),
wchar.c (sys_wcstombs, sys_wcstombs_alloc): avoid mis-conversions
of text that does not, actually, refer to a path or file name
Detailed explanation:
Our WCS -> UTF conversion handles the private Unicode page specially
to allow for otherwise invalid file names. However, this handling makes
no sense for command-lines, nor environment variables, which we would
rather convert verbatim.
As a stop-gap solution, let's just introduce a version of the
sys_wcstombs() function that specifically excludes that file name
conversion magic.
The proper solution is to change sys_wcstombs() to assume that it is not
a path that wants to be converted, and introduce sys_wcstombs_path()
that does, but that is a bigger task which we leave for another patch.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-12-17 23:22:49 +08:00
|
|
|
size_t __reg3 sys_wcstombs_alloc_no_path (char **, int, const wchar_t *,
|
2016-07-21 04:05:59 +08:00
|
|
|
size_t = (size_t) -1);
|
2013-01-21 12:34:52 +08:00
|
|
|
|
2016-07-21 04:05:59 +08:00
|
|
|
size_t __reg3 sys_cp_mbstowcs (mbtowc_p, wchar_t *, size_t, const char *,
|
|
|
|
size_t = (size_t) -1);
|
2013-01-21 12:34:52 +08:00
|
|
|
size_t __reg3 sys_mbstowcs (wchar_t * dst, size_t dlen, const char *src,
|
2016-07-21 04:05:59 +08:00
|
|
|
size_t nms = (size_t) -1);
|
2013-01-21 12:34:52 +08:00
|
|
|
size_t __reg3 sys_mbstowcs_alloc (wchar_t **, int, const char *,
|
2016-07-21 04:05:59 +08:00
|
|
|
size_t = (size_t) -1);
|
2010-02-04 20:35:49 +08:00
|
|
|
#endif /* __cplusplus */
|
2009-04-08 00:22:55 +08:00
|
|
|
#endif /* __INSIDE_CYGWIN__ */
|
2009-04-07 20:13:37 +08:00
|
|
|
|
2007-12-12 20:12:24 +08:00
|
|
|
#endif /* _CYGWIN_WCHAR_H */
|