From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Richard Stallman Newsgroups: gmane.emacs.devel Subject: Re: extensions for emacsclient (CVS version) Date: Thu, 11 Sep 2003 09:16:38 -0400 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: References: Reply-To: rms@gnu.org NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1063287168 21749 80.91.224.253 (11 Sep 2003 13:32:48 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 11 Sep 2003 13:32:48 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Thu Sep 11 15:32:46 2003 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19xRZ0-0000vO-00 for ; Thu, 11 Sep 2003 15:32:46 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 19xRZq-00019A-00 for ; Thu, 11 Sep 2003 15:33:38 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.22) id 19xRTi-0004rU-GA for emacs-devel@quimby.gnus.org; Thu, 11 Sep 2003 09:27:18 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.22) id 19xRTH-0004qh-D5 for emacs-devel@gnu.org; Thu, 11 Sep 2003 09:26:51 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.22) id 19xRQN-0003ql-Sf for emacs-devel@gnu.org; Thu, 11 Sep 2003 09:23:53 -0400 Original-Received: from [199.232.76.164] (helo=fencepost.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.22) id 19xROk-0003Qb-9t for emacs-devel@gnu.org; Thu, 11 Sep 2003 09:22:10 -0400 Original-Received: from rms by fencepost.gnu.org with local (Exim 4.20) id 19xRJO-0005ws-Vm; Thu, 11 Sep 2003 09:16:38 -0400 Original-To: =?iso-8859-1?q?Andreas_B=FCsching?= In-reply-to: (message from =?iso-8859-1?q?Andreas_B=FCsching?= on Wed, 10 Sep 2003 10:26:04 +0200) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:16297 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:16297 This change would be good, but it has a bug: if the argument is too long, the sprintf will clobber something. Here's a version that fixes that problem in a clean way. Does it work? cd ~/emacs/lib-src/ diff -c /home/rms/emacs/lib-src/emacsclient.c.\~1\~ /home/rms/emacs/lib-src/emacsclient.c *************** *** 67,72 **** --- 67,75 ---- is not running. --alternate-editor. */ const char * alternate_editor = NULL; + /* If non-NULL, thefilename of the UNIX socket */ + char *socket_name = NULL; + void print_help_and_exit (); struct option longopts[] = *************** *** 76,81 **** --- 79,85 ---- { "help", no_argument, NULL, 'H' }, { "version", no_argument, NULL, 'V' }, { "alternate-editor", required_argument, NULL, 'a' }, + { "socket-name", required_argument, NULL, 's' }, { "display", required_argument, NULL, 'd' }, { 0, 0, 0, 0 } }; *************** *** 91,97 **** while (1) { int opt = getopt_long (argc, argv, ! "VHnea:d:", longopts, 0); if (opt == EOF) break; --- 95,101 ---- while (1) { int opt = getopt_long (argc, argv, ! "VHnea:s:d:", longopts, 0); if (opt == EOF) break; *************** *** 109,114 **** --- 113,122 ---- alternate_editor = optarg; break; + case 's': + socket_name = optarg; + break; + case 'd': display = optarg; break; *************** *** 136,155 **** void print_help_and_exit () { ! fprintf (stderr, ! "Usage: %s [OPTIONS] FILE...\n\ Tell the Emacs server to visit the specified files.\n\ Every FILE can be either just a FILENAME or [+LINE[:COLUMN]] FILENAME.\n\ The following OPTIONS are accepted:\n\ -V, --version Just print a version info and return\n\ -H, --help Print this usage information message\n\ -n, --no-wait Don't wait for the server to return\n\ -e, --eval Evaluate the FILE arguments as ELisp expressions\n\ -d, --display=DISPLAY Visit the file in the given display\n\ -a, --alternate-editor=EDITOR\n\ Editor to fallback to if the server is not running\n\ Report bugs to bug-gnu-emacs@gnu.org.\n", progname); ! exit (1); } /* Return a copy of NAME, inserting a & --- 149,172 ---- void print_help_and_exit () { ! printf ( ! "Usage: %s [OPTIONS] FILE...\n\ Tell the Emacs server to visit the specified files.\n\ Every FILE can be either just a FILENAME or [+LINE[:COLUMN]] FILENAME.\n\ + \n\ The following OPTIONS are accepted:\n\ -V, --version Just print a version info and return\n\ -H, --help Print this usage information message\n\ -n, --no-wait Don't wait for the server to return\n\ -e, --eval Evaluate the FILE arguments as ELisp expressions\n\ -d, --display=DISPLAY Visit the file in the given display\n\ + -s, --socket-name=FILENAME\n\ + Set the filename of the UNIX socket for communication\n\ -a, --alternate-editor=EDITOR\n\ Editor to fallback to if the server is not running\n\ + \n\ Report bugs to bug-gnu-emacs@gnu.org.\n", progname); ! exit (0); } /* Return a copy of NAME, inserting a & *************** *** 336,342 **** { int sock_status = 0; ! sprintf (server.sun_path, "/tmp/esrv%d-%s", (int) geteuid (), system_name); /* See if the socket exists, and if it's owned by us. */ sock_status = socket_status (server.sun_path); --- 357,374 ---- { int sock_status = 0; ! if (! socket_name) ! { ! socket_name = alloca (system_name_length + 100); ! sprintf (socket_name, "/tmp/emacs%d-%s/server", ! (int) geteuid (), system_name); ! } ! ! if (strlen (socket_name) < sizeof (server.sun_path)) ! strcpy (server.sun_path, socket_name); ! else ! fprintf (stderr, "%s: socket-name %s too long", ! argv[0], socket_name); /* See if the socket exists, and if it's owned by us. */ sock_status = socket_status (server.sun_path);