subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From julianf...@apache.org
Subject svn commit: r1672358 - in /subversion/branches/move-tracking-2/subversion: libsvn_subr/prompt.c svnmover/svnmover.c
Date Thu, 09 Apr 2015 14:04:06 GMT
Author: julianfoad
Date: Thu Apr  9 14:04:06 2015
New Revision: 1672358

URL: http://svn.apache.org/r1672358
Log:
On the 'move-tracking-2' branch: Move the 'linenoise' line editing and
history functionality inside the 'prompt' function.

This avoids including the linenoise C file directly into the svnmover C
file, and so avoids seeing all the compiler warnings it elicits every time
we rebuild svnmover. Now we only see them when we rebuild prompt.c.

* subversion/libsvn_subr/prompt.c
  (svn_cmdline_prompt_user2): Move the linenoise call to here...

* subversion/svnmover/svnmover.c
  (read_words): .. from here.

Modified:
    subversion/branches/move-tracking-2/subversion/libsvn_subr/prompt.c
    subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c

Modified: subversion/branches/move-tracking-2/subversion/libsvn_subr/prompt.c
URL: http://svn.apache.org/viewvc/subversion/branches/move-tracking-2/subversion/libsvn_subr/prompt.c?rev=1672358&r1=1672357&r2=1672358&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/libsvn_subr/prompt.c (original)
+++ subversion/branches/move-tracking-2/subversion/libsvn_subr/prompt.c Thu Apr  9 14:04:06
2015
@@ -48,6 +48,11 @@
 #include <termios.h>
 #endif
 
+#undef HAVE_LINENOISE
+#ifdef HAVE_LINENOISE
+#include "linenoise/linenoise.c"
+#endif
+
 
 
 /* Descriptor of an open terminal */
@@ -925,10 +930,28 @@ svn_cmdline_prompt_user2(const char **re
                          svn_cmdline_prompt_baton_t *baton,
                          apr_pool_t *pool)
 {
+#ifdef HAVE_LINENOISE
+  char *input;
+
+  input = linenoise(prompt_str);
+  if (! input)
+    {
+      return svn_error_create(SVN_ERR_CANCELLED, NULL, NULL);
+    }
+  /* add the line to the recallable history (if non-empty) */
+  if (! (input && *input))
+    {
+      linenoiseHistoryAdd(input);
+    }
+  *result = apr_pstrdup(pool, input);
+  free(input);
+  return SVN_NO_ERROR;
+#else
   /* XXX: We know prompt doesn't use the new members
    * of svn_cmdline_prompt_baton2_t. */
   return prompt(result, prompt_str, FALSE /* don't hide input */,
                 (svn_cmdline_prompt_baton2_t *)baton, pool);
+#endif
 }
 
 /* This implements 'svn_auth_gnome_keyring_unlock_prompt_func_t'. */

Modified: subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c
URL: http://svn.apache.org/viewvc/subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c?rev=1672358&r1=1672357&r2=1672358&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c (original)
+++ subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c Thu Apr  9 14:04:06
2015
@@ -24,10 +24,6 @@
 #include <stdio.h>
 #include <string.h>
 #include <assert.h>
-#define HAVE_LINENOISE
-#ifdef HAVE_LINENOISE
-#include "../libsvn_subr/linenoise/linenoise.c"
-#endif
 
 #include <apr_lib.h>
 
@@ -2145,25 +2141,18 @@ read_words(apr_array_header_t **words,
            const char *prompt,
            apr_pool_t *result_pool)
 {
-#ifdef HAVE_LINENOISE
-  char *input;
+  svn_error_t *err;
+  const char *input;
 
-  input = linenoise(prompt);
-  if (! input)
+  err = svn_cmdline_prompt_user2(&input, prompt, NULL, result_pool);
+  if (err && (err->apr_err == SVN_ERR_CANCELLED || err->apr_err == APR_EOF))
     {
       *words = NULL;
+      svn_error_clear(err);
       return SVN_NO_ERROR;
     }
+  SVN_ERR(err);
   *words = svn_cstring_split(input, " ", TRUE /*chop_whitespace*/, result_pool);
-  if ((*words)->nelts)
-    linenoiseHistoryAdd(input);
-  free(input);
-#else
-  const char *input;
-
-  SVN_ERR(svn_cmdline_prompt_user2(&input, prompt, NULL, pool));
-  *words = svn_cstring_split(input, " ", TRUE /*chop_whitespace*/, pool);
-#endif
 
   return SVN_NO_ERROR;
 }



Mime
View raw message