62755474e5
and con_charset. (dev_console::str_to_con): Take mbtowc function pointer and charset as additional parameters. * fhandler_console.cc (fhandler_console::get_tty_stuff): Initialize aforementioned new members. Explain why. (dev_console::con_to_str): Remove useless comment. Call new sys_cp_wcstombs function rather than sys_wcstombs. (dev_console::str_to_con): Take mbtowc function pointer and charset as additional parameters. Call sys_cp_mbstowcs accordingly. (fhandler_console::write_normal): Only initialize f_mbtowc and charset once. Accommodate changed str_to_con. * strfuncs.cc (sys_cp_wcstombs): Renamed from sys_wcstombs. Take wctomb function pointer and charset as parameters. Use throughout. (sys_cp_mbstowcs): Take wctomb function pointer and charset as parameters instead of codepage. Remove matching local variables and their initialization. * wchar.h (ENCODING_LEN): Define as in newlib. (__mbtowc): Use mbtowc_p typedef for declaration. (wctomb_f): New type. (wctomb_p): New type. (__wctomb): Declare. (__utf8_wctomb): Use wctomb_f typedef for declaration. (sys_cp_wcstombs): Move declaration from winsup.h here. (sys_wcstombs): Ditto. (sys_wcstombs_alloc): Ditto. (sys_cp_mbstowcs): Ditto. (sys_mbstowcs): Ditto. (sys_mbstowcs_alloc): Ditto. * winsup.h: Move declaration of sys_FOO functions to wchar.h. Include wchar.h instead.
74 lines
1.9 KiB
C
74 lines
1.9 KiB
C
/* wchar.h: Extra wchar defs
|
|
|
|
Copyright 2007, 2009 Red Hat, Inc.
|
|
|
|
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>
|
|
|
|
#define ENCODING_LEN 31
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
typedef int mbtowc_f (struct _reent *, wchar_t *, const char *, size_t,
|
|
const char *, mbstate_t *);
|
|
typedef mbtowc_f *mbtowc_p;
|
|
|
|
extern mbtowc_p __mbtowc;
|
|
extern mbtowc_f __ascii_mbtowc;
|
|
extern mbtowc_f __utf8_mbtowc;
|
|
extern mbtowc_f __iso_mbtowc;
|
|
extern mbtowc_f __cp_mbtowc;
|
|
|
|
typedef int wctomb_f (struct _reent *, char *, wchar_t, const char *,
|
|
mbstate_t *);
|
|
typedef wctomb_f *wctomb_p;
|
|
|
|
extern wctomb_p __wctomb;
|
|
extern wctomb_f __utf8_wctomb;
|
|
|
|
extern char *__locale_charset ();
|
|
|
|
extern mbtowc_p __set_charset_from_codepage (unsigned int cp, char *charset);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
size_t __stdcall sys_cp_wcstombs (wctomb_p, char *, char *, size_t,
|
|
const PWCHAR, size_t = (size_t) -1)
|
|
__attribute__ ((regparm(3)));
|
|
inline size_t
|
|
__stdcall sys_wcstombs (char *dst, size_t len, const PWCHAR src,
|
|
size_t nwc = (size_t) -1)
|
|
{
|
|
return sys_cp_wcstombs (__wctomb, __locale_charset (), dst, len, src, nwc);
|
|
}
|
|
size_t __stdcall sys_wcstombs_alloc (char **, int, const PWCHAR,
|
|
size_t = (size_t) -1)
|
|
__attribute__ ((regparm(3)));
|
|
|
|
size_t __stdcall sys_cp_mbstowcs (mbtowc_p, char *, PWCHAR, size_t,
|
|
const char *, size_t = (size_t) -1)
|
|
__attribute__ ((regparm(3)));
|
|
inline size_t
|
|
sys_mbstowcs (PWCHAR dst, size_t dlen, const char *src,
|
|
size_t nms = (size_t) -1)
|
|
{
|
|
return sys_cp_mbstowcs (__mbtowc, __locale_charset (), dst, dlen, src, nms);
|
|
}
|
|
size_t __stdcall sys_mbstowcs_alloc (PWCHAR *, int, const char *,
|
|
size_t = (size_t) -1)
|
|
__attribute__ ((regparm(3)));
|
|
|
|
#endif /* _CYGWIN_WCHAR_H */
|