wxSscanf() and friends are now Unicode+ANSI friendly wrappers instead of defines for CRT functions
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46323 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
48a2e193ec
commit
c49f887978
@ -28,29 +28,35 @@
|
|||||||
#ifdef wxHAVE_TCHAR_SUPPORT
|
#ifdef wxHAVE_TCHAR_SUPPORT
|
||||||
#define wxCRT_Fprintf _ftprintf
|
#define wxCRT_Fprintf _ftprintf
|
||||||
#define wxCRT_Printf _tprintf
|
#define wxCRT_Printf _tprintf
|
||||||
#define wxCRT_Scanf _tscanf
|
|
||||||
|
|
||||||
#define wxCRT_Sscanf _stscanf
|
|
||||||
#define wxCRT_Vfprintf _vftprintf
|
#define wxCRT_Vfprintf _vftprintf
|
||||||
#define wxCRT_Vprintf _vtprintf
|
#define wxCRT_Vprintf _vtprintf
|
||||||
#define wxCRT_Vsscanf _vstscanf
|
|
||||||
#define wxCRT_Vsprintf _vstprintf
|
#define wxCRT_Vsprintf _vstprintf
|
||||||
|
#define wxCRT_Vscanf _vtscanf
|
||||||
|
#define wxCRT_Vfscanf _vftscanf
|
||||||
|
#define wxCRT_Vsscanf _vstscanf
|
||||||
#else /* !TCHAR-aware compilers */
|
#else /* !TCHAR-aware compilers */
|
||||||
|
|
||||||
#if !wxUSE_UNICODE /* ASCII */
|
#if !wxUSE_UNICODE /* ASCII */
|
||||||
#define wxCRT_Fprintf fprintf
|
#define wxCRT_Fprintf fprintf
|
||||||
#define wxCRT_Fscanf fscanf
|
#define wxCRT_Fscanf fscanf
|
||||||
#define wxCRT_Printf printf
|
#define wxCRT_Printf printf
|
||||||
#define wxCRT_Scanf scanf
|
|
||||||
#define wxCRT_Sscanf sscanf
|
|
||||||
#define wxCRT_Vfprintf vfprintf
|
#define wxCRT_Vfprintf vfprintf
|
||||||
#define wxCRT_Vprintf vprintf
|
#define wxCRT_Vprintf vprintf
|
||||||
#define wxCRT_Vsscanf vsscanf
|
|
||||||
#define wxCRT_Vsprintf vsprintf
|
#define wxCRT_Vsprintf vsprintf
|
||||||
|
#define wxCRT_Scanf scanf
|
||||||
|
#define wxCRT_Sscanf sscanf
|
||||||
|
#define wxCRT_Vsscanf vsscanf
|
||||||
#endif /* ASCII */
|
#endif /* ASCII */
|
||||||
#endif /* TCHAR-aware compilers/the others */
|
#endif /* TCHAR-aware compilers/the others */
|
||||||
|
|
||||||
|
/* Required for wxScanf() etc. */
|
||||||
|
#define wxCRT_VscanfA vscanf
|
||||||
|
#define wxCRT_VsscanfA vsscanf
|
||||||
|
#define wxCRT_VfscanfA vfscanf
|
||||||
|
#define wxCRT_VscanfW vwscanf
|
||||||
|
#define wxCRT_VsscanfW vswscanf
|
||||||
|
#define wxCRT_VfscanfW vfwscanf
|
||||||
|
|
||||||
/* printf() family saga */
|
/* printf() family saga */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -208,14 +214,10 @@
|
|||||||
|
|
||||||
#if defined(wxNEED_PRINTF_CONVERSION) || defined(wxNEED_WPRINTF)
|
#if defined(wxNEED_PRINTF_CONVERSION) || defined(wxNEED_WPRINTF)
|
||||||
/*
|
/*
|
||||||
we need to implement all wide character printf and scanf functions
|
we need to implement all wide character printf functions either because
|
||||||
either because we don't have them at all or because they don't have the
|
we don't have them at all or because they don't have the semantics we
|
||||||
semantics we need
|
need
|
||||||
*/
|
*/
|
||||||
int wxCRT_Scanf( const wxChar *format, ... ) ATTRIBUTE_PRINTF_1;
|
|
||||||
int wxCRT_Sscanf( const wxChar *str, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2;
|
|
||||||
int wxCRT_Fscanf( FILE *stream, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2;
|
|
||||||
int wxCRT_Vsscanf( const wxChar *str, const wxChar *format, va_list ap );
|
|
||||||
int wxCRT_Printf( const wxChar *format, ... ) ATTRIBUTE_PRINTF_1;
|
int wxCRT_Printf( const wxChar *format, ... ) ATTRIBUTE_PRINTF_1;
|
||||||
int wxCRT_Fprintf( FILE *stream, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2;
|
int wxCRT_Fprintf( FILE *stream, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2;
|
||||||
int wxCRT_Vfprintf( FILE *stream, const wxChar *format, va_list ap );
|
int wxCRT_Vfprintf( FILE *stream, const wxChar *format, va_list ap );
|
||||||
@ -379,11 +381,34 @@ wxVsnprintf(wchar_t *str, size_t size, const wxString& format, va_list argptr);
|
|||||||
// vararg-like functions, we just provide both char* and wchar_t* variants
|
// vararg-like functions, we just provide both char* and wchar_t* variants
|
||||||
// of these functions. The type of output variadic arguments for %s must match
|
// of these functions. The type of output variadic arguments for %s must match
|
||||||
// the type of 'str' and 'format' arguments.
|
// the type of 'str' and 'format' arguments.
|
||||||
|
//
|
||||||
|
// For compatibility with earlier wx versions, we also provide wxSscanf()
|
||||||
|
// version with the first argument (input string) wxString; for this version,
|
||||||
|
// the type of output string values is determined by the type of format string
|
||||||
|
// only.
|
||||||
|
|
||||||
// FIXME-UTF8: actually do it, for now we only have wxChar* variants:
|
int WXDLLIMPEXP_BASE wxScanf(const char *format, ...);
|
||||||
#define wxScanf wxCRT_Scanf
|
int WXDLLIMPEXP_BASE wxScanf(const wchar_t *format, ...);
|
||||||
#define wxFscanf wxCRT_Fscanf
|
|
||||||
#define wxSscanf wxCRT_Sscanf
|
int WXDLLIMPEXP_BASE wxFscanf(FILE *stream, const char *format, ...);
|
||||||
#define wxVsscanf wxCRT_Vsscanf
|
int WXDLLIMPEXP_BASE wxFscanf(FILE *stream, const wchar_t *format, ...);
|
||||||
|
|
||||||
|
int WXDLLIMPEXP_BASE wxSscanf(const char *str, const char *format, ...);
|
||||||
|
int WXDLLIMPEXP_BASE wxSscanf(const wchar_t *str, const wchar_t *format, ...);
|
||||||
|
int WXDLLIMPEXP_BASE wxSscanf(const wxCharBuffer& str, const char *format, ...);
|
||||||
|
int WXDLLIMPEXP_BASE wxSscanf(const wxWCharBuffer& str, const wchar_t *format, ...);
|
||||||
|
int WXDLLIMPEXP_BASE wxSscanf(const wxString& str, const char *format, ...);
|
||||||
|
int WXDLLIMPEXP_BASE wxSscanf(const wxString& str, const wchar_t *format, ...);
|
||||||
|
int WXDLLIMPEXP_BASE wxSscanf(const wxCStrData& str, const char *format, ...);
|
||||||
|
int WXDLLIMPEXP_BASE wxSscanf(const wxCStrData& str, const wchar_t *format, ...);
|
||||||
|
|
||||||
|
int WXDLLIMPEXP_BASE wxVsscanf(const char *str, const char *format, va_list ap);
|
||||||
|
int WXDLLIMPEXP_BASE wxVsscanf(const wchar_t *str, const wchar_t *format, va_list ap);
|
||||||
|
int WXDLLIMPEXP_BASE wxVsscanf(const wxCharBuffer& str, const char *format, va_list ap);
|
||||||
|
int WXDLLIMPEXP_BASE wxVsscanf(const wxWCharBuffer& str, const wchar_t *format, va_list ap);
|
||||||
|
int WXDLLIMPEXP_BASE wxVsscanf(const wxString& str, const char *format, va_list ap);
|
||||||
|
int WXDLLIMPEXP_BASE wxVsscanf(const wxString& str, const wchar_t *format, va_list ap);
|
||||||
|
int WXDLLIMPEXP_BASE wxVsscanf(const wxCStrData& str, const char *format, va_list ap);
|
||||||
|
int WXDLLIMPEXP_BASE wxVsscanf(const wxCStrData& str, const wchar_t *format, va_list ap);
|
||||||
|
|
||||||
#endif /* _WX_WXCRTVARARG_H_ */
|
#endif /* _WX_WXCRTVARARG_H_ */
|
||||||
|
@ -510,41 +510,6 @@ wxString wxConvertFormat(const wxChar *format)
|
|||||||
|
|
||||||
#if defined(wxNEED_PRINTF_CONVERSION) || defined(wxNEED_WPRINTF)
|
#if defined(wxNEED_PRINTF_CONVERSION) || defined(wxNEED_WPRINTF)
|
||||||
|
|
||||||
int wxCRT_Scanf( const wxChar *format, ... )
|
|
||||||
{
|
|
||||||
va_list argptr;
|
|
||||||
va_start(argptr, format);
|
|
||||||
|
|
||||||
int ret = vwscanf(wxFormatConverter(format), argptr );
|
|
||||||
|
|
||||||
va_end(argptr);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int wxCRT_Sscanf( const wxChar *str, const wxChar *format, ... )
|
|
||||||
{
|
|
||||||
va_list argptr;
|
|
||||||
va_start(argptr, format);
|
|
||||||
|
|
||||||
int ret = vswscanf( str, wxFormatConverter(format), argptr );
|
|
||||||
|
|
||||||
va_end(argptr);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int wxCRT_Fscanf( FILE *stream, const wxChar *format, ... )
|
|
||||||
{
|
|
||||||
va_list argptr;
|
|
||||||
va_start(argptr, format);
|
|
||||||
int ret = vfwscanf(stream, wxFormatConverter(format), argptr);
|
|
||||||
|
|
||||||
va_end(argptr);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int wxCRT_Printf( const wxChar *format, ... )
|
int wxCRT_Printf( const wxChar *format, ... )
|
||||||
{
|
{
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
@ -569,11 +534,6 @@ int wxCRT_Fprintf( FILE *stream, const wxChar *format, ... )
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxCRT_Vsscanf( const wxChar *str, const wxChar *format, va_list argptr )
|
|
||||||
{
|
|
||||||
return vswscanf( str, wxFormatConverter(format), argptr );
|
|
||||||
}
|
|
||||||
|
|
||||||
int wxCRT_Vfprintf( FILE *stream, const wxChar *format, va_list argptr )
|
int wxCRT_Vfprintf( FILE *stream, const wxChar *format, va_list argptr )
|
||||||
{
|
{
|
||||||
return vfwprintf( stream, wxFormatConverter(format), argptr );
|
return vfwprintf( stream, wxFormatConverter(format), argptr );
|
||||||
@ -1632,4 +1592,66 @@ void wxUpdateLocaleIsUtf8()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // wxUSE_UTF8_LOCALE_ONLY
|
#endif // wxUSE_UNICODE_UTF8
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// wx wrappers for CRT functions
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxScanf() and friends
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// implement vararg function by calling a vfoo function that takes va_list
|
||||||
|
// argument; use "ap" for the va_list argument in "call" expression
|
||||||
|
#define IMPL_SCANFUNC(call) \
|
||||||
|
va_list ap; \
|
||||||
|
va_start(ap, format); \
|
||||||
|
int retval = call; \
|
||||||
|
va_end(ap); \
|
||||||
|
return retval
|
||||||
|
|
||||||
|
int wxScanf(const char *format, ...)
|
||||||
|
{ IMPL_SCANFUNC( wxCRT_VscanfA(format, ap) ); }
|
||||||
|
int wxScanf(const wchar_t *format, ...)
|
||||||
|
{ IMPL_SCANFUNC( wxCRT_VscanfW(wxFormatConverter(format), ap) ); }
|
||||||
|
|
||||||
|
int wxFscanf(FILE *stream, const char *format, ...)
|
||||||
|
{ IMPL_SCANFUNC( wxCRT_VfscanfA(stream, format, ap) ); }
|
||||||
|
int wxFscanf(FILE *stream, const wchar_t *format, ...)
|
||||||
|
{ IMPL_SCANFUNC( wxCRT_VfscanfW(stream, wxFormatConverter(format), ap) ); }
|
||||||
|
|
||||||
|
int wxSscanf(const char *str, const char *format, ...)
|
||||||
|
{ IMPL_SCANFUNC( wxCRT_VsscanfA(str, format, ap) ); }
|
||||||
|
int wxSscanf(const wchar_t *str, const wchar_t *format, ...)
|
||||||
|
{ IMPL_SCANFUNC( wxCRT_VsscanfW(str, wxFormatConverter(format), ap) ); }
|
||||||
|
int wxSscanf(const wxCharBuffer& str, const char *format, ...)
|
||||||
|
{ IMPL_SCANFUNC( wxCRT_VsscanfA(str, format, ap) ); }
|
||||||
|
int wxSscanf(const wxWCharBuffer& str, const wchar_t *format, ...)
|
||||||
|
{ IMPL_SCANFUNC( wxCRT_VsscanfW(str, wxFormatConverter(format), ap) ); }
|
||||||
|
int wxSscanf(const wxString& str, const char *format, ...)
|
||||||
|
{ IMPL_SCANFUNC( wxCRT_VsscanfA(str.mb_str(), format, ap) ); }
|
||||||
|
int wxSscanf(const wxString& str, const wchar_t *format, ...)
|
||||||
|
{ IMPL_SCANFUNC( wxCRT_VsscanfW(str.wc_str(), wxFormatConverter(format), ap) ); }
|
||||||
|
int wxSscanf(const wxCStrData& str, const char *format, ...)
|
||||||
|
{ IMPL_SCANFUNC( wxCRT_VsscanfA(str.AsCharBuf(), format, ap) ); }
|
||||||
|
int wxSscanf(const wxCStrData& str, const wchar_t *format, ...)
|
||||||
|
{ IMPL_SCANFUNC( wxCRT_VsscanfW(str.AsWCharBuf(), wxFormatConverter(format), ap) ); }
|
||||||
|
|
||||||
|
int wxVsscanf(const char *str, const char *format, va_list ap)
|
||||||
|
{ return wxCRT_VsscanfA(str, format, ap); }
|
||||||
|
int wxVsscanf(const wchar_t *str, const wchar_t *format, va_list ap)
|
||||||
|
{ return wxCRT_VsscanfW(str, wxFormatConverter(format), ap); }
|
||||||
|
int wxVsscanf(const wxCharBuffer& str, const char *format, va_list ap)
|
||||||
|
{ return wxCRT_VsscanfA(str, format, ap); }
|
||||||
|
int wxVsscanf(const wxWCharBuffer& str, const wchar_t *format, va_list ap)
|
||||||
|
{ return wxCRT_VsscanfW(str, wxFormatConverter(format), ap); }
|
||||||
|
int wxVsscanf(const wxString& str, const char *format, va_list ap)
|
||||||
|
{ return wxCRT_VsscanfA(str.mb_str(), format, ap); }
|
||||||
|
int wxVsscanf(const wxString& str, const wchar_t *format, va_list ap)
|
||||||
|
{ return wxCRT_VsscanfW(str.wc_str(), wxFormatConverter(format), ap); }
|
||||||
|
int wxVsscanf(const wxCStrData& str, const char *format, va_list ap)
|
||||||
|
{ return wxCRT_VsscanfA(str.AsCharBuf(), format, ap); }
|
||||||
|
int wxVsscanf(const wxCStrData& str, const wchar_t *format, va_list ap)
|
||||||
|
{ return wxCRT_VsscanfW(str.AsWCharBuf(), wxFormatConverter(format), ap); }
|
||||||
|
Loading…
Reference in New Issue
Block a user