Author: suokko
Date: Wed May 28 11:48:00 2008
New Revision: 26898

URL: http://svn.gna.org/viewcvs/wesnoth?rev=26898&view=rev
Log:
Fixed tokenizer not to strip CR from quoted string becaue it would destroy 
images transfered over network

Modified:
    trunk/changelog
    trunk/src/serialization/tokenizer.cpp
    trunk/src/serialization/tokenizer.hpp

Modified: trunk/changelog
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=26898&r1=26897&r2=26898&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Wed May 28 11:48:00 2008
@@ -87,6 +87,8 @@
    * dissallow_observers is on as default if side has controller=null
    * Fixed null-pointer reference in network code
    * Made networking code check system buffer size and limit send length
+   * Fixed tokenizer not to strip CR from quoted string becaue it would
+     destroy images transfered over network
    * Added possibility to use per fight EV statistics proposed by maboul
    * Added smoother FPS limit to server
    * Fixed a mememory leak in networking code

Modified: trunk/src/serialization/tokenizer.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/serialization/tokenizer.cpp?rev=26898&r1=26897&r2=26898&view=diff
==============================================================================
--- trunk/src/serialization/tokenizer.cpp (original)
+++ trunk/src/serialization/tokenizer.cpp Wed May 28 11:48:00 2008
@@ -146,7 +146,10 @@
        case '"':
                token_.type = token::QSTRING;
                while (1) {
-                       next_char();
+                       /** Have to use next_char_no_strip 
+                        * because we will break image ifwe do striping
+                        **/
+                       next_char_no_strip();
 
                        if(current_ == EOF) {
                                token_.type = token::UNTERMINATED_QSTRING;
@@ -155,10 +158,10 @@
                        if(current_ == '"' && peek_char() != '"')
                                break;
                        if(current_ == '"' && peek_char() == '"')
-                               next_char_fast();
+                               next_char_fast_no_strip();
                        if (current_ == 254 && 
                                        (peek_char() == 'l' || peek_char() == 
't')) {
-                               next_char_fast();
+                               next_char_fast_no_strip();
                                if ((current_ == 'l' && peek_char() == 'i') || 
(current_ == 't' && peek_char() == 'e'))
                                {
                                        skip_comment();

Modified: trunk/src/serialization/tokenizer.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/serialization/tokenizer.hpp?rev=26898&r1=26897&r2=26898&view=diff
==============================================================================
--- trunk/src/serialization/tokenizer.hpp (original)
+++ trunk/src/serialization/tokenizer.hpp Wed May 28 11:48:00 2008
@@ -71,6 +71,26 @@
        int current_;
        size_t lineno_;
 
+       inline void next_char_no_strip()
+       {
+               if (UNLIKELY(current_ == '\n'))
+                       lineno_++;
+               this->next_char_fast_no_strip();
+       }
+
+       inline void next_char_fast_no_strip()
+       {
+               if (LIKELY(in_.good()))
+               {
+                       current_ = in_.get();
+               }
+               else
+               {
+                       current_ = EOF;
+                       return;
+               }
+       }
+
        inline void next_char()
        {
                if (UNLIKELY(current_ == '\n'))


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to