gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r10124: Reinstate substring searchin


From: Bastiaan Jacques
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r10124: Reinstate substring searching method overzealously removed and fix its
Date: Mon, 27 Oct 2008 03:28:31 +0100
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 10124
committer: Bastiaan Jacques <address@hidden>
branch nick: trunk
timestamp: Mon 2008-10-27 03:28:31 +0100
message:
  Reinstate substring searching method overzealously removed and fix its
  documentation to be accurate. Update testcase (which is the only user).
modified:
  libamf/buffer.cpp
  libamf/buffer.h
  testsuite/libamf.all/test_buffer.cpp
=== modified file 'libamf/buffer.cpp'
--- a/libamf/buffer.cpp 2008-10-27 02:12:41 +0000
+++ b/libamf/buffer.cpp 2008-10-27 02:28:31 +0000
@@ -507,6 +507,18 @@
      return false;
 }
 
+Network::byte_t *
+Buffer::find(Network::byte_t *b, size_t size)
+{
+//    GNASH_REPORT_FUNCTION;
+    for (size_t i=0; i< _nbytes; i++) {
+       if (memcmp((_data.get() + i), b, size) == 0) {
+           return _data.get() + i;
+       }
+    }
+    return 0;
+}
+
 /// \brief Drop a byte without resizing.
 ///            This will remove the byte from the Buffer, and then
 ///            move the remaining data to be in the correct

=== modified file 'libamf/buffer.h'
--- a/libamf/buffer.h   2008-10-27 02:12:41 +0000
+++ b/libamf/buffer.h   2008-10-27 02:28:31 +0000
@@ -234,6 +234,15 @@
     /// @return A reference to a Buffer.
     Buffer &operator+=(bool);
     
+    /// \brief Find a set of bytes in the buffer
+    ///
+    /// @param byte The bytes to find in the buffer.
+    ///
+    /// @param size The size of the bytes being searched for.
+    ///
+    /// @return A real pointer to the address of the byte in the buffer.
+    gnash::Network::byte_t *find(gnash::Network::byte_t *byte, size_t size);
+    
     /// \brief Drop a byte without resizing.
     ///                This will remove the byte from the Buffer, and then
     ///                move the remaining data to be in the correct

=== modified file 'testsuite/libamf.all/test_buffer.cpp'
--- a/testsuite/libamf.all/test_buffer.cpp      2008-09-21 16:18:07 +0000
+++ b/testsuite/libamf.all/test_buffer.cpp      2008-10-27 02:28:31 +0000
@@ -329,7 +329,7 @@
     delete[] data;
     
     // See if we can find a character
-    Network::byte_t *fptr = buf1.find('c');
+    Network::byte_t *fptr = std::find(buf1.begin(), buf1.end(), 'c'); 
     if (fptr == (ptr1 + 2)) {
          runtest.pass ("Buffer::find(Network::byte_t)");
     } else {


reply via email to

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