]> git.saurik.com Git - wxWidgets.git/blobdiff - user/wxLayout/wxlparser.cpp
corrected (?) wxStringList::Delete()
[wxWidgets.git] / user / wxLayout / wxlparser.cpp
index 90d92e91569f7abd90f16b6df6c2b451b68507dd..17900885177c2fffd370d57f27cb784af49ba70c 100644 (file)
 #   pragma implementation "wxlparser.h"
 #endif
 
-#include   "wxllist.h"
-#include   "wxlparser.h"
+//#include "Mpch.h"
+#ifdef M_BASEDIR
+#   include "gui/wxllist.h"
+#   include "gui/wxlparser.h"
+#else
+#   include "wxllist.h"
+#   include "wxlparser.h"
+#endif
 
 #define   BASE_SIZE 12
 
-void wxLayoutImportText(wxLayoutList &list, wxString const &str)
+inline static bool IsEndOfLine(const char *p)
+{
+   // in addition to Unix EOL convention we also (but not instead) understand
+   // the DOS one under Windows
+   return
+#ifdef OS_WIN
+      ((*p == '\r') && (*(p + 1) == '\n')) ||
+#endif
+      (*p == '\n');
+}
+
+void wxLayoutImportText(wxLayoutList &list, String const &str)
 {
    char * cptr = (char *)str.c_str(); // string gets changed only temporarily
    const char * begin = cptr;
@@ -23,15 +40,22 @@ void wxLayoutImportText(wxLayoutList &list, wxString const &str)
    
    for(;;)
    {
-      begin = cptr++;
-      while(*cptr && *cptr != '\n')
+      begin = cptr;
+      while( *cptr && !IsEndOfLine(cptr) )
          cptr++;
       backup = *cptr;
       *cptr = '\0';
       list.Insert(begin);
       *cptr = backup;
-      if(backup == '\n')
+
+      // check if it's the end of this line
+      if ( IsEndOfLine(cptr) )
+      {
+         // if it was "\r\n", skip the following '\n'
+         if ( *cptr == '\r' )
+            cptr++;
          list.LineBreak();
+      }
       else if(backup == '\0') // reached end of string
          break;
       cptr++;
@@ -39,11 +63,11 @@ void wxLayoutImportText(wxLayoutList &list, wxString const &str)
 }
 
 static
-wxString wxLayoutExportCmdAsHTML(wxLayoutObjectCmd const & cmd,
+String wxLayoutExportCmdAsHTML(wxLayoutObjectCmd const & cmd,
                                  wxLayoutStyleInfo **lastStylePtr)
 {
    static char buffer[20];
-   wxString html;
+   String html;
    
    wxLayoutStyleInfo *si = cmd.GetStyle();
    wxLayoutStyleInfo *last_si = NULL;
@@ -152,7 +176,7 @@ wxString wxLayoutExportCmdAsHTML(wxLayoutObjectCmd const & cmd,
       return export;
    }
 
-   wxString *str = new wxString();
+   String *str = new String();
    
    // text must be concatenated
    while(from != list.end() && WXLO_IS_TEXT(type))
@@ -168,8 +192,9 @@ wxString wxLayoutExportCmdAsHTML(wxLayoutObjectCmd const & cmd,
          *str += '\n';
          break;
       case WXLO_TYPE_CMD:
-         //wxASSERT(mode == WXLO_EXPORT_AS_HTML,"reached cmd object in text mode")
-         assert(mode == WXLO_EXPORT_AS_HTML);
+         wxASSERT_MSG( mode == WXLO_EXPORT_AS_HTML,
+                       "reached cmd object in text mode" );
+         
          *str += wxLayoutExportCmdAsHTML(*(wxLayoutObjectCmd const
                                            *)*from, &s_si);
          break;