You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2010/10/03 16:49:26 UTC
svn commit: r1003972 - /subversion/trunk/subversion/libsvn_client/patch.c
Author: stsp
Date: Sun Oct 3 14:49:25 2010
New Revision: 1003972
URL: http://svn.apache.org/viewvc?rev=1003972&view=rev
Log:
* subversion/libsvn_client/patch.c
(try_stream_write): Remove. This helper function was redundant because
svn_stream_write will always error on a short write.
(copy_lines_to_target, reject_hunk, apply_hunk): Make these callers use
svn_stream_write() instead.
Modified:
subversion/trunk/subversion/libsvn_client/patch.c
Modified: subversion/trunk/subversion/libsvn_client/patch.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/patch.c?rev=1003972&r1=1003971&r2=1003972&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/patch.c (original)
+++ subversion/trunk/subversion/libsvn_client/patch.c Sun Oct 3 14:49:25 2010
@@ -1238,24 +1238,6 @@ get_hunk_info(hunk_info_t **hi, patch_ta
return SVN_NO_ERROR;
}
-/* Attempt to write LEN bytes of DATA to STREAM, the underlying file
- * of which is at ABSPATH. Fail if not all bytes could be written to
- * the stream. Do temporary allocations in POOL. */
-static svn_error_t *
-try_stream_write(svn_stream_t *stream, const char *abspath,
- const char *data, apr_size_t len, apr_pool_t *pool)
-{
- apr_size_t written;
-
- written = len;
- SVN_ERR(svn_stream_write(stream, data, &written));
- if (written != len)
- return svn_error_createf(SVN_ERR_IO_WRITE_ERROR, NULL,
- _("Error writing to '%s'"),
- svn_dirent_local_style(abspath, pool));
- return SVN_NO_ERROR;
-}
-
/* Copy lines to the patched stream until the specified LINE has been
* reached. Indicate in *EOF whether end-of-file was encountered while
* reading from the target.
@@ -1272,6 +1254,7 @@ copy_lines_to_target(target_content_info
&& ! content_info->eof)
{
const char *target_line;
+ apr_size_t len;
svn_pool_clear(iterpool);
@@ -1279,9 +1262,8 @@ copy_lines_to_target(target_content_info
if (! content_info->eof)
target_line = apr_pstrcat(iterpool, target_line, content_info->eol_str,
NULL);
-
- SVN_ERR(try_stream_write(content_info->patched, patched_path,
- target_line, strlen(target_line), iterpool));
+ len = strlen(target_line);
+ SVN_ERR(svn_stream_write(content_info->patched, target_line, &len));
}
svn_pool_destroy(iterpool);
@@ -1343,12 +1325,17 @@ reject_hunk(patch_target_t *target, targ
if (! eof)
{
if (hunk_line->len >= 1)
- SVN_ERR(try_stream_write(content_info->reject, target->reject_path,
- hunk_line->data, hunk_line->len,
- iterpool));
+ {
+ len = hunk_line->len;
+ SVN_ERR(svn_stream_write(content_info->reject, hunk_line->data,
+ &len));
+ }
+
if (eol_str)
- SVN_ERR(try_stream_write(content_info->reject, target->reject_path,
- eol_str, strlen(eol_str), iterpool));
+ {
+ len = strlen(eol_str);
+ SVN_ERR(svn_stream_write(content_info->reject, eol_str, &len));
+ }
}
}
while (! eof);
@@ -1421,11 +1408,15 @@ apply_hunk(patch_target_t *target, targe
if (! eof && lines_read > hi->fuzz &&
lines_read <= svn_diff_hunk_get_modified_length(hi->hunk) - hi->fuzz)
{
+ apr_size_t len;
+
if (hunk_line->len >= 1)
- SVN_ERR(try_stream_write(content_info->patched,
- target->patched_path,
- hunk_line->data, hunk_line->len,
- iterpool));
+ {
+ len = hunk_line->len;
+ SVN_ERR(svn_stream_write(content_info->patched, hunk_line->data,
+ &len));
+ }
+
if (eol_str)
{
/* Use the EOL as it was read from the patch file,
@@ -1433,9 +1424,8 @@ apply_hunk(patch_target_t *target, targe
if (content_info->eol_style != svn_subst_eol_style_none)
eol_str = content_info->eol_str;
- SVN_ERR(try_stream_write(content_info->patched,
- target->patched_path, eol_str,
- strlen(eol_str), iterpool));
+ len = strlen(eol_str);
+ SVN_ERR(svn_stream_write(content_info->patched, eol_str, &len));
}
}
}