gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ChangeLog libbase/utf8.cpp libbase/utf8.h...


From: Benjamin Wolsey
Subject: [Gnash-commit] gnash ChangeLog libbase/utf8.cpp libbase/utf8.h...
Date: Mon, 28 Apr 2008 07:51:05 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Benjamin Wolsey <bwy>   08/04/28 07:51:05

Modified files:
        .              : ChangeLog 
        libbase        : utf8.cpp utf8.h 
        server/vm      : ASHandlers.cpp 

Log message:
                * libbase/utf8.{cpp,h}: decodeNextUnicodeCharacter should know
                  where the end of the string is, so it doesn't deference 
                  .end() (thanks zou).
                * server/vm/ASHanders.cpp: pass end of string iterator to 
                  decodeNextUnicodeCharacter, cache value generally to save 
repeated
                  calls to .end().

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6425&r2=1.6426
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/utf8.cpp?cvsroot=gnash&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/utf8.h?cvsroot=gnash&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/ASHandlers.cpp?cvsroot=gnash&r1=1.232&r2=1.233

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6425
retrieving revision 1.6426
diff -u -b -r1.6425 -r1.6426
--- ChangeLog   28 Apr 2008 06:44:50 -0000      1.6425
+++ ChangeLog   28 Apr 2008 07:51:03 -0000      1.6426
@@ -1,3 +1,12 @@
+2008-04-27 Benjamin Wolsey <address@hidden>
+
+       * libbase/utf8.{cpp,h}: decodeNextUnicodeCharacter should know
+         where the end of the string is, so it doesn't deference 
+         .end() (thanks zou).
+       * server/vm/ASHanders.cpp: pass end of string iterator to 
+         decodeNextUnicodeCharacter, cache value generally to save repeated
+         calls to .end().
+
 2008-04-28 Zou Lunkai <address@hidden>
        
        * server/swf/DisplayListTag.h: isRmove(), isPlace(), isReplace(), 
isMove(),

Index: libbase/utf8.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/utf8.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- libbase/utf8.cpp    17 Apr 2008 08:05:36 -0000      1.11
+++ libbase/utf8.cpp    28 Apr 2008 07:51:04 -0000      1.12
@@ -33,11 +33,11 @@
        
        std::wstring wstr = L"";
        
-       std::string::const_iterator it = str.begin();
+       std::string::const_iterator it = str.begin(), e = str.end();
        
        if (version > 5)
        {
-               while (boost::uint32_t code = decodeNextUnicodeCharacter(it))
+               while (boost::uint32_t code = decodeNextUnicodeCharacter(it, e))
                {
                    if (code == utf8::invalid)
                    {
@@ -88,7 +88,8 @@
 
 
 boost::uint32_t
-utf8::decodeNextUnicodeCharacter(std::string::const_iterator& it)
+utf8::decodeNextUnicodeCharacter(std::string::const_iterator& it,
+                                 const std::string::const_iterator& e)
 {
        boost::uint32_t uc;
 
@@ -112,12 +113,12 @@
 
 #define NEXT_BYTE(shift)                                               \
                                        \
-       if (*it == 0) return 0; /* end of buffer, do not advance */     \
+       if (it == e || *it == 0) return 0; /* end of buffer, do not advance */  
\
        if ((*it & 0xC0) != 0x80) return utf8::invalid; /* standard check */    
\
        /* Post-increment iterator: */          \
        uc |= (*it++ & 0x3F) << shift;
 
-       if (*it == 0) return 0; // End of buffer.  Do not advance.
+       if (it == e || *it == 0) return 0;      // End of buffer.  Do not 
advance.
 
        // Conventional 7-bit ASCII; return and increment iterator:
        if ((*it & 0x80) == 0) return (boost::uint32_t) *it++;

Index: libbase/utf8.h
===================================================================
RCS file: /sources/gnash/gnash/libbase/utf8.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- libbase/utf8.h      17 Apr 2008 08:22:36 -0000      1.18
+++ libbase/utf8.h      28 Apr 2008 07:51:04 -0000      1.19
@@ -84,7 +84,8 @@
        /// as output.  Advances string iterator past the character
        /// returned, unless the returned character is '\0', in which
        /// case the iterator does not advance.
-       DSOEXPORT boost::uint32_t 
decodeNextUnicodeCharacter(std::string::const_iterator& it);
+       DSOEXPORT boost::uint32_t 
decodeNextUnicodeCharacter(std::string::const_iterator& it,
+                                                            const 
std::string::const_iterator& e);
 
        /// \brief Encodes the given wide character into a canonical
        /// string, theoretically up to 6 chars in length.

Index: server/vm/ASHandlers.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/vm/ASHandlers.cpp,v
retrieving revision 1.232
retrieving revision 1.233
diff -u -b -r1.232 -r1.233
--- server/vm/ASHandlers.cpp    25 Apr 2008 10:01:34 -0000      1.232
+++ server/vm/ASHandlers.cpp    28 Apr 2008 07:51:04 -0000      1.233
@@ -1570,17 +1570,19 @@
     bool is_sought = true;
 
     std::string::const_iterator it = str.begin();
+    const std::string::const_iterator e = str.end();
+
     length = 0;
     
     // First, assume it's UTF8 and try to be wrong.
-    while (it != str.end() && is_sought)
+    while (it != e && is_sought)
     {
         ++length;
 
         offsets.push_back(it - str.begin()); // current position
 
         // Advances the iterator to point to the next 
-        boost::uint32_t c = utf8::decodeNextUnicodeCharacter(it);
+        boost::uint32_t c = utf8::decodeNextUnicodeCharacter(it, e);
 
         if (c == utf8::invalid)
         {
@@ -1591,7 +1593,7 @@
 
     offsets.push_back(it - str.begin()); // current position
 
-    if (it == str.end() && is_sought)
+    if (it == e && is_sought)
     {
         // No characters left, so it's almost certainly UTF8.
         return ENCGUESS_UNICODE;
@@ -1605,7 +1607,7 @@
     bool was_odd = true;
     bool was_even = true;
     // Now, assume it's SHIFT_JIS and try to be wrong.
-    while (it != str.end() && is_sought)
+    while (it != e && is_sought)
     {
         int c = static_cast<int> (*it);
 
@@ -1862,9 +1864,9 @@
 
     const std::string s = env.top(0).to_string();
     
-    std::string::const_iterator it = s.begin();
+    std::string::const_iterator it = s.begin(), e = s.end();
     
-    boost::uint32_t out = utf8::decodeNextUnicodeCharacter(it);
+    boost::uint32_t out = utf8::decodeNextUnicodeCharacter(it, e);
     
     /// Always valid, or can it be undefined?
     env.top(0).set_int(out);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]