From f93dfcfefe402a68f0afdd82e307188ab3394921 Mon Sep 17 00:00:00 2001 From: kervala Date: Wed, 6 Apr 2016 09:29:37 +0200 Subject: [PATCH] Changed: Minor changes --- code/nel/include/nel/gui/ctrl_draggable.h | 2 +- code/nel/include/nel/gui/interface_parser.h | 4 +- code/nel/include/nel/gui/widget_manager.h | 2 +- code/nel/src/gui/ctrl_button.cpp | 3 +- code/nel/src/gui/group_html.cpp | 10 +- code/nel/src/gui/group_html_parser.cpp | 96 ++++++++++++++------ code/nel/src/misc/bitmap_gif.cpp | 3 +- code/ryzom/common/src/game_share/task_list.h | 2 +- 8 files changed, 87 insertions(+), 35 deletions(-) diff --git a/code/nel/include/nel/gui/ctrl_draggable.h b/code/nel/include/nel/gui/ctrl_draggable.h index 3f625db1d..22ace71e0 100644 --- a/code/nel/include/nel/gui/ctrl_draggable.h +++ b/code/nel/include/nel/gui/ctrl_draggable.h @@ -29,7 +29,7 @@ namespace NLGUI DECLARE_UI_CLASS( CCtrlDraggable ) CCtrlDraggable( const TCtorParam ¶m ); - virtual ~CCtrlDraggable(){}; + virtual ~CCtrlDraggable(){} static CCtrlDraggable *getDraggedSheet(){ return _LastDraggedSheet; } bool isDragged() const{ return dragged; } diff --git a/code/nel/include/nel/gui/interface_parser.h b/code/nel/include/nel/gui/interface_parser.h index 18ec9045a..0a2d107fb 100644 --- a/code/nel/include/nel/gui/interface_parser.h +++ b/code/nel/include/nel/gui/interface_parser.h @@ -72,10 +72,12 @@ namespace NLGUI GroupChildren = 4 /// module can parse when parsing the group children }; - IParserModule(){ + IParserModule() + { parser = NULL; parsingStage = None; } + virtual ~IParserModule(){} bool canParseInStage( ParsingStage stage ) diff --git a/code/nel/include/nel/gui/widget_manager.h b/code/nel/include/nel/gui/widget_manager.h index 9d8ff060e..cfb51af8e 100644 --- a/code/nel/include/nel/gui/widget_manager.h +++ b/code/nel/include/nel/gui/widget_manager.h @@ -71,7 +71,7 @@ namespace NLGUI class IOnWidgetsDrawnHandler { public: - virtual ~IOnWidgetsDrawnHandler(){}; + virtual ~IOnWidgetsDrawnHandler(){} virtual void process() = 0; }; diff --git a/code/nel/src/gui/ctrl_button.cpp b/code/nel/src/gui/ctrl_button.cpp index bc54003da..d689dd71c 100644 --- a/code/nel/src/gui/ctrl_button.cpp +++ b/code/nel/src/gui/ctrl_button.cpp @@ -40,7 +40,8 @@ namespace NLGUI { char c = toLower( s[ i ] ); - switch( c ){ + switch( c ) + { case 'l': _Align &= ~1; break; diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index 1b5e36964..2c225b3ce 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -5882,9 +5882,11 @@ namespace NLGUI { const char* digits = (Type == "I" ? upper : lower); uint8 i, d=0; - do { + do + { uint32 num = number % 10; - if (num % 5 < 4){ + if (num % 5 < 4) + { for (i = num % 5; i > 0; i--) { ret.insert(ret.begin(), digits[d]); @@ -5904,7 +5906,9 @@ namespace NLGUI } number /= 10; d += 2; - } while (number > 0); + } + while (number > 0); + if (Type == "I") { ret = toUpper(ret); diff --git a/code/nel/src/gui/group_html_parser.cpp b/code/nel/src/gui/group_html_parser.cpp index 260e6a96f..de96a63ea 100644 --- a/code/nel/src/gui/group_html_parser.cpp +++ b/code/nel/src/gui/group_html_parser.cpp @@ -121,69 +121,112 @@ namespace NLGUI // *************************************************************************** // http://stackoverflow.com/a/18335183 - static std::string correct_non_utf_8(const std::string &str) + static std::string correctNonUtf8(const std::string &str) { - int i,f_size=str.size(); + int i, f_size=str.size(); unsigned char c,c2,c3,c4; std::string to; to.reserve(f_size); - for(i=0 ; i127 && c2<192){//valid 2byte UTF8 - if(c==194 && c2<160){//control char, skipping + } + else if (c < 224 && i + 1 < f_size) + { + //possibly 2byte UTF8 + c2 = (unsigned char)(str[i+1]); + + if (c2 > 127 && c2 < 192) + { + //valid 2byte UTF8 + if (c == 194 && c2 < 160) + { + //control char, skipping ; - }else{ + } + else + { to.append(1,c); to.append(1,c2); } i++; continue; } - }else if(c<240 && i+2127 && c2<192 && c3>127 && c3<192){//valid 3byte UTF8 + } + else if (c < 240 && i + 2 < f_size) + { + // possibly 3byte UTF8 + c2 = (unsigned char)(str[i+1]); + c3 = (unsigned char)(str[i+2]); + + if (c2 > 127 && c2 < 192 && c3 > 127 && c3 < 192) + { + // valid 3byte UTF8 to.append(1,c); to.append(1,c2); to.append(1,c3); i+=2; continue; } - }else if(c<245 && i+3127 && c2<192 && c3>127 && c3<192 && c4>127 && c4<192){//valid 4byte UTF8 + } + else if (c < 245 && i + 3 < f_size) + { + //possibly 4byte UTF8 + c2 = (unsigned char)(str[i+1]); + c3 = (unsigned char)(str[i+2]); + c4 = (unsigned char)(str[i+3]); + if (c2 > 127 && c2 < 192 && c3 > 127 && c3 < 192 && c4 > 127 && c4 < 192) + { + //valid 4byte UTF8 to.append(1,c); to.append(1,c2); to.append(1,c3); @@ -192,6 +235,7 @@ namespace NLGUI continue; } } + //invalid UTF8, converting ASCII (c>245 || string too short for multi-byte)) to.append(1,(unsigned char)195); to.append(1,c-64); @@ -250,7 +294,7 @@ namespace NLGUI } // if there is invalid utf-8 chars, then libxml will break everything after first it finds. - htmlString = correct_non_utf_8(htmlString); + htmlString = correctNonUtf8(htmlString); } // *************************************************************************** diff --git a/code/nel/src/misc/bitmap_gif.cpp b/code/nel/src/misc/bitmap_gif.cpp index 30e8b652c..4ae9dd0cf 100644 --- a/code/nel/src/misc/bitmap_gif.cpp +++ b/code/nel/src/misc/bitmap_gif.cpp @@ -49,7 +49,8 @@ static uint8 INTERLACED_OFFSET[] = { 0, 4, 2, 1 }; static uint8 INTERLACED_JUMP[] = { 8, 8, 4, 2 }; #endif -static int readGIFData(GifFileType *gif, GifByteType *data, int length){ +static int readGIFData(GifFileType *gif, GifByteType *data, int length) +{ NLMISC::IStream *f = static_cast(gif->UserData); if(!f->isReading()) return 0; diff --git a/code/ryzom/common/src/game_share/task_list.h b/code/ryzom/common/src/game_share/task_list.h index 3ac764ad8..b939d8bfa 100644 --- a/code/ryzom/common/src/game_share/task_list.h +++ b/code/ryzom/common/src/game_share/task_list.h @@ -99,7 +99,7 @@ public: void addTaskAt(T t, CTask* task) { task->setTime(t); _Tasks.push_back(task);_Clean = false; } uint32 getSize() const { return (uint32)_Tasks.size(); } CTask* getTaskAt(uint32 index) const { nlassert( index < _Tasks.size()); return _Tasks[index].getTask();} - void removeTaskAt(uint32 index){ nlassert( index < _Tasks.size()); _Tasks.erase(_Tasks.begin() + index); }; + void removeTaskAt(uint32 index){ nlassert( index < _Tasks.size()); _Tasks.erase(_Tasks.begin() + index); } // Waiting task are discared