Update of /cvsroot/mahogany/M/src/util
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17497/src/util
Modified Files:
strutil.cpp
Log Message:
escape separator string in the array elements when flattening it (and unescape when
restoring); this fixes bug with (quick) filters containing colons in their names which
used to horribly confuse Mahogany
Index: strutil.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/util/strutil.cpp,v
retrieving revision 1.127
retrieving revision 1.128
diff -b -u -2 -r1.127 -r1.128
--- strutil.cpp 21 Jan 2004 12:13:33 -0000 1.127
+++ strutil.cpp 11 Mar 2004 20:13:33 -0000 1.128
@@ -1274,5 +1274,8 @@
// ----------------------------------------------------------------------------
-wxArrayString strutil_restore_array(const String& str, wxChar ch)
+// note that these functions don't work with strings containing NULs: this
+// shouldn't be a problem at all in practice however
+
+wxArrayString strutil_restore_array(const String& str, wxChar chSep)
{
wxArrayString array;
@@ -1282,9 +1285,19 @@
for ( const wxChar *p = str.c_str(); ; p++ )
{
- if ( *p == ch || *p == '\0' )
+ if ( *p == _T('\\') )
+ {
+ // skip the backslash and treat the next character literally,
+ // whatever it is -- but take care to not overrun the string end
+ const char ch = *++p;
+ if ( !ch )
+ break;
+
+ s += ch;
+ }
+ else if ( *p == chSep || *p == _T('\0') )
{
array.Add(s);
- if ( *p == '\0' )
+ if ( *p == _T('\0') )
break;
@@ -1301,13 +1314,26 @@
}
-String strutil_flatten_array(const wxArrayString& array, wxChar ch)
+String strutil_flatten_array(const wxArrayString& array, wxChar chSep)
{
String s;
- size_t count = array.GetCount();
+ s.reserve(1024);
+
+ const size_t count = array.GetCount();
for ( size_t n = 0; n < count; n++ )
{
if ( n > 0 )
+ s += chSep;
+
+ const wxChar *p = array[n].c_str();
+ while ( *p )
+ {
+ const char ch = *p++;
+
+ // escape the separator characters
+ if ( ch == chSep || ch == '\\' )
+ s += '\\';
+
s += ch;
- s += array[n];
+ }
}
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates