]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/wxchar.cpp
compilation fix
[wxWidgets.git] / src / common / wxchar.cpp
index 657a0554c2eac439d7e3d3ed1be5f2ff9d2df37c..39efe204fa8026594f724032dc6b5bad6a951e59 100644 (file)
@@ -200,9 +200,9 @@ WXDLLEXPORT wxChar * wxStrtok(wxChar *psz, const wxChar *delim, wxChar **save_pt
 #ifndef wxSetlocale
 WXDLLEXPORT wxWCharBuffer wxSetlocale(int category, const wxChar *locale)
 {
-    char *localeOld = setlocale(category, wxConvLibc.cWX2MB(locale));
+    char *localeOld = setlocale(category, wxConvLocal.cWX2MB(locale));
 
-    return wxWCharBuffer(wxConvLibc.cMB2WC(localeOld));
+    return wxWCharBuffer(wxConvLocal.cMB2WC(localeOld));
 }
 #endif
 
@@ -335,7 +335,7 @@ WXDLLEXPORT double wxStrtod(const wxChar *nptr, wxChar **endptr)
   }
 
   wxString data(nptr, nptr-start);
-  wxWX2MBbuf dat = data.mb_str(wxConvLibc);
+  wxWX2MBbuf dat = data.mb_str(wxConvLocal);
   char *rdat = wxMBSTRINGCAST dat;
   double ret = strtod(dat, &rdat);
 
@@ -363,7 +363,7 @@ WXDLLEXPORT long int wxStrtol(const wxChar *nptr, wxChar **endptr, int base)
          (wxIsalpha(*nptr) && (wxToupper(*nptr) - wxT('A') + 10 < base))) nptr++;
 
   wxString data(nptr, nptr-start);
-  wxWX2MBbuf dat = data.mb_str(wxConvLibc);
+  wxWX2MBbuf dat = data.mb_str(wxConvLocal);
   char *rdat = wxMBSTRINGCAST dat;
   long int ret = strtol(dat, &rdat, base);
 
@@ -376,12 +376,20 @@ WXDLLEXPORT long int wxStrtol(const wxChar *nptr, wxChar **endptr, int base)
 #ifdef wxNEED_WX_STDIO_H
 WXDLLEXPORT FILE * wxFopen(const wxChar *path, const wxChar *mode)
 {
-    return fopen( wxConvFile.cWX2MB(path), wxConvLibc.cWX2MB(mode) );
+    char mode_buffer[10];
+    for (size_t i = 0; i < wxStrlen(mode)+1; i++)
+       mode_buffer[i] = (char) mode[i];
+    
+    return fopen( wxConvFile.cWX2MB(path), mode_buffer );
 }
 
 WXDLLEXPORT FILE * wxFreopen(const wxChar *path, const wxChar *mode, FILE *stream)
 {
-    return freopen( wxConvFile.cWX2MB(path), wxConvLibc.cWX2MB(mode), stream );
+    char mode_buffer[10];
+    for (size_t i = 0; i < wxStrlen(mode)+1; i++)
+       mode_buffer[i] = (char) mode[i];
+    
+    return freopen( wxConvFile.cWX2MB(path), mode_buffer, stream );
 }
 
 WXDLLEXPORT int wxRemove(const wxChar *path)
@@ -393,103 +401,24 @@ WXDLLEXPORT int wxRename(const wxChar *oldpath, const wxChar *newpath)
 {
     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
 double   WXDLLEXPORT wxAtof(const wxChar *psz)
 {
-  return atof(wxConvLibc.cWX2MB(psz));
+  return atof(wxConvLocal.cWX2MB(psz));
 }
 #endif
 
 #ifdef wxNEED_WX_STDLIB_H
 int      WXDLLEXPORT wxAtoi(const wxChar *psz)
 {
-  return atoi(wxConvLibc.cWX2MB(psz));
+  return atoi(wxConvLocal.cWX2MB(psz));
 }
 
 long     WXDLLEXPORT wxAtol(const wxChar *psz)
 {
-  return atol(wxConvLibc.cWX2MB(psz));
+  return atol(wxConvLocal.cWX2MB(psz));
 }
 
 wxChar * WXDLLEXPORT wxGetenv(const wxChar *name)
@@ -502,7 +431,7 @@ wxChar * WXDLLEXPORT wxGetenv(const wxChar *name)
   {
     // nope, retrieve it,
 #if wxUSE_UNICODE
-    wxCharBuffer buffer = wxConvLibc.cWX2MB(name);
+    wxCharBuffer buffer = wxConvLocal.cWX2MB(name);
     // printf( "buffer %s\n", (const char*) buffer );
     const char *val = getenv( (const char *)buffer );
 #else
@@ -514,7 +443,7 @@ wxChar * WXDLLEXPORT wxGetenv(const wxChar *name)
     
     // convert it,
 #ifdef wxUSE_UNICODE
-    data = (wxObject *)new wxString(val, wxConvLibc);
+    data = (wxObject *)new wxString(val, wxConvLocal);
 #else
     data = (wxObject *)new wxString(val);
 #endif
@@ -526,9 +455,9 @@ wxChar * WXDLLEXPORT wxGetenv(const wxChar *name)
   return (wxChar *)((wxString *)data)->c_str();
 }
 
-int      WXDLLEXPORT wxSystem(const wxChar *psz)
+int WXDLLEXPORT wxSystem(const wxChar *psz)
 {
-  return system(wxConvLibc.cWX2MB(psz));
+    return system(wxConvLocal.cWX2MB(psz));
 }
 
 #endif
@@ -536,17 +465,21 @@ int      WXDLLEXPORT wxSystem(const wxChar *psz)
 #ifdef wxNEED_WX_TIME_H
 WXDLLEXPORT size_t   wxStrftime(wxChar *s, size_t max, const wxChar *fmt, const struct tm *tm)
 {
-  if (!max) return 0;
-  char *buf = (char *)malloc(max);
-  size_t ret = strftime(buf, max, wxConvLibc.cWX2MB(fmt), tm);
-  if (ret) {
-    wxStrcpy(s, wxConvLibc.cMB2WX(buf));
-    free(buf);
-    return wxStrlen(s);
-  } else {
-    free(buf);
-    *s = 0;
-    return 0;
+    if (!max) return 0;
+    
+    char *buf = (char *)malloc(max);
+    size_t ret = strftime(buf, max, wxConvLocal.cWX2MB(fmt), tm);
+    if (ret)
+    {
+        wxStrcpy(s, wxConvLocal.cMB2WX(buf));
+        free(buf);
+        return wxStrlen(s);
+    } 
+    else
+    {
+        free(buf);
+        *s = 0;
+        return 0;
   }
 }
 #endif