[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] Use svn_stream_t for output of diff/merge

From: Sander Striker <striker_at_apache.org>
Date: 2003-12-12 00:17:22 CET

Hi,

Subject says it all.

Sander

Log:

* subversion/include/svn_diff.h

  (svn_diff_file_output_unified, svn_diff_file_output_merge): Change signature.


* subversion/libsvn_diff/diff_file.c

  (svn_diff__file_output_baton_t, svn_diff3__file_output_baton_t): Trade in
    apr_file_t for a svn_stream_t.

  (svn_diff__file_output_unified_flush_hunk, svn_diff3__file_output_line,
   svn_diff3__file_output_conflict): Use stream output functions instead of
    apr file output functions.

  (svn_diff_file_output_unified, svn_diff_file_output_merge): Take and use
    a svn stream for output instead of an apr file.


* subversion/libsvn_wc/merge.c

  (svn_wc_merge): Update call to svn_diff_file_output_merge. Provide a
    stream instead of a file.


* subversion/libsvn_client/diff.c

  (diff_file_changed): Update call to svn_diff_file_output_unified. Provide
    a stream instead of a file.


* subversion/svnlook/main.c

  (print_diff_tree): Update call to svn_diff_file_output_unified. Provide
    a stream instead of a file.


* subversion/tests/libsvn_diff/diff-diff3-test.c

  (three_way_merge): Update call to svn_diff_file_output_merge. Provide a
    stream instead of a file.

  (two_way_diff): Update call to svn_diff_file_output_unified. Provide a
    stream instead of a file.


* subversion/tests/libsvn_diff/diff-test.c

  (do_diff): Take and pass an svn stream.

  (main): Update call to do_diff. Provide a stream instead of a file.


* subversion/tests/libsvn_diff/diff3-test.c

  (do_diff3): Take and pass an svn stream.

  (main): Update call to do_diff3. Provide a stream instead of a file.


* subversion/tests/libsvn_diff/diff4-test.c

  (do_diff4): Take and pass an svn stream.

  (main): Update call to do_diff4. Provide a stream instead of a file.

Index: subversion/include/svn_diff.h
===================================================================
--- subversion/include/svn_diff.h (revision 7950)
+++ subversion/include/svn_diff.h (working copy)
@@ -49,6 +49,7 @@
 
 #include "svn_types.h"
 #include "svn_error.h"
+#include "svn_io.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -339,7 +340,7 @@
  * will be displayed, consisting of path and last modified time.
  */
 svn_error_t *
-svn_diff_file_output_unified(apr_file_t *output_file,
+svn_diff_file_output_unified(svn_stream_t *output_stream,
                              svn_diff_t *diff,
                              const char *original_path,
                              const char *modified_path,
@@ -361,7 +362,7 @@
  * as desired. Note that these options are mutually exclusive.
  */
 svn_error_t *
-svn_diff_file_output_merge(apr_file_t *output_file,
+svn_diff_file_output_merge(svn_stream_t *output_stream,
                            svn_diff_t *diff,
                            const char *original_path,
                            const char *modified_path,
Index: subversion/libsvn_diff/diff_file.c
===================================================================
--- subversion/libsvn_diff/diff_file.c (revision 7950)
+++ subversion/libsvn_diff/diff_file.c (working copy)
@@ -532,7 +532,7 @@
 
 typedef struct svn_diff__file_output_baton_t
 {
- apr_file_t *output_file;
+ svn_stream_t *output_stream;
 
   const char *path[2];
   apr_file_t *file[2];
@@ -705,29 +705,34 @@
   /* Output the hunk header. If the hunk length is 1, the file is a one line
      file. In this case, surpress the number of lines in the hunk (it is
      1 implicitly)
- ### todo: check for error from apr_file_printf() ? */
- apr_file_printf(baton->output_file, "@@ -%" APR_OFF_T_FMT,
- baton->hunk_start[0]);
+ */
+ SVN_ERR(svn_stream_printf(baton->output_stream, baton->pool,
+ "@@ -%" APR_OFF_T_FMT,
+ baton->hunk_start[0]));
   if (baton->hunk_length[0] != 1)
     {
- apr_file_printf(baton->output_file, ",%" APR_OFF_T_FMT,
- baton->hunk_length[0]);
+ SVN_ERR(svn_stream_printf(baton->output_stream, baton->pool,
+ ",%" APR_OFF_T_FMT,
+ baton->hunk_length[0]));
     }
 
- apr_file_printf(baton->output_file, " +%" APR_OFF_T_FMT,
- baton->hunk_start[1]);
+ SVN_ERR(svn_stream_printf(baton->output_stream, baton->pool,
+ " +%" APR_OFF_T_FMT,
+ baton->hunk_start[1]));
   if (baton->hunk_length[1] != 1)
     {
- apr_file_printf(baton->output_file, ",%" APR_OFF_T_FMT,
- baton->hunk_length[1]);
+ SVN_ERR(svn_stream_printf(baton->output_stream, baton->pool,
+ ",%" APR_OFF_T_FMT,
+ baton->hunk_length[1]));
     }
 
- apr_file_printf(baton->output_file, " @@" APR_EOL_STR);
+ SVN_ERR(svn_stream_printf(baton->output_stream, baton->pool,
+ " @@" APR_EOL_STR));
 
   /* Output the hunk content */
   hunk_len = baton->hunk->len;
- SVN_ERR (svn_io_file_write_full(baton->output_file, baton->hunk->data,
- hunk_len, NULL, baton->pool));
+ SVN_ERR (svn_stream_write(baton->output_stream, baton->hunk->data,
+ &hunk_len));
 
   /* Prepare for the next hunk */
   baton->hunk_length[0] = 0;
@@ -836,7 +841,7 @@
 };
 
 svn_error_t *
-svn_diff_file_output_unified(apr_file_t *output_file,
+svn_diff_file_output_unified(svn_stream_t *output_stream,
                              svn_diff_t *diff,
                              const char *original_path,
                              const char *modified_path,
@@ -850,7 +855,7 @@
   if (svn_diff_contains_diffs(diff))
     {
       memset(&baton, 0, sizeof(baton));
- baton.output_file = output_file;
+ baton.output_stream = output_stream;
       baton.pool = pool;
       baton.path[0] = original_path;
       baton.path[1] = modified_path;
@@ -874,10 +879,10 @@
             svn_diff__file_output_unified_default_hdr(pool, modified_path);
         }
 
- SVN_ERR( svn_io_file_printf(output_file,
- "--- %s" APR_EOL_STR
- "+++ %s" APR_EOL_STR,
- original_header, modified_header) );
+ SVN_ERR(svn_stream_printf(output_stream, pool,
+ "--- %s" APR_EOL_STR
+ "+++ %s" APR_EOL_STR,
+ original_header, modified_header));
 
       SVN_ERR(svn_diff_output(diff, &baton,
                               &svn_diff__file_output_unified_vtable));
@@ -897,7 +902,7 @@
 
 typedef struct svn_diff3__file_output_baton_t
 {
- apr_file_t *output_file;
+ svn_stream_t *output_stream;
 
   const char *path[3];
 
@@ -935,7 +940,6 @@
   char *endp;
   char *eol;
   apr_size_t len;
- apr_status_t rv;
 
   curp = baton->curp[idx];
   endp = baton->endp[idx];
@@ -959,8 +963,7 @@
   if (type != svn_diff3__file_output_skip)
     {
       len = eol - curp;
- SVN_ERR (svn_io_file_write_full(baton->output_file, curp, len, NULL,
- baton->pool));
+ SVN_ERR(svn_stream_write(baton->output_stream, curp, &len));
     }
 
   baton->curp[idx] = eol;
@@ -1052,8 +1055,8 @@
   apr_off_t latest_start, apr_off_t latest_length,
   svn_diff_t *diff)
 {
- apr_status_t rv;
   svn_diff3__file_output_baton_t *file_baton = baton;
+ apr_size_t len;
 
   if (diff && file_baton->display_resolved_conflicts)
     {
@@ -1061,47 +1064,52 @@
                              &svn_diff3__file_output_vtable);
     }
 
- rv = apr_file_puts(file_baton->conflict_modified, file_baton->output_file);
- if (rv != APR_SUCCESS)
- return svn_error_wrap_apr(rv, "Can't write file");
+ len = strlen(file_baton->conflict_modified);
+ SVN_ERR(svn_stream_write(file_baton->output_stream,
+ file_baton->conflict_modified,
+ &len));
+ len = sizeof(APR_EOL_STR) - 1;
+ SVN_ERR(svn_stream_write(file_baton->output_stream,
+ APR_EOL_STR, &len));
 
- apr_file_puts(APR_EOL_STR, file_baton->output_file);
-
   SVN_ERR(svn_diff3__file_output_hunk(baton, 1,
             modified_start, modified_length));
 
   if (file_baton->display_original_in_conflict)
     {
- rv = apr_file_puts(file_baton->conflict_original, file_baton->output_file);
- if (rv != APR_SUCCESS)
- return svn_error_wrap_apr(rv, "Can't write file");
+ len = strlen(file_baton->conflict_original);
+ SVN_ERR(svn_stream_write(file_baton->output_stream,
+ file_baton->conflict_original, &len));
+ len = sizeof(APR_EOL_STR) - 1;
+ SVN_ERR(svn_stream_write(file_baton->output_stream,
+ APR_EOL_STR, &len));
 
- apr_file_puts(APR_EOL_STR, file_baton->output_file);
-
       SVN_ERR(svn_diff3__file_output_hunk(baton, 0,
               original_start, original_length));
     }
 
- rv = apr_file_puts(file_baton->conflict_separator, file_baton->output_file);
- if (rv != APR_SUCCESS)
- return svn_error_wrap_apr(rv, "Can't write file");
+ len = strlen(file_baton->conflict_separator);
+ SVN_ERR(svn_stream_write(file_baton->output_stream,
+ file_baton->conflict_separator, &len));
+ len = sizeof(APR_EOL_STR) - 1;
+ SVN_ERR(svn_stream_write(file_baton->output_stream,
+ APR_EOL_STR, &len));
 
- apr_file_puts(APR_EOL_STR, file_baton->output_file);
-
   SVN_ERR(svn_diff3__file_output_hunk(baton, 2,
             latest_start, latest_length));
 
- rv = apr_file_puts(file_baton->conflict_latest, file_baton->output_file);
- if (rv != APR_SUCCESS)
- return svn_error_wrap_apr(rv, "Can't write file");
+ len = strlen(file_baton->conflict_latest);
+ SVN_ERR(svn_stream_write(file_baton->output_stream,
+ file_baton->conflict_latest, &len));
+ len = sizeof(APR_EOL_STR) - 1;
+ SVN_ERR(svn_stream_write(file_baton->output_stream,
+ APR_EOL_STR, &len));
 
- apr_file_puts(APR_EOL_STR, file_baton->output_file);
-
   return SVN_NO_ERROR;
 }
 
 svn_error_t *
-svn_diff_file_output_merge(apr_file_t *output_file,
+svn_diff_file_output_merge(svn_stream_t *output_stream,
                            svn_diff_t *diff,
                            const char *original_path,
                            const char *modified_path,
@@ -1123,7 +1131,7 @@
 #endif /* APR_HAS_MMAP */
 
   memset(&baton, 0, sizeof(baton));
- baton.output_file = output_file;
+ baton.output_stream = output_stream;
   baton.pool = pool;
   baton.path[0] = original_path;
   baton.path[1] = modified_path;
Index: subversion/libsvn_wc/merge.c
===================================================================
--- subversion/libsvn_wc/merge.c (revision 7950)
+++ subversion/libsvn_wc/merge.c (working copy)
@@ -128,7 +128,10 @@
           const char *target_marker;
           const char *left_marker;
           const char *right_marker;
+ svn_stream_t *ostream;
 
+ ostream = svn_stream_from_aprfile(result_f, pool);
+
           SVN_ERR (svn_diff_file_diff3 (&diff,
                                         tmp_left, tmp_target, tmp_right,
                                         pool));
@@ -149,7 +152,7 @@
           else
             right_marker = ">>>>>>> .new";
 
- SVN_ERR (svn_diff_file_output_merge (result_f, diff,
+ SVN_ERR (svn_diff_file_output_merge (ostream, diff,
                                                tmp_left, tmp_target, tmp_right,
                                                left_marker,
                                                target_marker,
@@ -158,6 +161,7 @@
                                                FALSE, /* display original */
                                                FALSE, /* resolve conflicts */
                                                pool));
+ SVN_ERR (svn_stream_close (ostream));
 
           contains_conflicts = svn_diff_contains_conflicts (diff);
         }
Index: subversion/svnlook/main.c
===================================================================
--- subversion/svnlook/main.c (revision 7950)
+++ subversion/svnlook/main.c (working copy)
@@ -869,23 +869,19 @@
               SVN_ERR (svn_diff_file_diff (&diff, orig_path, new_path, pool));
               if (svn_diff_contains_diffs (diff))
                 {
- apr_file_t *outhandle;
- apr_status_t apr_err;
+ svn_stream_t *ostream;
                   const char *orig_label, *new_label;
 
- /* Get an apr_file_t representing stdout, which is where
- we'll have the diff program print to. */
- apr_err = apr_file_open_stdout (&outhandle, pool);
- if (apr_err)
- return svn_error_wrap_apr (apr_err, "Can't open stdout");
+ SVN_ERR (svn_stream_for_stdout (&ostream, pool));
                   
                   SVN_ERR (generate_label (&orig_label, base_root,
                                            base_path, pool));
                   SVN_ERR (generate_label (&new_label, root, path, pool));
- SVN_ERR (svn_diff_file_output_unified (outhandle, diff,
+ SVN_ERR (svn_diff_file_output_unified (ostream, diff,
                                                          orig_path, new_path,
                                                          orig_label, new_label,
                                                          pool));
+ SVN_ERR (svn_stream_close (ostream));
                 }
             }
         }
Index: subversion/libsvn_client/diff.c
===================================================================
--- subversion/libsvn_client/diff.c (revision 7950)
+++ subversion/libsvn_client/diff.c (working copy)
@@ -269,12 +269,15 @@
   const char *diff_cmd = NULL;
   const char **args = NULL;
   int nargs, exitcode;
- apr_file_t *outfile = diff_cmd_baton->outfile;
+ apr_pool_t *subpool = svn_pool_create (diff_cmd_baton->pool);
+ svn_stream_t *os;
   apr_file_t *errfile = diff_cmd_baton->errfile;
- apr_pool_t *subpool = svn_pool_create (diff_cmd_baton->pool);
   const char *label1, *label2;
   svn_boolean_t mt1_binary = FALSE, mt2_binary = FALSE;
 
+ /* Get a stream from our output file. */
+ os = svn_stream_from_aprfile(diff_cmd_baton->outfile, subpool);
+
   /* Assemble any option args. */
   nargs = diff_cmd_baton->options->nelts;
   if (nargs)
@@ -348,32 +351,33 @@
   if (mt1_binary || mt2_binary)
     {
       /* Print out the diff header. */
- SVN_ERR (svn_io_file_printf (outfile, "Index: %s" APR_EOL_STR
- "%s" APR_EOL_STR, path, equal_string));
+ SVN_ERR (svn_stream_printf (os, subpool,
+ "Index: %s" APR_EOL_STR
+ "%s" APR_EOL_STR, path, equal_string));
 
- SVN_ERR (svn_io_file_printf
- (outfile,
+ SVN_ERR (svn_stream_printf
+ (os, subpool,
                 "Cannot display: file marked as a binary type."
                 APR_EOL_STR));
       
       if (mt1_binary && !mt2_binary)
- SVN_ERR (svn_io_file_printf (outfile,
- "svn:mime-type = %s" APR_EOL_STR,
- mimetype1));
+ SVN_ERR (svn_stream_printf (os, subpool,
+ "svn:mime-type = %s" APR_EOL_STR,
+ mimetype1));
       else if (mt2_binary && !mt1_binary)
- SVN_ERR (svn_io_file_printf (outfile,
- "svn:mime-type = %s" APR_EOL_STR,
- mimetype2));
+ SVN_ERR (svn_stream_printf (os, subpool,
+ "svn:mime-type = %s" APR_EOL_STR,
+ mimetype2));
       else if (mt1_binary && mt2_binary)
         {
           if (strcmp (mimetype1, mimetype2) == 0)
- SVN_ERR (svn_io_file_printf
- (outfile,
+ SVN_ERR (svn_stream_printf
+ (os, subpool,
                       "svn:mime-type = %s" APR_EOL_STR,
                       mimetype1));
           else
- SVN_ERR (svn_io_file_printf
- (outfile,
+ SVN_ERR (svn_stream_printf
+ (os, subpool,
                       "svn:mime-type = (%s, %s)" APR_EOL_STR,
                       mimetype1, mimetype2));
         }
@@ -399,12 +403,15 @@
   if (diff_cmd)
     {
       /* Print out the diff header. */
- SVN_ERR (svn_io_file_printf (outfile, "Index: %s" APR_EOL_STR
- "%s" APR_EOL_STR, path, equal_string));
+ SVN_ERR (svn_stream_printf (os, subpool,
+ "Index: %s" APR_EOL_STR
+ "%s" APR_EOL_STR, path, equal_string));
+ /* Close the stream (flush) */
+ SVN_ERR (svn_stream_close (os));
 
       SVN_ERR (svn_io_run_diff (".", args, nargs, label1, label2,
                                 tmpfile1, tmpfile2,
- &exitcode, outfile, errfile,
+ &exitcode, diff_cmd_baton->outfile, errfile,
                                 diff_cmd, subpool));
     }
   else /* use libsvn_diff to generate the diff */
@@ -436,11 +443,12 @@
       if (svn_diff_contains_diffs (diff) || diff_cmd_baton->force_diff_output)
         {
           /* Print out the diff header. */
- SVN_ERR (svn_io_file_printf (outfile, "Index: %s" APR_EOL_STR
- "%s" APR_EOL_STR, path, equal_string));
+ SVN_ERR (svn_stream_printf (os, subpool,
+ "Index: %s" APR_EOL_STR
+ "%s" APR_EOL_STR, path, equal_string));
 
           /* Output the actual diff */
- SVN_ERR (svn_diff_file_output_unified (outfile, diff,
+ SVN_ERR (svn_diff_file_output_unified (os, diff,
                                                  tmpfile1, tmpfile2,
                                                  label1, label2,
                                                  subpool));
Index: subversion/tests/libsvn_diff/diff-diff3-test.c
===================================================================
--- subversion/tests/libsvn_diff/diff-diff3-test.c (revision 7950)
+++ subversion/tests/libsvn_diff/diff-diff3-test.c (working copy)
@@ -144,6 +144,7 @@
 {
   svn_diff_t *diff;
   apr_file_t *output;
+ svn_stream_t *ostream;
   apr_status_t status;
   svn_stringbuf_t *actual;
   char *merge_name = apr_psprintf (pool, "merge-%s-%s-%s",
@@ -159,12 +160,15 @@
                           pool);
   if (status)
     return svn_error_createf (status, NULL, "failed to open '%s'", merge_name);
- SVN_ERR (svn_diff_file_output_merge (output, diff,
+
+ ostream = svn_stream_from_aprfile (output, pool);
+ SVN_ERR (svn_diff_file_output_merge (ostream, diff,
                                        filename1, filename2, filename3,
                                        NULL, NULL, NULL, NULL,
                                        FALSE,
                                        FALSE,
                                        pool));
+ SVN_ERR (svn_stream_close (ostream));
   status = apr_file_close (output);
   if (status)
     return svn_error_createf (status, NULL, "failed to close '%s'", merge_name);
@@ -202,6 +206,7 @@
 {
   svn_diff_t *diff;
   apr_file_t *output;
+ svn_stream_t *ostream;
   apr_status_t status;
   svn_stringbuf_t *actual;
   char *diff_name = apr_psprintf (pool, "diff-%s-%s", filename1, filename2);
@@ -217,10 +222,13 @@
                           pool);
   if (status)
     return svn_error_createf (status, NULL, "failed to open '%s'", diff_name);
- SVN_ERR (svn_diff_file_output_unified (output, diff,
+
+ ostream = svn_stream_from_aprfile (output, pool);
+ SVN_ERR (svn_diff_file_output_unified (ostream, diff,
                                          filename1, filename2,
                                          filename1, filename2,
                                          pool));
+ SVN_ERR (svn_stream_close (ostream));
   status = apr_file_close (output);
   if (status)
     return svn_error_createf (status, NULL, "failed to close '%s'", diff_name);
Index: subversion/tests/libsvn_diff/diff-test.c
===================================================================
--- subversion/tests/libsvn_diff/diff-test.c (revision 7950)
+++ subversion/tests/libsvn_diff/diff-test.c (working copy)
@@ -22,11 +22,12 @@
 
 #include "svn_pools.h"
 #include "svn_diff.h"
+#include "svn_io.h"
 
 
 static
 svn_error_t *
-do_diff(apr_file_t *output_file,
+do_diff(svn_stream_t *ostream,
         const char *original, const char *modified,
         svn_boolean_t *has_changes,
         apr_pool_t *pool)
@@ -37,7 +38,7 @@
 
   *has_changes = svn_diff_contains_diffs(diff);
 
- SVN_ERR(svn_diff_file_output_unified(output_file, diff,
+ SVN_ERR(svn_diff_file_output_unified(ostream, diff,
                                        original, modified,
                                        NULL, NULL, pool));
 
@@ -47,21 +48,21 @@
 int main(int argc, char *argv[])
 {
   apr_pool_t *pool;
- apr_file_t *output_file;
+ svn_stream_t *ostream;
   int rc;
 
   apr_initialize();
 
   pool = svn_pool_create(NULL);
 
- apr_file_open_stdout(&output_file, pool);
+ svn_stream_for_stdout(&ostream, pool);
 
   if (argc == 3)
     {
+ svn_error_t *svn_err;
       svn_boolean_t has_changes;
- svn_error_t *svn_err;
 
- svn_err = do_diff(output_file, argv[1], argv[2], &has_changes, pool);
+ svn_err = do_diff(ostream, argv[1], argv[2], &has_changes, pool);
       if (svn_err == NULL)
         {
           rc = has_changes ? 1 : 0;
@@ -74,7 +75,8 @@
     }
   else
     {
- apr_file_printf(output_file, "Usage: %s <file1> <file2>\n", argv[0]);
+ svn_stream_printf(ostream, pool,
+ "Usage: %s <file1> <file2>\n", argv[0]);
       rc = 2;
     }
 
Index: subversion/tests/libsvn_diff/diff3-test.c
===================================================================
--- subversion/tests/libsvn_diff/diff3-test.c (revision 7950)
+++ subversion/tests/libsvn_diff/diff3-test.c (working copy)
@@ -22,11 +22,12 @@
 
 #include "svn_pools.h"
 #include "svn_diff.h"
+#include "svn_io.h"
 
 
 static
 svn_error_t *
-do_diff3(apr_file_t *output_file,
+do_diff3(svn_stream_t *ostream,
          const char *original, const char *modified, const char *latest,
          svn_boolean_t *has_changes,
          apr_pool_t *pool)
@@ -37,7 +38,7 @@
 
   *has_changes = svn_diff_contains_diffs(diff);
 
- SVN_ERR(svn_diff_file_output_merge(output_file, diff,
+ SVN_ERR(svn_diff_file_output_merge(ostream, diff,
                                      original, modified, latest,
                                      NULL, NULL, NULL, NULL,
                                      FALSE,
@@ -50,21 +51,21 @@
 int main(int argc, char *argv[])
 {
   apr_pool_t *pool;
- apr_file_t *output_file;
+ svn_stream_t *ostream;
   int rc;
 
   apr_initialize();
 
   pool = svn_pool_create(NULL);
 
- apr_file_open_stdout(&output_file, pool);
+ svn_stream_for_stdout(&ostream, pool);
 
   if (argc == 4)
     {
       svn_boolean_t has_changes;
       svn_error_t *svn_err;
 
- svn_err = do_diff3(output_file, argv[2], argv[1], argv[3], &has_changes, pool);
+ svn_err = do_diff3(ostream, argv[2], argv[1], argv[3], &has_changes, pool);
       if (svn_err == NULL)
         {
           rc = has_changes ? 1 : 0;
@@ -77,7 +78,8 @@
     }
   else
     {
- apr_file_printf(output_file, "Usage: %s <mine> <older> <yours>\n", argv[0]);
+ svn_stream_printf(ostream, pool,
+ "Usage: %s <mine> <older> <yours>\n", argv[0]);
       rc = 2;
     }
 
Index: subversion/tests/libsvn_diff/diff4-test.c
===================================================================
--- subversion/tests/libsvn_diff/diff4-test.c (revision 7950)
+++ subversion/tests/libsvn_diff/diff4-test.c (working copy)
@@ -22,11 +22,12 @@
 
 #include "svn_pools.h"
 #include "svn_diff.h"
+#include "svn_io.h"
 
 
 static
 svn_error_t *
-do_diff4(apr_file_t *output_file,
+do_diff4(svn_stream_t *ostream,
          const char *original,
          const char *modified,
          const char *latest,
@@ -38,7 +39,7 @@
   SVN_ERR(svn_diff_file_diff4(&diff,
                               original, modified, latest, ancestor,
                               pool));
- SVN_ERR(svn_diff_file_output_merge(output_file, diff,
+ SVN_ERR(svn_diff_file_output_merge(ostream, diff,
                                      original, modified, latest,
                                      NULL, NULL, NULL, NULL,
                                      FALSE,
@@ -51,20 +52,20 @@
 int main(int argc, char *argv[])
 {
   apr_pool_t *pool;
- apr_file_t *output_file;
+ svn_stream_t *ostream;
   int rc = 0;
 
   apr_initialize();
 
   pool = svn_pool_create(NULL);
 
- apr_file_open_stdout(&output_file, pool);
+ svn_stream_for_stdout(&ostream, pool);
 
   if (argc == 5)
     {
       svn_error_t *svn_err;
 
- svn_err = do_diff4(output_file,
+ svn_err = do_diff4(ostream,
                          argv[2], argv[1], argv[3], argv[4],
                          pool);
       if (svn_err != NULL)
@@ -75,7 +76,8 @@
     }
   else
     {
- apr_file_printf(output_file, "Usage: %s <mine> <older> <yours> <ancestor>\n", argv[0]);
+ svn_stream_printf(ostream, pool,
+ "Usage: %s <mine> <older> <yours> <ancestor>\n", argv[0]);
       rc = 2;
     }
 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Dec 12 00:18:28 2003

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.