From 8f19c916dcf4b31d40b386c5f85a95d511241693 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Sun, 12 Mar 2000 11:29:13 +0000 Subject: [PATCH] Made iniconf compile on BC++ 5.01 (involved adding Set... accessors to wxConfigBase); 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 | 3 +++ src/msw/iniconf.cpp | 13 +++++++++-- utils/dialoged/src/reswrite.cpp | 40 ++++++++++++++++++++++++--------- 3 files changed, 43 insertions(+), 13 deletions(-) diff --git a/include/wx/confbase.h b/include/wx/confbase.h index fb9f8f7127..840b5ed9a7 100644 --- a/include/wx/confbase.h +++ b/include/wx/confbase.h @@ -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; } diff --git a/src/msw/iniconf.cpp b/src/msw/iniconf.cpp index e65785791d..cc177eab52 100644 --- a/src/msw/iniconf.cpp +++ b/src/msw/iniconf.cpp @@ -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()) { diff --git a/utils/dialoged/src/reswrite.cpp b/utils/dialoged/src/reswrite.cpp index 3959269ab0..ba22dfe885 100644 --- a/utils/dialoged/src/reswrite.cpp +++ b/utils/dialoged/src/reswrite.cpp @@ -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; + } } -- 2.47.2