[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/lib-src/emacsclient.c [lexbind]
From: |
Miles Bader |
Subject: |
[Emacs-diffs] Changes to emacs/lib-src/emacsclient.c [lexbind] |
Date: |
Tue, 14 Oct 2003 19:59:21 -0400 |
Index: emacs/lib-src/emacsclient.c
diff -c emacs/lib-src/emacsclient.c:1.50.4.1
emacs/lib-src/emacsclient.c:1.50.4.2
*** emacs/lib-src/emacsclient.c:1.50.4.1 Fri Apr 4 01:19:54 2003
--- emacs/lib-src/emacsclient.c Tue Oct 14 19:59:13 2003
***************
*** 67,72 ****
--- 67,75 ----
is not running. --alternate-editor. */
const char * alternate_editor = NULL;
+ /* If non-NULL, the filename 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;
***************
*** 152,157 ****
--- 160,167 ----
-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\
***************
*** 159,172 ****
exit (0);
}
! /* Return a copy of NAME, inserting a &
! before each &, each space, each newline, and any initial -.
! Change spaces to underscores, too, so that the
return value never contains a space. */
! char *
! quote_file_name (name)
char *name;
{
char *copy = (char *) malloc (strlen (name) * 2 + 1);
char *p, *q;
--- 169,182 ----
exit (0);
}
! /* In NAME, insert a & before each &, each space, each newline, and
! any initial -. Change spaces to underscores, too, so that the
return value never contains a space. */
! void
! quote_file_name (name, stream)
char *name;
+ FILE *stream;
{
char *copy = (char *) malloc (strlen (name) * 2 + 1);
char *p, *q;
***************
*** 196,202 ****
}
*q++ = 0;
! return copy;
}
/* Like malloc but get fatal error if memory is exhausted. */
--- 206,214 ----
}
*q++ = 0;
! fprintf (stream, copy);
!
! free (copy);
}
/* Like malloc but get fatal error if memory is exhausted. */
***************
*** 300,306 ****
/* Process options. */
decode_options (argc, argv);
! if (argc - optind < 1)
{
fprintf (stderr, "%s: file name or argument required\n", progname);
fprintf (stderr, "Try `%s --help' for more information\n", progname);
--- 312,318 ----
/* Process options. */
decode_options (argc, argv);
! if ((argc - optind < 1) && !eval)
{
fprintf (stderr, "%s: file name or argument required\n", progname);
fprintf (stderr, "Try `%s --help' for more information\n", progname);
***************
*** 347,353 ****
{
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);
--- 359,376 ----
{
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);
***************
*** 438,450 ****
if (cwd == 0)
{
/* getwd puts message in STRING if it fails. */
! fprintf (stderr, "%s: %s (%s)\n", argv[0],
#ifdef HAVE_GETCWD
! "Cannot get current working directory",
#else
! string,
#endif
- strerror (errno));
fail (argc, argv);
}
--- 461,473 ----
if (cwd == 0)
{
/* getwd puts message in STRING if it fails. */
!
#ifdef HAVE_GETCWD
! fprintf (stderr, "%s: %s (%s)\n", argv[0],
! "Cannot get current working directory", strerror (errno));
#else
! fprintf (stderr, "%s: %s (%s)\n", argv[0], string, strerror (errno));
#endif
fail (argc, argv);
}
***************
*** 455,478 ****
fprintf (out, "-eval ");
if (display)
! fprintf (out, "-display %s ", quote_file_name (display));
! for (i = optind; i < argc; i++)
{
! if (eval)
! ; /* Don't prepend any cwd or anything like that. */
! else if (*argv[i] == '+')
{
! char *p = argv[i] + 1;
! while (isdigit ((unsigned char) *p) || *p == ':') p++;
! if (*p != 0)
! fprintf (out, "%s/", quote_file_name (cwd));
! }
! else if (*argv[i] != '/')
! fprintf (out, "%s/", quote_file_name (cwd));
! fprintf (out, "%s ", quote_file_name (argv[i]));
}
fprintf (out, "\n");
fflush (out);
--- 478,524 ----
fprintf (out, "-eval ");
if (display)
! {
! fprintf (out, "-display ");
! quote_file_name (display, out);
! fprintf (out, " ");
! }
! if ((argc - optind > 0))
{
! for (i = optind; i < argc; i++)
{
! if (eval)
! ; /* Don't prepend any cwd or anything like that. */
! else if (*argv[i] == '+')
! {
! char *p = argv[i] + 1;
! while (isdigit ((unsigned char) *p) || *p == ':') p++;
! if (*p != 0)
! {
! quote_file_name (cwd, out);
! fprintf (out, "/");
! }
! }
! else if (*argv[i] != '/')
! {
! quote_file_name (cwd, out);
! fprintf (out, "/");
! }
! quote_file_name (argv[i], out);
! fprintf (out, " ");
! }
}
+ else
+ {
+ while ((str = fgets (string, BUFSIZ, stdin)))
+ {
+ quote_file_name (str, out);
+ }
+ fprintf (out, " ");
+ }
+
fprintf (out, "\n");
fflush (out);
***************
*** 519,521 ****
--- 565,570 ----
}
#endif /* ! HAVE_STRERROR */
+
+ /* arch-tag: f39bb9c4-73eb-477e-896d-50832e2ca9a7
+ (do not change this comment) */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] Changes to emacs/lib-src/emacsclient.c [lexbind],
Miles Bader <=