]> git.saurik.com Git - wxWidgets.git/commitdiff
Made iniconf compile on BC++ 5.01 (involved adding Set... accessors to wxConfigBase);
authorJulian Smart <julian@anthemion.co.uk>
Sun, 12 Mar 2000 11:29:13 +0000 (11:29 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Sun, 12 Mar 2000 11:29:13 +0000 (11:29 +0000)
added SafeWord patch to Dialog Editor

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6634 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/confbase.h
src/msw/iniconf.cpp
utils/dialoged/src/reswrite.cpp

index fb9f8f71275a114b38d930a493667b7375785f1e..840b5ed9a7b3c48b0ea4aa779cfaeb2181a0e331 100644 (file)
@@ -226,6 +226,9 @@ public:
     // misc accessors
   wxString GetAppName() const { return m_appName; }
   wxString GetVendorName() const { return m_vendorName; }
+  // Used wxIniConfig to set members in constructor
+  void SetAppName(const wxString& appName) { m_appName = appName; }
+  void SetVendorName(const wxString& vendorName) { m_vendorName = vendorName; }
 
   void SetStyle(long style) { m_style = style; }
   long GetStyle() const { return m_style; }
index e65785791dd66aefec0ebe347dcb8061677746d3..cc177eab522fe293a0632d4af626dc79940a28e0 100644 (file)
@@ -60,13 +60,22 @@ wxIniConfig::wxIniConfig(const wxString& strAppName,
                          const wxString& localFilename,
                          const wxString& globalFilename,
                          long style)
-           : wxConfigBase(!strAppName && wxTheApp ? wxTheApp->GetAppName()
+           : wxConfigBase(strAppName, strVendor, localFilename, globalFilename, style)
+
+#if 0 // This is too complex for some compilers, e.g. BC++ 5.01
+           : wxConfigBase((strAppName.IsEmpty() && wxTheApp) ? wxTheApp->GetAppName()
                                                : strAppName,
-                          !strVendor ? (wxTheApp ? wxTheApp->GetVendorName()
+                          strVendor.IsEmpty() ? (wxTheApp ? wxTheApp->GetVendorName()
                                                   : strAppName)
                                       : strVendor,
                           localFilename, globalFilename, style)
+#endif
 {
+    if (strAppName.IsEmpty() && wxTheApp)
+        SetAppName(wxTheApp->GetAppName());
+    if (strVendor.IsEmpty() && wxTheApp)
+        SetVendorName(wxTheApp->GetVendorName());
+
     m_strLocalFilename = localFilename;
     if (m_strLocalFilename.IsEmpty())
     {
index 3959269ab0fe25358829446ab4f049fff86ee6c5..ba22dfe8853ebf3ce13c5ad029a065724180580e 100644 (file)
@@ -108,7 +108,7 @@ bool wxResourceTableWithSaving::SaveResource(wxTextOutputStream& stream, wxItemR
       }
 
       stream << "  style = '" << styleBuf << "',\\\n";
-      stream << "  title = '" << item->GetTitle() << "',\\\n";
+      stream << "  title = " << SafeWord(item->GetTitle()) << ",\\\n";
       stream << "  id = " << item->GetId() << ",\\\n";
       stream << "  x = " << item->GetX() << ", y = " << item->GetY();
       stream << ", width = " << item->GetWidth() << ", height = " << item->GetHeight();
@@ -576,17 +576,35 @@ char *SafeString(const wxString& s)
   }
 }
 
-// Returns quoted string or ''
+// Returns quoted string or '' : convert " to \"
 char *SafeWord(const wxString& s)
 {
-  if (s == "")
-    return "''";
-  else
-  {
-    strcpy(wxBuffer, "'");
-    strcat(wxBuffer, (const char*) s);
-    strcat(wxBuffer, "'");
-    return wxBuffer;
-  }
+       const char *cp;
+       char *dp;
+
+       if (s == "")
+               return "''";
+       else
+       {
+               dp = wxBuffer;
+               cp = s.c_str();
+               *dp++ = '\'';
+               while(*cp != 0) {
+                       if(*cp == '"') {
+                               *dp++ = '\\';
+                               *dp++ = '"';
+                       } else if(*cp == '\'') {
+                               *dp++ = '\\';
+                               *dp++ = '\'';
+                       } else
+                               *dp++ = *cp;
+
+                       cp++;
+               }
+               *dp++ = '\'';
+               *dp++ = 0;
+
+               return wxBuffer;
+       }
 }