]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/wxchar.cpp
fixed MSVC6 warning
[wxWidgets.git] / src / common / wxchar.cpp
index 368d4bf9fb3dd4ab59d679c278a8b69e93394125..e09e7e06b6fdffcf37c41031eedb57259141cd9c 100644 (file)
@@ -130,11 +130,11 @@ bool WXDLLEXPORT wxOKlibc()
             (strcasecmp(cur_locale + strlen(cur_locale) - 4, "utf8")) ||
             (strcasecmp(cur_locale + strlen(cur_locale) - 5, "utf-8"))) {
       // nope, don't use libc conversion
-      return FALSE;
+      return false;
     }
   }
 #endif
-  return TRUE;
+  return true;
 }
 
 // ============================================================================
@@ -180,10 +180,10 @@ int WXDLLEXPORT wxVsnprintf_(wxChar *buf, size_t lenMax,
         {
             static char s_szFlags[256] = "%";
             size_t flagofs = 1;
-            bool adj_left = FALSE,
-                 in_prec = FALSE,
-                 prec_dot = FALSE,
-                 done = FALSE;
+            bool adj_left = false,
+                 in_prec = false,
+                 prec_dot = false,
+                 done = false;
             int ilen = 0;
             size_t min_width = 0,
                    max_width = wxSTRING_MAXLEN;
@@ -194,7 +194,7 @@ int WXDLLEXPORT wxVsnprintf_(wxChar *buf, size_t lenMax,
                 if (in_prec && !prec_dot) \
                 { \
                     s_szFlags[flagofs++] = '.'; \
-                    prec_dot = TRUE; \
+                    prec_dot = true; \
                 }
 
 #define APPEND_CH(ch) \
@@ -220,12 +220,12 @@ int WXDLLEXPORT wxVsnprintf_(wxChar *buf, size_t lenMax,
                     case wxT('\0'):
                         APPEND_CH(_T('\0'));
 
-                        done = TRUE;
+                        done = true;
                         break;
 
                     case wxT('%'):
                         APPEND_CH(_T('%'));
-                        done = TRUE;
+                        done = true;
                         break;
 
                     case wxT('#'):
@@ -239,14 +239,14 @@ int WXDLLEXPORT wxVsnprintf_(wxChar *buf, size_t lenMax,
 
                     case wxT('-'):
                         CHECK_PREC
-                        adj_left = TRUE;
+                        adj_left = true;
                         s_szFlags[flagofs++] = ch;
                         break;
 
                     case wxT('.'):
                         CHECK_PREC
-                        in_prec = TRUE;
-                        prec_dot = FALSE;
+                        in_prec = true;
+                        prec_dot = false;
                         max_width = 0;
                         // dot will be auto-added to s_szFlags if non-negative
                         // number follows
@@ -372,7 +372,7 @@ int WXDLLEXPORT wxVsnprintf_(wxChar *buf, size_t lenMax,
                             APPEND_STR(tmp);
                         }
 
-                        done = TRUE;
+                        done = true;
                         break;
 
                     case wxT('e'):
@@ -400,7 +400,7 @@ int WXDLLEXPORT wxVsnprintf_(wxChar *buf, size_t lenMax,
                             APPEND_STR(tmp);
                         }
 
-                        done = TRUE;
+                        done = true;
                         break;
 
                     case wxT('p'):
@@ -415,7 +415,7 @@ int WXDLLEXPORT wxVsnprintf_(wxChar *buf, size_t lenMax,
                                 wxConvLibc.cMB2WX(szScratch);
                             APPEND_STR(tmp);
 
-                            done = TRUE;
+                            done = true;
                         }
                         break;
 
@@ -447,7 +447,7 @@ int WXDLLEXPORT wxVsnprintf_(wxChar *buf, size_t lenMax,
                                 for (i = 1; i < min_width; i++)
                                     APPEND_CH(_T(' '));
 
-                            done = TRUE;
+                            done = true;
                         }
                         break;
 
@@ -517,7 +517,7 @@ int WXDLLEXPORT wxVsnprintf_(wxChar *buf, size_t lenMax,
                                 for (i = len; i < min_width; i++)
                                     APPEND_CH(_T(' '));
 
-                            done = TRUE;
+                            done = true;
                         }
                         break;
 
@@ -537,14 +537,14 @@ int WXDLLEXPORT wxVsnprintf_(wxChar *buf, size_t lenMax,
                             long int *val = va_arg(argptr, long int *);
                             *val = lenCur;
                         }
-                        done = TRUE;
+                        done = true;
                         break;
 
                     default:
                         // bad format, leave unchanged
                         APPEND_CH(_T('%'));
                         APPEND_CH(ch);
-                        done = TRUE;
+                        done = true;
                         break;
                 }
             }
@@ -604,23 +604,23 @@ int WXDLLEXPORT wxSnprintf_(wxChar *buf, size_t len, const wxChar *format, ...)
 // implement the standard IO functions for wide char if libc doesn't have them
 // ----------------------------------------------------------------------------
 
-#ifdef wxNEED_FPUTWC
-
+#ifdef wxNEED_FPUTS
 int wxFputs(const wchar_t *ws, FILE *stream)
 {
     // counting the number of wide characters written isn't worth the trouble,
     // simply distinguish between ok and error
     return fputs(wxConvLibc.cWC2MB(ws), stream) == -1 ? -1 : 0;
 }
+#endif // wxNEED_FPUTS
 
+#ifdef wxNEED_PUTC
 int /* not wint_t */ wxPutc(wchar_t wc, FILE *stream)
 {
     wchar_t ws[2] = { wc, L'\0' };
 
     return wxFputs(ws, stream);
 }
-
-#endif // wxNEED_FPUTWC
+#endif // wxNEED_PUTC
 
 // NB: we only implement va_list functions here, the ones taking ... are
 //     defined below for wxNEED_PRINTF_CONVERSION case anyhow and we reuse
@@ -1329,36 +1329,16 @@ long     WXDLLEXPORT wxAtol(const wxChar *psz)
 
 wxChar * WXDLLEXPORT wxGetenv(const wxChar *name)
 {
-  static wxHashTable env;
-
-  // check if we already have stored the converted env var
-  wxObject *data = env.Get(name);
-  if (!data)
-  {
-    // nope, retrieve it,
-#if wxUSE_UNICODE
-    wxCharBuffer buffer = wxConvLocal.cWX2MB(name);
-    // printf( "buffer %s\n", (const char*) buffer );
-    const char *val = getenv( (const char *)buffer );
-#else
-    const char *val = getenv( name );
-#endif
-
-    if (!val) return (wxChar *)NULL;
-    // printf( "home %s\n", val );
-
-    // convert it,
 #if wxUSE_UNICODE
-    data = (wxObject *)new wxString(val, wxConvLocal);
+    // NB: buffer returned by getenv() is allowed to be overwritten next
+    //     time getenv() is called, so it is OK to use static string
+    //     buffer to hold the data.
+    static wxWCharBuffer value((wxChar*)NULL);
+    value = wxConvLocal.cMB2WX(getenv(wxConvLocal.cWX2MB(name)));
+    return value.data();
 #else
-    data = (wxObject *)new wxString(val);
+    return getenv(name);
 #endif
-
-    // and store it
-    env.Put(name, data);
-  }
-  // return converted env var
-  return (wxChar *)((wxString *)data)->c_str();
 }
 
 int WXDLLEXPORT wxSystem(const wxChar *psz)