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

[PATCH] a little step in issue 897: non-recursive svn_handle_error()

From: Erik Hülsmann <dionisos_at_tigris.org>
Date: 2003-10-25 19:25:19 CEST
('binary' encoding is not supported, stored as-is) Hi!

In the discussion about issue #897 Greg Hudson suggests that
svn_handle_error() is too lispy and could/should be rewritten
to be more C-like.
(http://subversion.tigris.org/issues/show_bug.cgi?id=897 ;
cleanup error messages)

I have written the patch below which does exactly that and
thus eliminates the need for the handle_error function.

Comments? Reviews? Coding style?

bye,

Erik.

Log:
[[[
First step for issue #897 and related discussion:
make svn_handle_error() non-recursive

* subversion/libsvn_subr/error.c:
  make svn_handle_error() non-recursive
    thus eliminating the need for handle_error()
]]]

Patch:
Index: subversion/libsvn_subr/error.c
===================================================================
--- subversion/libsvn_subr/error.c (revision 7519)
+++ subversion/libsvn_subr/error.c (working copy)
@@ -223,63 +223,64 @@
 }
  
  
-static void
-handle_error (svn_error_t *err, FILE *stream, svn_boolean_t fatal,
- int depth, apr_status_t parent_apr_err)
+void
+svn_handle_error (svn_error_t *err, FILE *stream, svn_boolean_t fatal)
 {
   char errbuf[256];
   const char *err_string;
+ int depth;
+ apr_status_t parent_apr_err;
  
   /* Pretty-print the error */
   /* Note: we can also log errors here someday. */
  
+ for (depth = 0, parent_apr_err = 0;
+ err;
+ parent_apr_err = err->apr_err, err = err->child, depth++)
+ {
+
 #ifdef SVN_DEBUG
- if (err->file)
+ if (err->file)
     /* Note: err->file is _not_ in UTF-8, because it's expanded from
              the __FILE__ preprocessor macro. */
- fprintf (stream, "%s:%ld", err->file, err->line);
- else
- fputs (SVN_FILE_LINE_UNDEFINED, stream);
+ fprintf (stream, "%s:%ld", err->file, err->line);
+ else
+ fputs (SVN_FILE_LINE_UNDEFINED, stream);
  
- fprintf (stream, ": (apr_err=%d)\n", err->apr_err);
+ fprintf (stream, ": (apr_err=%d)\n", err->apr_err);
 #endif /* SVN_DEBUG */
  
   /* When we're recursing, don't repeat the top-level message if its
      the same as before. */
- if (depth == 0 || err->apr_err != parent_apr_err)
- {
+ if ((depth == 0 || err->apr_err != parent_apr_err)
+ // && (! err->message)
+ )
+ {
       /* Is this a Subversion-specific error code? */
- if ((err->apr_err > APR_OS_START_USEERR)
- && (err->apr_err <= APR_OS_START_CANONERR))
- err_string = convert_string_for_output
- (svn_strerror (err->apr_err, errbuf, sizeof (errbuf)), err->pool);
+ if ((err->apr_err > APR_OS_START_USEERR)
+ && (err->apr_err <= APR_OS_START_CANONERR))
+ err_string = convert_string_for_output
+ (svn_strerror (err->apr_err, errbuf,
+ sizeof (errbuf)), err->pool);
       /* Otherwise, this must be an APR error code. */
- else
- err_string = apr_strerror (err->apr_err, errbuf, sizeof (errbuf));
-
- fprintf (stream, "svn: %s\n", err_string);
+ else
+ err_string = apr_strerror (err->apr_err, errbuf, sizeof (errbuf));
+
+ fprintf (stream, "svn: %s\n", err_string);
+ }
+ if (err->message)
+ fprintf (stream, "svn: %s\n",
+ convert_string_for_output (err->message, err->pool));
+ fflush (stream);
     }
- if (err->message)
- fprintf (stream, "svn: %s\n",
- convert_string_for_output (err->message, err->pool));
- fflush (stream);
  
- if (err->child)
- handle_error (err->child, stream, FALSE, depth + 1, err->apr_err);
-
   if (fatal)
     /* XXX Shouldn't we exit(1) here instead, so that atexit handlers
        get called? --xbc */
     abort ();
 }
  
-void
-svn_handle_error (svn_error_t *err, FILE *stream, svn_boolean_t fatal)
-{
- handle_error (err, stream, fatal, 0, APR_SUCCESS);
-}
  
-
 void
 svn_handle_warning (FILE *stream, svn_error_t *err)
 {

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 25 20:01:25 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.