"Peter N. Lundblad" <peter@famlundblad.se> writes:
> > (If I could think of some way to make SVN_CL__TRY take an arbitrary
> > number of errors to test for, that would be perfect. But variadic
> > macros weren't added to C until C99, and even then they don't do quite
> > what we'd need. Oh well.)
>
> We could always supply an array of extra errors to accept. Maybe the
> avoidance of code duplication is worth it.
I was thinking of that. Unfortunately, this being C, the overhead of
setting up an array would be annoying. However, I thought of another
way. Let's change SVN_CL__TRY() to a variadic function:
/* A helper for the many subcommands that wish to merely warn when
* invoked on an unversioned, nonexistent, or otherwise innocuously
* errorful resource. Meant to be wrapped with SVN_ERR().
*
* - If ERR is null, set *SUCCESS to TRUE and return SVN_NO_ERROR.
*
* - Else if ERR->apr_err is one of the error codes supplied in
* varargs (typically, codes like SVN_ERR_UNVERSIONED_RESOURCE,
* SVN_ERR_ENTRY_NOT_FOUND, etc, are passed), then handle ERR
* as a warning (unless QUIET is true), clear ERR, set *SUCCESS
* to FALSE, and return SVN_NO_ERROR.
*
* - Else don't touch SUCCESS, just return ERR.
*/
svn_error_t *
svn_cl__try (svn_error_t *err,
svn_boolean_t *success,
svn_boolean_t quiet,
...)
{
if (err)
{
/*** loop over varargs in obvious way ***/
}
return err;
}
Then we just replace all instances of
SVN_CL__TRY (whatever);
with
SVN_ERR (svn_cl__try (whatever));
Thoughts?
> > Don't forget to check opt_state->quiet before calling
> > svn_handle_warning(). We don't want to emit warnings if the user
> > specified --quiet on the command line.
>
> Ha, that's my fault. I adviced against that since cat doesn't accept
> --quiet. Maybe we want to add --quiet to cat for this case.
Yes, I think we should (though that's somewhat a separate issue).
-Karl
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue May 31 18:48:30 2005