subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From i...@apache.org
Subject svn commit: r1719271 - in /subversion/trunk/subversion: libsvn_client/patch.c libsvn_diff/parse-diff.c libsvn_repos/dump.c libsvn_subr/io.c libsvn_subr/stream.c tests/libsvn_subr/io-test.c
Date Fri, 11 Dec 2015 07:11:07 GMT
Author: ivan
Date: Fri Dec 11 07:11:06 2015
New Revision: 1719271

URL: http://svn.apache.org/viewvc?rev=1719271&view=rev
Log:
Use svn_io_file_get_offset() instead of svn_io_file_seek(APR_CUR) where it
makes sense.

* subversion/libsvn_client/patch.c
* subversion/libsvn_diff/parse-diff.c
* subversion/libsvn_repos/dump.c
* subversion/libsvn_subr/io.c
* subversion/libsvn_subr/stream.c
* subversion/tests/libsvn_subr/io-test.c
  (tell_file, read_handler_base85, hunk_readline_original_or_modified,
   svn_diff_hunk_readline_diff_text, parse_next_hunk, parse_binary_patch,
   svn_diff_parse_next_patch, store_delta, svn_io_file_readline,
   mark_handler_apr, test_file_readline, aligned_seek): Use
   svn_io_file_get_offset() instead of svn_io_file_seek(0, APR_CUR).

Modified:
    subversion/trunk/subversion/libsvn_client/patch.c
    subversion/trunk/subversion/libsvn_diff/parse-diff.c
    subversion/trunk/subversion/libsvn_repos/dump.c
    subversion/trunk/subversion/libsvn_subr/io.c
    subversion/trunk/subversion/libsvn_subr/stream.c
    subversion/trunk/subversion/tests/libsvn_subr/io-test.c

Modified: subversion/trunk/subversion/libsvn_client/patch.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/patch.c?rev=1719271&r1=1719270&r2=1719271&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/patch.c (original)
+++ subversion/trunk/subversion/libsvn_client/patch.c Fri Dec 11 07:11:06 2015
@@ -831,8 +831,7 @@ tell_file(void *baton, apr_off_t *offset
 {
   apr_file_t *file = baton;
 
-  *offset = 0;
-  SVN_ERR(svn_io_file_seek(file, APR_CUR, offset, scratch_pool));
+  SVN_ERR(svn_io_file_get_offset(offset, file, scratch_pool));
   return SVN_NO_ERROR;
 }
 

Modified: subversion/trunk/subversion/libsvn_diff/parse-diff.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_diff/parse-diff.c?rev=1719271&r1=1719270&r2=1719271&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_diff/parse-diff.c (original)
+++ subversion/trunk/subversion/libsvn_diff/parse-diff.c Fri Dec 11 07:11:06 2015
@@ -345,9 +345,8 @@ read_handler_base85(void *baton, char *b
         b85b->next_pos = b85b->end_pos;
       else
         {
-          b85b->next_pos = 0;
-          SVN_ERR(svn_io_file_seek(b85b->file, APR_CUR, &b85b->next_pos,
-                                   iterpool));
+          SVN_ERR(svn_io_file_get_offset(&b85b->next_pos, b85b->file,
+                                         iterpool));
         }
 
       if (line->len && line->data[0] >= 'A' && line->data[0]
<= 'Z')
@@ -669,8 +668,7 @@ hunk_readline_original_or_modified(apr_f
       return SVN_NO_ERROR;
     }
 
-  pos = 0;
-  SVN_ERR(svn_io_file_seek(file, APR_CUR, &pos,  scratch_pool));
+  SVN_ERR(svn_io_file_get_offset(&pos, file, scratch_pool));
   SVN_ERR(svn_io_file_seek(file, APR_SET, &range->current, scratch_pool));
 
   /* It's not ITERPOOL because we use data allocated in LAST_POOL out
@@ -683,8 +681,7 @@ hunk_readline_original_or_modified(apr_f
       max_len = range->end - range->current;
       SVN_ERR(svn_io_file_readline(file, &str, eol, eof, max_len,
                                    last_pool, last_pool));
-      range->current = 0;
-      SVN_ERR(svn_io_file_seek(file, APR_CUR, &range->current, last_pool));
+      SVN_ERR(svn_io_file_get_offset(&range->current, file, last_pool));
       filtered = (str->data[0] == verboten || str->data[0] == '\\');
     }
   while (filtered && ! *eof);
@@ -803,17 +800,15 @@ svn_diff_hunk_readline_diff_text(svn_dif
       return SVN_NO_ERROR;
     }
 
-  pos = 0;
-  SVN_ERR(svn_io_file_seek(hunk->apr_file, APR_CUR, &pos, scratch_pool));
+  SVN_ERR(svn_io_file_get_offset(&pos, hunk->apr_file, scratch_pool));
   SVN_ERR(svn_io_file_seek(hunk->apr_file, APR_SET,
                            &hunk->diff_text_range.current, scratch_pool));
   max_len = hunk->diff_text_range.end - hunk->diff_text_range.current;
   SVN_ERR(svn_io_file_readline(hunk->apr_file, &line, eol, eof, max_len,
                                result_pool,
                    scratch_pool));
-  hunk->diff_text_range.current = 0;
-  SVN_ERR(svn_io_file_seek(hunk->apr_file, APR_CUR,
-                           &hunk->diff_text_range.current, scratch_pool));
+  SVN_ERR(svn_io_file_get_offset(&hunk->diff_text_range.current,
+                                 hunk->apr_file, scratch_pool));
 
   if (*eof && !*eol && *line->data)
     {
@@ -1088,9 +1083,8 @@ parse_next_hunk(svn_diff_hunk_t **hunk,
   modified_end = 0;
   *hunk = apr_pcalloc(result_pool, sizeof(**hunk));
 
-  /* Get current seek position -- APR has no ftell() :( */
-  pos = 0;
-  SVN_ERR(svn_io_file_seek(apr_file, APR_CUR, &pos, scratch_pool));
+  /* Get current seek position. */
+  SVN_ERR(svn_io_file_get_offset(&pos, apr_file, scratch_pool));
 
   /* Start out assuming noise. */
   last_line_type = noise_line;
@@ -1107,8 +1101,7 @@ parse_next_hunk(svn_diff_hunk_t **hunk,
                                    iterpool, iterpool));
 
       /* Update line offset for next iteration. */
-      pos = 0;
-      SVN_ERR(svn_io_file_seek(apr_file, APR_CUR, &pos, iterpool));
+      SVN_ERR(svn_io_file_get_offset(&pos, apr_file, iterpool));
 
       /* Lines starting with a backslash indicate a missing EOL:
        * "\ No newline at end of file" or "end of property". */
@@ -1966,8 +1959,7 @@ parse_binary_patch(svn_patch_t *patch, a
 
   patch->prop_patches = apr_hash_make(result_pool);
 
-  pos = 0;
-  SVN_ERR(svn_io_file_seek(apr_file, APR_CUR, &pos, scratch_pool));
+  SVN_ERR(svn_io_file_get_offset(&pos, apr_file, scratch_pool));
 
   while (!eof)
     {
@@ -1976,8 +1968,7 @@ parse_binary_patch(svn_patch_t *patch, a
                                iterpool, iterpool));
 
       /* Update line offset for next iteration. */
-      pos = 0;
-      SVN_ERR(svn_io_file_seek(apr_file, APR_CUR, &pos, iterpool));
+      SVN_ERR(svn_io_file_get_offset(&pos, apr_file, iterpool));
 
       if (in_blob)
         {
@@ -2158,9 +2149,8 @@ svn_diff_parse_next_patch(svn_patch_t **
       if (! eof)
         {
           /* Update line offset for next iteration. */
-          pos = 0;
-          SVN_ERR(svn_io_file_seek(patch_file->apr_file, APR_CUR, &pos,
-                                   iterpool));
+          SVN_ERR(svn_io_file_get_offset(&pos, patch_file->apr_file,
+                                         iterpool));
         }
 
       /* Run the state machine. */
@@ -2270,9 +2260,8 @@ svn_diff_parse_next_patch(svn_patch_t **
 
   svn_pool_destroy(iterpool);
 
-  patch_file->next_patch_offset = 0;
-  SVN_ERR(svn_io_file_seek(patch_file->apr_file, APR_CUR,
-                           &patch_file->next_patch_offset, scratch_pool));
+  SVN_ERR(svn_io_file_get_offset(&patch_file->next_patch_offset,
+                                 patch_file->apr_file, scratch_pool));
 
   if (patch && patch->hunks)
     {

Modified: subversion/trunk/subversion/libsvn_repos/dump.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/dump.c?rev=1719271&r1=1719270&r2=1719271&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/dump.c (original)
+++ subversion/trunk/subversion/libsvn_repos/dump.c Fri Dec 11 07:11:06 2015
@@ -326,7 +326,7 @@ store_delta(apr_file_t **tempfile, svn_f
             svn_fs_root_t *newroot, const char *newpath, apr_pool_t *pool)
 {
   svn_stream_t *temp_stream;
-  apr_off_t offset = 0;
+  apr_off_t offset;
   svn_txdelta_stream_t *delta_stream;
   svn_txdelta_window_handler_t wh;
   void *whb;
@@ -346,7 +346,7 @@ store_delta(apr_file_t **tempfile, svn_f
   SVN_ERR(svn_txdelta_send_txstream(delta_stream, wh, whb, pool));
 
   /* Get the length of the temporary file and rewind it. */
-  SVN_ERR(svn_io_file_seek(*tempfile, APR_CUR, &offset, pool));
+  SVN_ERR(svn_io_file_get_offset(&offset, *tempfile, pool));
   *len = offset;
   offset = 0;
   return svn_io_file_seek(*tempfile, APR_SET, &offset, pool);

Modified: subversion/trunk/subversion/libsvn_subr/io.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/io.c?rev=1719271&r1=1719270&r2=1719271&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/io.c (original)
+++ subversion/trunk/subversion/libsvn_subr/io.c Fri Dec 11 07:11:06 2015
@@ -5383,8 +5383,7 @@ svn_io_file_readline(apr_file_t *file,
               apr_off_t pos;
 
               /* Check for "\r\n" by peeking at the next byte. */
-              pos = 0;
-              SVN_ERR(svn_io_file_seek(file, APR_CUR, &pos, scratch_pool));
+              SVN_ERR(svn_io_file_get_offset(&pos, file, scratch_pool));
               SVN_ERR(svn_io_file_read_full2(file, &c, sizeof(c), &numbytes,
                                              &found_eof, scratch_pool));
               if (numbytes == 1 && c == '\n')

Modified: subversion/trunk/subversion/libsvn_subr/stream.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/stream.c?rev=1719271&r1=1719270&r2=1719271&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/stream.c (original)
+++ subversion/trunk/subversion/libsvn_subr/stream.c Fri Dec 11 07:11:06 2015
@@ -925,8 +925,7 @@ mark_handler_apr(void *baton, svn_stream
   struct mark_apr *mark_apr;
 
   mark_apr = apr_palloc(pool, sizeof(*mark_apr));
-  mark_apr->off = 0;
-  SVN_ERR(svn_io_file_seek(btn->file, APR_CUR, &mark_apr->off, btn->pool));
+  SVN_ERR(svn_io_file_get_offset(&mark_apr->off, btn->file, btn->pool));
   *mark = (svn_stream_mark_t *)mark_apr;
   return SVN_NO_ERROR;
 }

Modified: subversion/trunk/subversion/tests/libsvn_subr/io-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_subr/io-test.c?rev=1719271&r1=1719270&r2=1719271&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_subr/io-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_subr/io-test.c Fri Dec 11 07:11:06 2015
@@ -621,8 +621,7 @@ test_file_readline(apr_pool_t *pool)
 
   /* Check that APR file reports correct offset. See r1719196 why it's
      important. */
-  pos = 0;
-  SVN_ERR(svn_io_file_seek(f, APR_CUR, &pos, pool));
+  SVN_ERR(svn_io_file_get_offset(&pos, f, pool));
   SVN_TEST_INT_ASSERT(pos, 3);
 
   err = svn_io_file_readline(f, &buf, &eol, &eof, APR_SIZE_MAX, pool, pool);
@@ -633,8 +632,7 @@ test_file_readline(apr_pool_t *pool)
 
   /* Check that APR file reports correct offset. See r1719196 why it's
      important. */
-  pos = 0;
-  SVN_ERR(svn_io_file_seek(f, APR_CUR, &pos, pool));
+  SVN_ERR(svn_io_file_get_offset(&pos, f, pool));
   SVN_TEST_INT_ASSERT(pos, 6);
 
   err = svn_io_file_readline(f, &buf, &eol, &eof, APR_SIZE_MAX, pool, pool);
@@ -645,8 +643,7 @@ test_file_readline(apr_pool_t *pool)
 
   /* Check that APR file reports correct offset. See r1719196 why it's
      important. */
-  pos = 0;
-  SVN_ERR(svn_io_file_seek(f, APR_CUR, &pos, pool));
+  SVN_ERR(svn_io_file_get_offset(&pos, f, pool));
   SVN_TEST_INT_ASSERT(pos, 12);
 
   err = svn_io_file_readline(f, &buf, &eol, &eof, APR_SIZE_MAX, pool, pool);
@@ -657,8 +654,7 @@ test_file_readline(apr_pool_t *pool)
 
   /* Check that APR file reports correct offset. See r1719196 why it's
      important. */
-  pos = 0;
-  SVN_ERR(svn_io_file_seek(f, APR_CUR, &pos, pool));
+  SVN_ERR(svn_io_file_get_offset(&pos, f, pool));
   SVN_TEST_INT_ASSERT(pos, 18);
 
   /* Further reads still returns EOF. */
@@ -670,8 +666,7 @@ test_file_readline(apr_pool_t *pool)
 
   /* Check that APR file reports correct offset. See r1719196 why it's
      important. */
-  pos = 0;
-  SVN_ERR(svn_io_file_seek(f, APR_CUR, &pos, pool));
+  SVN_ERR(svn_io_file_get_offset(&pos, f, pool));
   SVN_TEST_INT_ASSERT(pos, 18);
 
   SVN_ERR(svn_io_file_close(f, pool));
@@ -706,8 +701,7 @@ aligned_seek(apr_file_t *file,
     }
 
   /* we must be at the desired offset */
-  current = 0;
-  SVN_ERR(svn_io_file_seek(file, APR_CUR, &current, pool));
+  SVN_ERR(svn_io_file_get_offset(&current, file, pool));
   SVN_TEST_ASSERT(current == (apr_off_t)offset);
 
   return SVN_NO_ERROR;



Mime
View raw message