X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a5f81d8c07022c086723a587488750ef055439e3..f0824a5a4a255989b5153945ade9e21232724980:/user/wxLayout/wxlparser.cpp diff --git a/user/wxLayout/wxlparser.cpp b/user/wxLayout/wxlparser.cpp index 90d92e9156..1790088517 100644 --- a/user/wxLayout/wxlparser.cpp +++ b/user/wxLayout/wxlparser.cpp @@ -10,12 +10,29 @@ # 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;