gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/parser/movie_def_impl.cp...


From: Benjamin Wolsey
Subject: [Gnash-commit] gnash ChangeLog server/parser/movie_def_impl.cp...
Date: Mon, 02 Jun 2008 13:40:51 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Benjamin Wolsey <bwy>   08/06/02 13:40:50

Modified files:
        .              : ChangeLog 
        server/parser  : movie_def_impl.cpp 
        libbase        : log.cpp 

Log message:
                * server/movie_def_impl.cpp: use hexify() to format tag dumps - 
it
                  takes a useful length parameter that avoids writing 
uninitialized
                  values. Read more than a single byte at a time from the 
stream and
                  check return of read().
                * libbase/log.cpp: adapt hexify so it can be used in 
movie_def_impl
                  (not printing newlines, using '.' instead of '^' for non-print
                  characters).
        
                I hope the changes to hexify don't inconvenience anyone (it is
                mainly used for debugging) - if printing a newline is necessary,
                I'll have to find another solution.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6774&r2=1.6775
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/movie_def_impl.cpp?cvsroot=gnash&r1=1.113&r2=1.114
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/log.cpp?cvsroot=gnash&r1=1.77&r2=1.78

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6774
retrieving revision 1.6775
diff -u -b -r1.6774 -r1.6775
--- ChangeLog   2 Jun 2008 12:51:07 -0000       1.6774
+++ ChangeLog   2 Jun 2008 13:40:49 -0000       1.6775
@@ -1,5 +1,15 @@
 2008-06-02 Benjamin Wolsey <address@hidden>
 
+       * server/movie_def_impl.cpp: use hexify() to format tag dumps - it
+         takes a useful length parameter that avoids writing uninitialized
+         values. Read more than a single byte at a time from the stream and
+         check return of read().
+       * libbase/log.cpp: adapt hexify so it can be used in movie_def_impl
+         (not printing newlines, using '.' instead of '^' for non-print
+         characters).
+
+2008-06-02 Benjamin Wolsey <address@hidden>
+
        * server/asobj/NetStreamFfmpeg.cpp: gnash.h for get_sound_handler().
 
 2008-06-02 Benjamin Wolsey <address@hidden>

Index: server/parser/movie_def_impl.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/parser/movie_def_impl.cpp,v
retrieving revision 1.113
retrieving revision 1.114
diff -u -b -r1.113 -r1.114
--- server/parser/movie_def_impl.cpp    30 May 2008 20:23:50 -0000      1.113
+++ server/parser/movie_def_impl.cpp    2 Jun 2008 13:40:50 -0000       1.114
@@ -155,35 +155,29 @@
 //
 
 /// Log the contents of the current tag, in hex to the output strream
-static void    dump_tag_bytes(stream* in, std::ostream& os)
+static void    dumpTagBytes(stream* in, std::ostream& os)
 {
-    static const int   ROW_BYTES = 16;
-    char       row_buf[ROW_BYTES];
-    int        row_count = 0;
+    const unsigned int rowlength = 16;
+    os << std::endl;
 
-    row_buf[ROW_BYTES-1] = '\0';
+    // This decremented until we reach the end of the stream.
+    unsigned int toread = in->get_tag_end_position() - in->get_position();
+    in->ensureBytes(toread);
 
-    os << std::endl;
-    while(in->get_position() < in->get_tag_end_position())
+    unsigned char buf[rowlength];    
+    while (toread)
     {
-            int        c = in->read_u8();
-            os << std::hex << std::setw(2) << std::setfill('0') << c << " ";
+        // Read in max row length or remainder of stream.
+        unsigned int got = in->read(reinterpret_cast<char*>(&buf),
+                                    std::min<unsigned>(toread, rowlength));
 
-            if (c < 32 || c > 127 ) c = '.';
-            row_buf[row_count] = c;
+        // Stream once as hex
+        os << std::left << std::setw(3 * rowlength) << hexify(buf, got, false);
 
-            row_count++;
-            if (row_count >= ROW_BYTES)
-            {
-                    os << row_buf << std::endl;
-                    row_count = 0;
-            }
-   }
-   if ( row_count )
-   {
-            row_buf[row_count] = '\0';
-            while (row_count++ < ROW_BYTES ) os << "   ";
-            os << row_buf << std::endl;
+        // and once as ASCII
+        os << "| " << hexify(buf, got, true) << std::endl;
+
+        toread -= got;
    }
 }
 
@@ -211,7 +205,6 @@
 
 movie_def_impl::~movie_def_impl()
 {
-       //cout << "movie_def_impl dtor called" << endl;
 
        // Request cancelation of the loading thread
        _loadingCanceled = true;
@@ -669,7 +662,7 @@
                                tag_type);
                        IF_VERBOSE_PARSE(
                                std::stringstream ss;
-                               dump_tag_bytes(&str, ss);
+                               dumpTagBytes(&str, ss);
                                log_error("tag dump follows: %s", ss.str());
                        );
                }

Index: libbase/log.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/log.cpp,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -b -r1.77 -r1.78
--- libbase/log.cpp     27 May 2008 09:55:26 -0000      1.77
+++ libbase/log.cpp     2 Jun 2008 13:40:50 -0000       1.78
@@ -63,10 +63,10 @@
             i != e; ++i)
            {
                if (ascii) {
-                   if (std::isprint(*i) || *i == 0xd || *i == 0xa) {
+                   if (std::isprint(*i) || *i == 0xd) {
                        ss << *i;
                    }
-                   else ss << "^";
+                   else ss << ".";
                }
                else  {
                    // Not ascii




reply via email to

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