#endif // OS/compiler
}
+#ifndef wxSnprintf
// wxSnprintf() is like snprintf() if it's available and sprintf() (always
-// available, but dangerous!) if not
+// available, but dangerous!) if not.
extern int WXDLLEXPORT wxSnprintf(wxChar *buf, size_t len,
const wxChar *format,
...) ATTRIBUTE_PRINTF_3;
+#else
+// GNU libc 2.2 only has for wxSnprintf for Unicode called swprintf
+// so we imitate wxSprintf using it.
+extern int WXDLLEXPORT wxSprintf(wxChar *buf,
+ const wxChar *format,
+ ...) ATTRIBUTE_PRINTF_2;
+#endif
+#ifndef wxVsnprintf
// and wxVsnprintf() is like vsnprintf() or vsprintf()
extern int WXDLLEXPORT wxVsnprintf(wxChar *buf, size_t len,
const wxChar *format,
va_list argptr);
+#else
+// GNU libc 2.2 only has for wxVsnprintf for Unicode called vswprintf
+// so we imitate wxVsprintf using it.
+extern int WXDLLEXPORT wxVsprintf(wxChar *buf,
+ const wxChar *format,
+ va_list argptr);
+#endif
// return an empty wxString
class WXDLLEXPORT wxString; // not yet defined
# define wxStrtoul wcstoul
# define wxStrxfrm wcsxfrm
+# define wxFgetc fgetwc
+# define wxFgetchar fgetwchar
+# define wxFgets fgetws
+# define wxFputc fputwc
+# define wxFputchar fputwchar
+# define wxFprintf fwprintf
+# define wxFscanf fwscanf
+# define wxGetc getwc
+# define wxGetchar getwchar
+# define wxGets getws
+# define wxPrintf wprintf
+# define wxPutc wputc
+# define wxPutchar wputchar
+# define wxPuts putws
+# define wxScanf wscanf
+# define wxSnprintf swprintf
+# define wxSscanf swscanf
+# define wxUngetc ungetwc
+# define wxVfprint vfwprintf
+# define wxVprintf vwprintf
+# define wxVsscanf vswscanf
+# define wxVsnprintf vswprintf
+
// glibc doesn't have wc equivalents of the other stuff
# define wxNEED_WX_STDIO_H
# define wxNEED_WX_STDLIB_H
# endif
# ifdef wxNEED_WX_STDIO_H
+# define wxFopen fopen
+# define wxFreopen freopen
+# define wxPerror perror
+# define wxRemove remove
+# define wxRename rename
+# define wxTmpnam tmpnam
+
# define wxFgetc fgetc
# define wxFgetchar fgetchar
# define wxFgets fgets
-# define wxFopen fopen
# define wxFputc fputc
# define wxFputchar fputchar
# define wxFprintf fprintf
-# define wxFreopen freopen
# define wxFscanf fscanf
# define wxGetc getc
# define wxGetchar getchar
# define wxGets gets
-# define wxPerror perror
# define wxPrintf printf
# define wxPutc putc
# define wxPutchar putchar
# define wxPuts puts
-# define wxRemove remove
-# define wxRename rename
# define wxScanf scanf
# define wxSprintf sprintf
# define wxSscanf sscanf
-# define wxTmpnam tmpnam
# define wxUngetc ungetc
# define wxVfprint vfprintf
# define wxVprintf vprintf
# undef wxNEED_WX_STDIO_H
# endif
+
# ifdef wxNEED_WX_STDLIB_H
# define wxAtof atof
# define wxAtoi atoi
WXDLLEXPORT FILE * wxFreopen(const wxChar *path, const wxChar *mode, FILE *stream);
WXDLLEXPORT int wxRemove(const wxChar *path);
WXDLLEXPORT int wxRename(const wxChar *oldpath, const wxChar *newpath);
-WXDLLEXPORT int wxPrintf(const wxChar *fmt, ...) ATTRIBUTE_PRINTF_1;
-WXDLLEXPORT int wxVprintf(const wxChar *fmt, va_list argptr);
-WXDLLEXPORT int wxFprintf(FILE *stream, const wxChar *fmt, ...) ATTRIBUTE_PRINTF_2;
-WXDLLEXPORT int wxVfprintf(FILE *stream, const wxChar *fmt, va_list argptr);
-WXDLLEXPORT int wxSprintf(wxChar *buf, const wxChar *fmt, ...) ATTRIBUTE_PRINTF_2;
-WXDLLEXPORT int wxVsprintf(wxChar *buf, const wxChar *fmt, va_list argptr);
-WXDLLEXPORT int wxSscanf(const wxChar *buf, const wxChar *fmt, ...) ATTRIBUTE_PRINTF_2;
-WXDLLEXPORT int wxVsscanf(const wxChar *buf, const wxChar *fmt, va_list argptr);
#endif
#ifndef wxAtof
#if wxUSE_UNICODE
#undef wxUSE_EXPERIMENTAL_PRINTF
- #define wxUSE_EXPERIMENTAL_PRINTF 1
+ #ifndef wvsnprintf
+ #define wxUSE_EXPERIMENTAL_PRINTF 1
+ #endif
#endif
// allocating extra space for each string consumes more memory but speeds up
#endif //std::string compatibility
-extern int WXDLLEXPORT wxVsnprintf(wxChar *buf, size_t len,
- const wxChar *format, va_list argptr)
+#ifndef wxVsnprintf
+int WXDLLEXPORT wxVsnprintf(wxChar *buf, size_t len,
+ const wxChar *format, va_list argptr)
{
#if wxUSE_UNICODE
- // FIXME should use wvsnprintf() or whatever if it's available
wxString s;
int iLen = s.PrintfV(format, argptr);
if ( iLen != -1 )
return rc;
#endif // Unicode/ANSI
}
+#else
+// GNU libc 2.2 only has for wxVsnprintf for Unicode called vswprintf
+// so we imitate wxVsprintf using it.
+int WXDLLEXPORT wxVsprintf(wxChar *buf,
+ const wxChar *format,
+ va_list argptr)
+{
+ return vswprintf( buf, 10000, format, argptr );
+}
+#endif
-extern int WXDLLEXPORT wxSnprintf(wxChar *buf, size_t len,
- const wxChar *format, ...)
+#ifndef wxSnprintf
+int WXDLLEXPORT wxSnprintf(wxChar *buf, size_t len,
+ const wxChar *format, ...)
{
va_list argptr;
va_start(argptr, format);
return iLen;
}
+#else
+// GNU libc 2.2 only has for wxSnprintf for Unicode called swprintf
+// so we imitate wxSprintf using it.
+int WXDLLEXPORT wxSprintf(wxChar *buf,
+ const wxChar *format,
+ ...) ATTRIBUTE_PRINTF_2
+{
+ va_list argptr;
+ va_start(argptr, format);
+
+ int iLen = swprintf(buf, 10000, format, argptr);
+
+ va_end(argptr);
+
+ return iLen;
+}
+#endif
// ----------------------------------------------------------------------------
// private classes
{
return rename( wxConvFile.cWX2MB(oldpath), wxConvFile.cWX2MB(newpath) );
}
-
-int WXDLLEXPORT wxPrintf(const wxChar *fmt, ...)
-{
- va_list argptr;
- int ret;
-
- va_start(argptr, fmt);
- ret = wxVprintf(fmt, argptr);
- va_end(argptr);
- return ret;
-}
-
-int WXDLLEXPORT wxVprintf(const wxChar *fmt, va_list argptr)
-{
- wxString str;
- str.PrintfV(fmt,argptr);
- printf("%s", (const char*)str.mb_str());
- return str.Len();
-}
-
-int WXDLLEXPORT wxFprintf(FILE *stream, const wxChar *fmt, ...)
-{
- va_list argptr;
- int ret;
-
- va_start(argptr, fmt);
- ret = wxVfprintf(stream, fmt, argptr);
- va_end(argptr);
- return ret;
-}
-
-int WXDLLEXPORT wxVfprintf(FILE *stream, const wxChar *fmt, va_list argptr)
-{
- wxString str;
- str.PrintfV(fmt,argptr);
- fprintf(stream, "%s", (const char*)str.mb_str());
- return str.Len();
-}
-
-int WXDLLEXPORT wxSprintf(wxChar *buf, const wxChar *fmt, ...)
-{
- va_list argptr;
- int ret;
-
- va_start(argptr, fmt);
- ret = wxVsprintf(buf, fmt, argptr);
- va_end(argptr);
- return ret;
-}
-
-int WXDLLEXPORT wxVsprintf(wxChar *buf, const wxChar *fmt, va_list argptr)
-{
- // this might be sort of inefficient, but it doesn't matter since
- // we'd prefer people to use wxString::Printf directly instead anyway
- wxString str;
- str.PrintfV(fmt,argptr);
- wxStrcpy(buf,str.c_str());
- return str.Len();
-}
-
-int WXDLLEXPORT wxSscanf(const wxChar *buf, const wxChar *fmt, ...)
-{
- va_list argptr;
- int ret;
-
- va_start(argptr, fmt);
- ret = wxVsscanf(buf, fmt, argptr);
- va_end(argptr);
- return ret;
-}
-
-int WXDLLEXPORT wxVsscanf(const wxChar *buf, const wxChar *fmt, va_list argptr)
-{
- int ret;
- // this will work only for numeric conversion! Strings will not be converted correctly
- // hopefully this is all we'll need
- ret = vsscanf(wxConvLibc.cWX2MB(buf), wxConvLibc.cWX2MB(fmt), argptr);
- return ret;
-}
#endif
#ifndef wxAtof