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

Re: [PATCH] Rename svn_io_file_printf

From: Erik Huelsmann <e.huelsmann_at_gmx.net>
Date: 2003-12-17 19:38:22 CET

> On Wed, 2003-12-17 at 12:22, Erik Huelsmann wrote:
> > There are only 5 occurrances (all within libsvn_client/diff.c) and the
> > function does not have a massive body. We could do away with it
> entirely. Or just
> > make it a static within libsvn_client/diff.c.
>
> I like the last option. If we start to need it in more places, we can
> reconsider making it an svn_io function.

The diff below does just that. Should I attach this as a patch with log to
the issue?

bye,

Erik.

Index: subversion/include/svn_io.h
===================================================================
--- subversion/include/svn_io.h (revision 8027)
+++ subversion/include/svn_io.h (working copy)
@@ -737,14 +737,6 @@
                  apr_pool_t *pool);
 
 
-/** Wrapper for @c apr_file_printf(), which see. @a format is a
utf8-encoded
- * string after it is formatted, so this function can convert it to
- * native encoding before printing.
- */
-svn_error_t *
-svn_io_file_printf (apr_file_t *fptr, const char *format, ...);
-
-
 
 /** Version/format files.
  *
Index: subversion/libsvn_subr/io.c
===================================================================
--- subversion/libsvn_subr/io.c (revision 8027)
+++ subversion/libsvn_subr/io.c (working copy)
@@ -1993,25 +1993,6 @@
 }
 
 
-svn_error_t *
-svn_io_file_printf (apr_file_t *fptr, const char *format, ...)
-{
- va_list ap;
- const char *buf, *buf_apr;
-
- va_start (ap, format);
- buf = apr_pvsprintf (apr_file_pool_get (fptr), format, ap);
- va_end(ap);
-
- SVN_ERR (svn_path_cstring_from_utf8 (&buf_apr, buf,
- apr_file_pool_get (fptr)));
-
- return do_io_file_wrapper_cleanup
- (fptr, apr_file_puts (buf_apr, fptr), "write to",
- apr_file_pool_get (fptr));
-}
-
-
 
 /**
  * Determine if a directory is empty or not.
Index: subversion/libsvn_client/diff.c
===================================================================
--- subversion/libsvn_client/diff.c (revision 8027)
+++ subversion/libsvn_client/diff.c (working copy)
@@ -66,11 +66,11 @@
 {
   int i;
 
- SVN_ERR (svn_io_file_printf (file,
- APR_EOL_STR "Property changes on: %s"
- APR_EOL_STR, path));
+ SVN_ERR (file_printf_from_utf8 (file,
+ APR_EOL_STR "Property changes on: %s"
+ APR_EOL_STR, path));
 
- /* ### todo [issue #1533]: Use svn_io_file_printf() to convert this
+ /* ### todo [issue #1533]: Use file_printf_from_utf8() to convert this
      line of dashes to native encoding, at least conditionally? Or is
      it better to have under_string always output the same, so
      programs can find it? Also, what about checking for error? */
@@ -89,8 +89,8 @@
       else
         original_value = NULL;
       
- SVN_ERR (svn_io_file_printf (file, "Name: %s" APR_EOL_STR,
- propchange->name));
+ SVN_ERR (file_printf_from_utf8 (file, "Name: %s" APR_EOL_STR,
+ propchange->name));
 
       /* For now, we have a rather simple heuristic: if this is an
          "svn:" property, then assume the value is UTF-8 and must
@@ -103,7 +103,7 @@
           {
             if (val_is_utf8)
               {
- SVN_ERR (svn_io_file_printf
+ SVN_ERR (file_printf_from_utf8
                          (file, " - %s" APR_EOL_STR,
original_value->data));
               }
             else
@@ -118,7 +118,7 @@
           {
             if (val_is_utf8)
               {
- SVN_ERR (svn_io_file_printf
+ SVN_ERR (file_printf_from_utf8
                          (file, " + %s" APR_EOL_STR,
                           propchange->value->data));
               }
@@ -132,7 +132,7 @@
       }
     }
 
- /* ### todo [issue #1533]: Use svn_io_file_printf() to convert this
+ /* ### todo [issue #1533]: Use file_printf_from_utf8() to convert this
      to native encoding, at least conditionally? Or is it better to
      have under_string always output the same eol, so programs can
      find it consistently? Also, what about checking for error? */
@@ -193,6 +193,29 @@
 }
 
 
+/* Wrapper for @c apr_file_printf(), which see. @a format is a
utf8-encoded
+ * string after it is formatted, so this function can convert it to
+ * native encoding before printing.
+ */
+
+static svn_error_t *
+file_printf_from_utf8 (apr_file_t *fptr, const char *format, ...)
+{
+ va_list ap;
+ const char *buf, *buf_apr;
+
+ va_start (ap, format);
+ buf = apr_pvsprintf (apr_file_pool_get (fptr), format, ap);
+ va_end(ap);
+
+ SVN_ERR (svn_path_cstring_from_utf8 (&buf_apr, buf,
+ apr_file_pool_get (fptr)));
+
+ return svn_io_file_write_full (fptr, buf_apr, strlen (buf_apr),
+ NULL, apr_file_pool_get (fptr));
+}
+
+
 /*-----------------------------------------------------------------*/
 
 /*** Callbacks for 'svn diff', invoked by the repos-diff editor. ***/
@@ -533,7 +556,7 @@
   if (state)
     *state = svn_wc_notify_state_unknown;
 
- SVN_ERR (svn_io_file_printf
+ SVN_ERR (file_printf_from_utf8
            (diff_cmd_baton->outfile,
             "Index: %s (deleted)" APR_EOL_STR "%s" APR_EOL_STR,
             path, equal_string));

-- 
+++ GMX - die erste Adresse für Mail, Message, More +++
Neu: Preissenkung für MMS und FreeMMS! http://www.gmx.net
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Dec 17 19:39:20 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.