From: Richard Stallman <rms@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: extensions for emacsclient (CVS version)
Date: Thu, 11 Sep 2003 09:16:38 -0400 [thread overview]
Message-ID: <E19xRJO-0005ws-Vm@fencepost.gnu.org> (raw)
In-Reply-To: <xtzn0dd123n.fsf@dataman.informatik.uni-bremen.de> (message from Andreas Büsching on Wed, 10 Sep 2003 10:26:04 +0200)
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);
next prev parent reply other threads:[~2003-09-11 13:16 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-09-10 8:26 extensions for emacsclient (CVS version) Andreas Büsching
2003-09-10 8:44 ` Miles Bader
2003-09-10 9:00 ` Andreas Büsching
2003-09-10 9:30 ` Miles Bader
2003-09-10 10:56 ` Andreas Büsching
2003-09-10 11:36 ` Miles Bader
2003-09-10 11:40 ` Andreas Büsching
2003-09-10 12:38 ` Stefan Monnier
2003-09-10 13:45 ` Andreas Büsching
2003-09-10 14:37 ` Miles Bader
2003-09-10 15:00 ` Andreas Büsching
2003-09-10 15:09 ` Miles Bader
2003-09-11 6:57 ` Andreas Büsching
2003-09-11 23:47 ` Richard Stallman
2003-09-12 5:22 ` Andreas Buesching
2003-09-12 21:06 ` Richard Stallman
2003-09-12 7:35 ` Andreas Büsching
2003-09-10 14:41 ` Stefan Monnier
2003-09-10 15:02 ` Andreas Büsching
2003-09-10 15:08 ` Stefan Monnier
2003-09-10 16:13 ` David Kastrup
2003-09-10 16:22 ` Andreas Büsching
2003-09-10 16:50 ` David Kastrup
2003-09-10 19:40 ` Alex Schroeder
2003-09-11 5:20 ` Andreas Buesching
2003-09-11 19:30 ` Andreas Buesching
2003-09-11 21:22 ` Miles Bader
2003-09-12 21:06 ` Richard Stallman
2003-09-11 23:46 ` Richard Stallman
2003-09-12 15:38 ` Stefan Monnier
2003-09-12 22:49 ` Alex Schroeder
2003-09-13 13:56 ` Richard Stallman
2003-09-11 13:16 ` Richard Stallman [this message]
2003-09-11 14:15 ` Andreas Büsching
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E19xRJO-0005ws-Vm@fencepost.gnu.org \
--to=rms@gnu.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).