You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by br...@apache.org on 2012/09/01 06:48:27 UTC

svn commit: r1379689 - in /subversion/trunk/subversion/libsvn_subr: deprecated.c opt.c opt.h

Author: brane
Date: Sat Sep  1 04:48:26 2012
New Revision: 1379689

URL: http://svn.apache.org/viewvc?rev=1379689&view=rev
Log:
First step towards making client version informatin usable by other than
the svn command-line client.

* subversion/libsvn_subr/opt.h (svn_opt__get_version_info): Renamed from
  svn_opt__print_version_info and prototype changed to return a string.
  Updated docstring.

* subversion/libsvn_subr/opt.c (svn_opt__get_version_info): Renamed from
  svn_opt__print_version_info; constructs a string with the version info
  instead of printing directly to the console.
  (svn_opt_print_help4): Update to use svn_opt__get_version_info.

* subversion/libsvn_subr/deprecated.c (svn_opt_print_hel0: Update to use
  svn_opt__get_version_info.

Modified:
    subversion/trunk/subversion/libsvn_subr/deprecated.c
    subversion/trunk/subversion/libsvn_subr/opt.c
    subversion/trunk/subversion/libsvn_subr/opt.h

Modified: subversion/trunk/subversion/libsvn_subr/deprecated.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/deprecated.c?rev=1379689&r1=1379688&r2=1379689&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/deprecated.c (original)
+++ subversion/trunk/subversion/libsvn_subr/deprecated.c Sat Sep  1 04:48:26 2012
@@ -604,8 +604,11 @@ svn_opt_print_help(apr_getopt_t *os,
         }
     }
   else if (print_version)   /* just --version */
-    SVN_ERR(svn_opt__print_version_info(pgm_name, version_footer,
-                                        quiet, FALSE, pool));
+    {
+      const char *info = svn_opt__get_version_info(pgm_name, version_footer,
+                                                   quiet, FALSE, pool);
+      SVN_ERR(svn_cmdline_fputs(info, stdout, pool));
+    }
   else if (os && !targets->nelts)            /* `-h', `--help', or `help' */
     svn_opt_print_generic_help(header,
                                cmd_table,

Modified: subversion/trunk/subversion/libsvn_subr/opt.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/opt.c?rev=1379689&r1=1379688&r2=1379689&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/opt.c (original)
+++ subversion/trunk/subversion/libsvn_subr/opt.c Sat Sep  1 04:48:26 2012
@@ -1102,32 +1102,35 @@ svn_opt__arg_canonicalize_path(const cha
   return SVN_NO_ERROR;
 }
 
-svn_error_t *
-svn_opt__print_version_info(const char *pgm_name,
-                            const char *footer,
-                            svn_boolean_t quiet,
-                            svn_boolean_t verbose,
-                            apr_pool_t *pool)
+
+const char *
+svn_opt__get_version_info(const char *pgm_name,
+                          const char *footer,
+                          svn_boolean_t quiet,
+                          svn_boolean_t verbose,
+                          apr_pool_t *pool)
 {
+  char *info;
+
   if (quiet)
-    return svn_cmdline_printf(pool, "%s\n", SVN_VER_NUMBER);
+    return apr_psprintf(pool, "%s\n", SVN_VER_NUMBER);
 
-  SVN_ERR(svn_cmdline_printf(pool, _("%s, version %s\n"
-                                     "   compiled %s, %s on %s\n\n"),
-                             pgm_name, SVN_VERSION, __DATE__, __TIME__,
-                             SVN_BUILD_HOST));
-  SVN_ERR(svn_cmdline_fputs(
-             _("Copyright (C) 2012 The Apache Software Foundation.\n"
-               "This software consists of contributions made by many "
-               "people; see the NOTICE\n"
-               "file for more information.\n"
-               "Subversion is open source software, see "
-               "http://subversion.apache.org/\n\n"),
-             stdout, pool));
+  info = apr_psprintf(pool, _("%s, version %s\n"
+                              "   compiled %s, %s on %s\n\n"),
+                      pgm_name, SVN_VERSION, __DATE__, __TIME__,
+                      SVN_BUILD_HOST);
+  info = apr_pstrcat(pool, info,
+                     _("Copyright (C) 2012 The Apache Software Foundation.\n"
+                       "This software consists of contributions made by many "
+                       "people; see the NOTICE\n"
+                       "file for more information.\n"
+                       "Subversion is open source software, see "
+                       "http://subversion.apache.org/\n\n"),
+                     NULL);
 
   if (footer)
     {
-      SVN_ERR(svn_cmdline_printf(pool, "%s\n", footer));
+      info = apr_pstrcat(pool, info, footer, "\n", NULL);
     }
 
   if (verbose)
@@ -1137,33 +1140,32 @@ svn_opt__print_version_info(const char *
       const char *const slibs = svn_sysinfo__linked_libs(pool);
       const char *const dlibs = svn_sysinfo__loaded_libs(pool);
 
-      SVN_ERR(svn_cmdline_fputs(_("System information:\n\n"), stdout, pool));
+      info = apr_pstrcat(pool, info, _("System information:\n\n"), NULL);
       if (relname)
-        SVN_ERR(svn_cmdline_printf(pool, _("* running on %s\n"
-                                           "  - %s\n"),
-                                   host, relname));
+        info = apr_psprintf(pool, _("%s* running on %s\n"
+                                    "  - %s\n"),
+                            info, host, relname);
       else
-        SVN_ERR(svn_cmdline_printf(pool, _("* running on %s\n"), host));
+        info = apr_psprintf(pool, _("%s* running on %s\n"), info, host);
 
       if (slibs)
         {
-          SVN_ERR(svn_cmdline_fputs(_("* linked dependencies:\n"),
-                                    stdout, pool));
-          SVN_ERR(svn_cmdline_fputs(slibs, stdout, pool));
+          info = apr_pstrcat(pool, info,
+                             _("* linked dependencies:\n"),
+                             slibs, NULL);
         }
 
       if (dlibs)
         {
-          SVN_ERR(svn_cmdline_fputs(_("* loaded shared libraries:\n"),
-                                    stdout, pool));
-          SVN_ERR(svn_cmdline_fputs(dlibs, stdout, pool));
+          info = apr_pstrcat(pool, info,
+                             _("* loaded shared libraries:\n"),
+                             dlibs, NULL);
         }
     }
 
-  return SVN_NO_ERROR;
+  return info;
 }
 
-
 svn_error_t *
 svn_opt_print_help4(apr_getopt_t *os,
                     const char *pgm_name,
@@ -1195,8 +1197,11 @@ svn_opt_print_help4(apr_getopt_t *os,
         }
     }
   else if (print_version)   /* just --version */
-    SVN_ERR(svn_opt__print_version_info(pgm_name, version_footer,
-                                        quiet, verbose, pool));
+    {
+      const char *info = svn_opt__get_version_info(pgm_name, version_footer,
+                                                   quiet, verbose, pool);
+      SVN_ERR(svn_cmdline_fputs(info, stdout, pool));
+    }
   else if (os && !targets->nelts)            /* `-h', `--help', or `help' */
     svn_opt_print_generic_help2(header,
                                 cmd_table,

Modified: subversion/trunk/subversion/libsvn_subr/opt.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/opt.h?rev=1379689&r1=1379688&r2=1379689&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/opt.h (original)
+++ subversion/trunk/subversion/libsvn_subr/opt.h Sat Sep  1 04:48:26 2012
@@ -30,19 +30,19 @@
 extern "C" {
 #endif /* __cplusplus */
 
-/* Print version info for PGM_NAME.  If QUIET is  true, print in
- * brief.  Else if QUIET is not true, print the version more
- * verbosely, and if FOOTER is non-null, print it following the
+/* Return a string containing version info for PGM_NAME.  If QUIET is
+ * true, print in brief.  Else if QUIET is not true, print the version
+ * more verbosely, and if FOOTER is non-null, print it following the
  * version information. If VERBOSE is true, print running system info.
  *
  * Use POOL for temporary allocations.
  */
-svn_error_t *
-svn_opt__print_version_info(const char *pgm_name,
-                            const char *footer,
-                            svn_boolean_t quiet,
-                            svn_boolean_t verbose,
-                            apr_pool_t *pool);
+const char *
+svn_opt__get_version_info(const char *pgm_name,
+                          const char *footer,
+                          svn_boolean_t quiet,
+                          svn_boolean_t verbose,
+                          apr_pool_t *pool);
 
 #ifdef __cplusplus
 }



Re: svn commit: r1379689 - in /subversion/trunk/subversion/libsvn_subr: deprecated.c opt.c opt.h

Posted by Daniel Shahaf <d....@daniel.shahaf.name>.
Branko Čibej wrote on Tue, Sep 04, 2012 at 13:24:42 +0200:
> On 01.09.2012 23:41, Daniel Shahaf wrote:
> > Branko Čibej wrote on Sat, Sep 01, 2012 at 06:55:40 +0200:
> >> On 01.09.2012 06:48, brane@apache.org wrote:
> >>> Author: brane
> >>> Date: Sat Sep  1 04:48:26 2012
> >>> New Revision: 1379689
> >>>
> >>> URL: http://svn.apache.org/viewvc?rev=1379689&view=rev
> >>> Log:
> >>> First step towards making client version informatin usable by other than
> >>> the svn command-line client.
> >>>
> >>> * subversion/libsvn_subr/opt.h (svn_opt__get_version_info): Renamed from
> >>>   svn_opt__print_version_info and prototype changed to return a string.
> >>>   Updated docstring.
> >> The plan here is to make svn_opt__get_version_info public, so that other
> >> clients built on top of the core Subversion libraries -- e.g.,
> >> TortoiseSVN -- can use it directly instead of having to construct their
> >> own version info.
> >>
> >> I /think/ this would be a useful addition to the API, but would welcome
> >> any comments on this plan.
> >>
> > Currently the function constructs and returns a string.  For API use
> > maybe it should return a struct?
> 
> Updated to do just that in r1380559. Comments welcome.

Looks good to me, thanks.

Re: svn commit: r1379689 - in /subversion/trunk/subversion/libsvn_subr: deprecated.c opt.c opt.h

Posted by Branko Čibej <br...@wandisco.com>.
On 01.09.2012 23:41, Daniel Shahaf wrote:
> Branko Čibej wrote on Sat, Sep 01, 2012 at 06:55:40 +0200:
>> On 01.09.2012 06:48, brane@apache.org wrote:
>>> Author: brane
>>> Date: Sat Sep  1 04:48:26 2012
>>> New Revision: 1379689
>>>
>>> URL: http://svn.apache.org/viewvc?rev=1379689&view=rev
>>> Log:
>>> First step towards making client version informatin usable by other than
>>> the svn command-line client.
>>>
>>> * subversion/libsvn_subr/opt.h (svn_opt__get_version_info): Renamed from
>>>   svn_opt__print_version_info and prototype changed to return a string.
>>>   Updated docstring.
>> The plan here is to make svn_opt__get_version_info public, so that other
>> clients built on top of the core Subversion libraries -- e.g.,
>> TortoiseSVN -- can use it directly instead of having to construct their
>> own version info.
>>
>> I /think/ this would be a useful addition to the API, but would welcome
>> any comments on this plan.
>>
> Currently the function constructs and returns a string.  For API use
> maybe it should return a struct?

Updated to do just that in r1380559. Comments welcome.

-- Brane

-- 
Certified & Supported Apache Subversion Downloads:
http://www.wandisco.com/subversion/download


Re: svn commit: r1379689 - in /subversion/trunk/subversion/libsvn_subr: deprecated.c opt.c opt.h

Posted by Daniel Shahaf <d....@daniel.shahaf.name>.
Branko Čibej wrote on Sat, Sep 01, 2012 at 06:55:40 +0200:
> On 01.09.2012 06:48, brane@apache.org wrote:
> > Author: brane
> > Date: Sat Sep  1 04:48:26 2012
> > New Revision: 1379689
> >
> > URL: http://svn.apache.org/viewvc?rev=1379689&view=rev
> > Log:
> > First step towards making client version informatin usable by other than
> > the svn command-line client.
> >
> > * subversion/libsvn_subr/opt.h (svn_opt__get_version_info): Renamed from
> >   svn_opt__print_version_info and prototype changed to return a string.
> >   Updated docstring.
> 
> The plan here is to make svn_opt__get_version_info public, so that other
> clients built on top of the core Subversion libraries -- e.g.,
> TortoiseSVN -- can use it directly instead of having to construct their
> own version info.
> 
> I /think/ this would be a useful addition to the API, but would welcome
> any comments on this plan.
> 

Currently the function constructs and returns a string.  For API use
maybe it should return a struct?

> -- Brane
> 
> -- 
> Certified & Supported Apache Subversion Downloads:
> http://www.wandisco.com/subversion/download
> 

Re: svn commit: r1379689 - in /subversion/trunk/subversion/libsvn_subr: deprecated.c opt.c opt.h

Posted by Branko Čibej <br...@wandisco.com>.
On 01.09.2012 06:48, brane@apache.org wrote:
> Author: brane
> Date: Sat Sep  1 04:48:26 2012
> New Revision: 1379689
>
> URL: http://svn.apache.org/viewvc?rev=1379689&view=rev
> Log:
> First step towards making client version informatin usable by other than
> the svn command-line client.
>
> * subversion/libsvn_subr/opt.h (svn_opt__get_version_info): Renamed from
>   svn_opt__print_version_info and prototype changed to return a string.
>   Updated docstring.

The plan here is to make svn_opt__get_version_info public, so that other
clients built on top of the core Subversion libraries -- e.g.,
TortoiseSVN -- can use it directly instead of having to construct their
own version info.

I /think/ this would be a useful addition to the API, but would welcome
any comments on this plan.

-- Brane

-- 
Certified & Supported Apache Subversion Downloads:
http://www.wandisco.com/subversion/download