diff options
Diffstat (limited to 'subversion/libsvn_subr/opt.c')
-rw-r--r-- | subversion/libsvn_subr/opt.c | 53 |
1 files changed, 31 insertions, 22 deletions
diff --git a/subversion/libsvn_subr/opt.c b/subversion/libsvn_subr/opt.c index 7b108e5a572a8..fd8c73a273b27 100644 --- a/subversion/libsvn_subr/opt.c +++ b/subversion/libsvn_subr/opt.c @@ -350,41 +350,50 @@ print_command_info2(const svn_opt_subcommand_desc2_t *cmd, return SVN_NO_ERROR; } -void -svn_opt_print_generic_help2(const char *header, - const svn_opt_subcommand_desc2_t *cmd_table, - const apr_getopt_option_t *opt_table, - const char *footer, - apr_pool_t *pool, FILE *stream) +/* The body for svn_opt_print_generic_help2() function with standard error + * handling semantic. Handling of errors implemented at caller side. */ +static svn_error_t * +print_generic_help_body(const char *header, + const svn_opt_subcommand_desc2_t *cmd_table, + const apr_getopt_option_t *opt_table, + const char *footer, + apr_pool_t *pool, FILE *stream) { int i = 0; - svn_error_t *err; if (header) - if ((err = svn_cmdline_fputs(header, stream, pool))) - goto print_error; + SVN_ERR(svn_cmdline_fputs(header, stream, pool)); while (cmd_table[i].name) { - if ((err = svn_cmdline_fputs(" ", stream, pool)) - || (err = print_command_info2(cmd_table + i, opt_table, - NULL, FALSE, - pool, stream)) - || (err = svn_cmdline_fputs("\n", stream, pool))) - goto print_error; + SVN_ERR(svn_cmdline_fputs(" ", stream, pool)); + SVN_ERR(print_command_info2(cmd_table + i, opt_table, + NULL, FALSE, + pool, stream)); + SVN_ERR(svn_cmdline_fputs("\n", stream, pool)); i++; } - if ((err = svn_cmdline_fputs("\n", stream, pool))) - goto print_error; + SVN_ERR(svn_cmdline_fputs("\n", stream, pool)); if (footer) - if ((err = svn_cmdline_fputs(footer, stream, pool))) - goto print_error; + SVN_ERR(svn_cmdline_fputs(footer, stream, pool)); + + return SVN_NO_ERROR; +} + +void +svn_opt_print_generic_help2(const char *header, + const svn_opt_subcommand_desc2_t *cmd_table, + const apr_getopt_option_t *opt_table, + const char *footer, + apr_pool_t *pool, FILE *stream) +{ + svn_error_t *err; - return; + err = print_generic_help_body(header, cmd_table, opt_table, footer, pool, + stream); - print_error: /* Issue #3014: * Don't print anything on broken pipes. The pipe was likely * closed by the process at the other end. We expect that @@ -392,7 +401,7 @@ svn_opt_print_generic_help2(const char *header, * * ### This assumes that there is only one error in a chain for * ### SVN_ERR_IO_PIPE_WRITE_ERROR. See svn_cmdline_fputs(). */ - if (err->apr_err != SVN_ERR_IO_PIPE_WRITE_ERROR) + if (err && err->apr_err != SVN_ERR_IO_PIPE_WRITE_ERROR) svn_handle_error2(err, stderr, FALSE, "svn: "); svn_error_clear(err); } |