subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From julianf...@apache.org
Subject svn commit: r1130490 - in /subversion/trunk/subversion: include/svn_io.h libsvn_subr/stream.c
Date Thu, 02 Jun 2011 10:46:55 GMT
Author: julianfoad
Date: Thu Jun  2 10:46:55 2011
New Revision: 1130490

URL: http://svn.apache.org/viewvc?rev=1130490&view=rev
Log:
Change svn_stream_skip() so that if no skip handler is provided it will
still work by reading from the stream, and so remove three trivial handlers.

See email from Stefan Fuhrmann on 2011-06-02, subject "svn commit: r1072519
- Add svn_stream_skip(), svn_stream_buffered(), svn_stream_supports_mark()",
<http://svn.haxx.se/dev/archive-2011-06/0039.shtml>.

* subversion/include/svn_io.h
  (svn_stream_skip): Document the new semantics.

* subversion/libsvn_subr/stream.c
  (svn_stream_skip): If no skip handler is installed, use the default
    implementation.
  (skip_handler_empty, skip_handler_gz, skip_handler_checksum): Remove these
    skip handlers, as they are no different from the default.
  (svn_stream_empty, svn_stream_compressed, svn_stream_checksummed2): Don't
    install skip handlers, as the default is sufficient.

Modified:
    subversion/trunk/subversion/include/svn_io.h
    subversion/trunk/subversion/libsvn_subr/stream.c

Modified: subversion/trunk/subversion/include/svn_io.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_io.h?rev=1130490&r1=1130489&r2=1130490&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_io.h (original)
+++ subversion/trunk/subversion/include/svn_io.h Thu Jun  2 10:46:55 2011
@@ -1091,7 +1091,9 @@ svn_stream_read(svn_stream_t *stream,
  * other than that the stream read pointer will be advanced by *len
  * bytes. Depending on the capabilities of the underlying stream
  * implementation, this may for instance be translated into a sequence
- * of reads or a simple seek operation.
+ * of reads or a simple seek operation. If the stream implementation has
+ * not provided a skip function, this will read from the stream and
+ * discard the data.
  */
 svn_error_t *
 svn_stream_skip(svn_stream_t *stream,

Modified: subversion/trunk/subversion/libsvn_subr/stream.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/stream.c?rev=1130490&r1=1130489&r2=1130490&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/stream.c (original)
+++ subversion/trunk/subversion/libsvn_subr/stream.c Thu Jun  2 10:46:55 2011
@@ -57,6 +57,12 @@ struct svn_stream_t {
 };
 
 
+/*** Forward declarations. ***/
+
+static svn_error_t *
+skip_default_handler(void *baton, apr_size_t *count, svn_read_fn_t read_fn);
+
+
 /*** Generic streams. ***/
 
 svn_stream_t *
@@ -138,7 +144,9 @@ svn_stream_read(svn_stream_t *stream, ch
 svn_error_t *
 svn_stream_skip(svn_stream_t *stream, apr_size_t *len)
 {
-  SVN_ERR_ASSERT(stream->skip_fn != NULL);
+  if (stream->skip_fn == NULL)
+    return skip_default_handler(stream->baton, len, stream->read_fn);
+
   return stream->skip_fn(stream->baton, len);
 }
 
@@ -650,13 +658,6 @@ read_handler_empty(void *baton, char *bu
 }
 
 static svn_error_t *
-skip_handler_empty(void *baton, apr_size_t *count)
-{
-  *count = 0;
-  return SVN_NO_ERROR;
-}
-
-static svn_error_t *
 write_handler_empty(void *baton, const char *data, apr_size_t *len)
 {
   return SVN_NO_ERROR;
@@ -689,7 +690,6 @@ svn_stream_empty(apr_pool_t *pool)
 
   stream = svn_stream_create(NULL, pool);
   svn_stream_set_read(stream, read_handler_empty);
-  svn_stream_set_skip(stream, skip_handler_empty);
   svn_stream_set_write(stream, write_handler_empty);
   svn_stream_set_mark(stream, mark_handler_empty);
   svn_stream_set_seek(stream, seek_handler_empty);
@@ -1188,13 +1188,6 @@ read_handler_gz(void *baton, char *buffe
   return SVN_NO_ERROR;
 }
 
-/* Skip data from a compressed stream by reading and discarding it. */
-static svn_error_t *
-skip_handler_gz(void *baton, apr_size_t *count)
-{
-  return skip_default_handler(baton, count, read_handler_gz);
-}
-
 /* Compress data and write it to the substream */
 static svn_error_t *
 write_handler_gz(void *baton, const char *buffer, apr_size_t *len)
@@ -1308,7 +1301,6 @@ svn_stream_compressed(svn_stream_t *stre
 
   zstream = svn_stream_create(baton, pool);
   svn_stream_set_read(zstream, read_handler_gz);
-  svn_stream_set_skip(zstream, skip_handler_gz);
   svn_stream_set_write(zstream, write_handler_gz);
   svn_stream_set_close(zstream, close_handler_gz);
 
@@ -1351,13 +1343,6 @@ read_handler_checksum(void *baton, char 
 
 
 static svn_error_t *
-skip_handler_checksum(void *baton, apr_size_t *count)
-{
-  return skip_default_handler(baton, count, read_handler_checksum);
-}
-
-
-static svn_error_t *
 write_handler_checksum(void *baton, const char *buffer, apr_size_t *len)
 {
   struct checksum_stream_baton *btn = baton;
@@ -1431,7 +1416,6 @@ svn_stream_checksummed2(svn_stream_t *st
 
   s = svn_stream_create(baton, pool);
   svn_stream_set_read(s, read_handler_checksum);
-  svn_stream_set_skip(s, skip_handler_checksum);
   svn_stream_set_write(s, write_handler_checksum);
   svn_stream_set_close(s, close_handler_checksum);
   return s;



Mime
View raw message