Revision: 7335
          http://mahogany.svn.sourceforge.net/mahogany/?rev=7335&view=rev
Author:   vadz
Date:     2007-08-24 15:35:19 -0700 (Fri, 24 Aug 2007)

Log Message:
-----------
use string iterators instead of char to iterate correctly on Unicode string 
characters

Modified Paths:
--------------
    trunk/M/src/util/strutil.cpp

Modified: trunk/M/src/util/strutil.cpp
===================================================================
--- trunk/M/src/util/strutil.cpp        2007-08-24 18:27:43 UTC (rev 7334)
+++ trunk/M/src/util/strutil.cpp        2007-08-24 22:35:19 UTC (rev 7335)
@@ -1270,31 +1270,31 @@
 wxArrayString strutil_restore_array(const String& str, wxChar chSep)
 {
    wxArrayString array;
+
    if ( !str.empty() )
    {
       String s;
-      for ( const wxChar *p = str.c_str(); ; p++ )
+      for ( String::const_iterator p = str.begin(), end = str.end(); ; ++p )
       {
-         if ( *p == _T('\\') )
+         if ( p == end || *p == chSep )
          {
-            // 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 )
+            array.Add(s);
+
+            if ( p == end )
                break;
 
-            s += ch;
+            s.clear();
          }
-         else if ( *p == chSep || *p == _T('\0') )
+         else if ( *p == _T('\\') )
          {
-            array.Add(s);
-
-            if ( *p == _T('\0') )
+            // skip the backslash and treat the next character literally,
+            // whatever it is -- but take care to not overrun the string end
+            if ( ++p == str.end() )
                break;
 
-            s.clear();
+            s += *p;
          }
-         else
+         else // normal character
          {
             s += *p;
          }
@@ -1315,10 +1315,12 @@
       if ( n > 0 )
          s += chSep;
 
-      const wxChar *p = array[n].c_str();
-      while ( *p )
+      for ( String::const_iterator p = array[n].begin(),
+                                 end = array[n].end();
+            p != end;
+            ++p )
       {
-         const char ch = *p++;
+         const wxChar ch = *p;
 
          // escape the separator characters
          if ( ch == chSep || ch == '\\' )


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Mahogany-cvsupdates mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to