emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 89187e9 1/2: Revert "Add support for arguments in A


From: Reuben Thomas
Subject: [Emacs-diffs] master 89187e9 1/2: Revert "Add support for arguments in ALTERNATE_EDITOR to emacsclient"
Date: Mon, 7 Aug 2017 16:59:25 -0400 (EDT)

branch: master
commit 89187e93d220ac5e2177c7c769ae6a0e9966d0f5
Author: Reuben Thomas <address@hidden>
Commit: Reuben Thomas <address@hidden>

    Revert "Add support for arguments in ALTERNATE_EDITOR to emacsclient"
    
    This reverts commit 28f1fe97daa13e13714e6c43c9a6fbb0c0e99a26.
---
 etc/NEWS                          |  4 ---
 lib-src/emacsclient.c             | 73 ++++++++++-----------------------------
 test/lib-src/emacsclient-tests.el | 33 ------------------
 3 files changed, 18 insertions(+), 92 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index f18837a..58b0834 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -505,10 +505,6 @@ Linum mode and all similar packages are henceforth 
becoming obsolete.
 Users and developers are encouraged to switch to this new feature
 instead.
 
-+++
-** emacsclient now accepts command-line options in ALTERNATE_EDITOR
-and --alternate-editor. For example, ALTERNATE_EDITOR="emacs -Q -nw".
-
 
 * Editing Changes in Emacs 26.1
 
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index 32b8c03..f1d4e89 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -110,9 +110,6 @@ char *w32_getenv (const char *);
 /* Name used to invoke this program.  */
 const char *progname;
 
-/* The first argument to main.  */
-int main_argc;
-
 /* The second argument to main.  */
 char **main_argv;
 
@@ -204,35 +201,6 @@ xmalloc (size_t size)
   return result;
 }
 
-/* Like realloc but get fatal error if memory is exhausted.  */
-
-static void *
-xrealloc (void *ptr, size_t size)
-{
-  void *result = realloc (ptr, size);
-  if (result == NULL)
-    {
-      perror ("realloc");
-      exit (EXIT_FAILURE);
-    }
-  return result;
-}
-
-/* Like strdup but get a fatal error if memory is exhausted. */
-char *xstrdup (const char *);
-
-char *
-xstrdup (const char *s)
-{
-  char *result = strdup (s);
-  if (result == NULL)
-    {
-      perror ("strdup");
-      exit (EXIT_FAILURE);
-    }
-  return result;
-}
-
 /* From sysdep.c */
 #if !defined (HAVE_GET_CURRENT_DIR_NAME) || defined 
(BROKEN_GET_CURRENT_DIR_NAME)
 
@@ -296,6 +264,21 @@ get_current_dir_name (void)
 
 #ifdef WINDOWSNT
 
+/* Like strdup but get a fatal error if memory is exhausted. */
+char *xstrdup (const char *);
+
+char *
+xstrdup (const char *s)
+{
+  char *result = strdup (s);
+  if (result == NULL)
+    {
+      perror ("strdup");
+      exit (EXIT_FAILURE);
+    }
+  return result;
+}
+
 #define REG_ROOT "SOFTWARE\\GNU\\Emacs"
 
 char *w32_get_resource (HKEY, const char *, LPDWORD);
@@ -690,7 +673,7 @@ Report bugs with M-x report-emacs-bug.\n");
 }
 
 /* Try to run a different command, or --if no alternate editor is
-   defined-- exit with an decoderde.
+   defined-- exit with an errorcode.
    Uses argv, but gets it from the global variable main_argv.  */
 
 static _Noreturn void
@@ -698,27 +681,9 @@ fail (void)
 {
   if (alternate_editor)
     {
-      size_t extra_args_size = (main_argc - optind + 1) * sizeof (char *);
-      size_t new_argv_size = extra_args_size;
-      char **new_argv = NULL;
-      /* Needed because strtok overwrites its input.  */
-      char *s = xstrdup (alternate_editor);
-      unsigned toks = 0;
-      char *tok = strtok(s, " ");
-
-      /* Unpack alternate_editor's space-separated tokens into new_argv.  */
-      do
-        {
-          toks++;
-          new_argv = xrealloc (new_argv, new_argv_size + toks * sizeof (char 
*));
-          new_argv[toks - 1] = tok;
-        }
-      while ((tok = strtok (NULL, " ")));
-
-      /* Append main_argv arguments to new_argv.  */
-      memcpy (&new_argv[toks], main_argv + optind, extra_args_size);
+      int i = optind - 1;
 
-      execvp (s, new_argv);
+      execvp (alternate_editor, main_argv + i);
       message (true, "%s: error executing alternate editor \"%s\"\n",
               progname, alternate_editor);
     }
@@ -731,7 +696,6 @@ fail (void)
 int
 main (int argc, char **argv)
 {
-  main_argc = argc;
   main_argv = argv;
   progname = argv[0];
   message (true, "%s: Sorry, the Emacs server is supported only\n"
@@ -1665,7 +1629,6 @@ main (int argc, char **argv)
   int start_daemon_if_needed;
   int exit_status = EXIT_SUCCESS;
 
-  main_argc = argc;
   main_argv = argv;
   progname = argv[0];
 
diff --git a/test/lib-src/emacsclient-tests.el 
b/test/lib-src/emacsclient-tests.el
deleted file mode 100644
index b06a6f5..0000000
--- a/test/lib-src/emacsclient-tests.el
+++ /dev/null
@@ -1,33 +0,0 @@
-;;; process-tests.el --- Test emacsclient
-
-;; Copyright (C) 2016 Free Software Foundation, Inc.
-
-;; This program is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-
-;;
-
-;;; Code:
-
-(require 'ert)
-
-(ert-deftest emacsclient-test-alternate-editor-allows-arguments ()
-  (setenv "ALTERNATE_EDITOR" "emacs --batch")
-  (should
-   (= 0
-      (call-process "emacsclient" nil nil nil "foo"))))
-
-(provide 'emacsclient-tests)
-;; emacsclient-tests.el ends here.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]