diff options
| author | Eli Zaretskii | 2003-09-28 08:24:56 +0000 |
|---|---|---|
| committer | Eli Zaretskii | 2003-09-28 08:24:56 +0000 |
| commit | 872093579a7ca35aa65a89d4050204868b82d5ce (patch) | |
| tree | 31439c1736acd30574b1f22308ed42d9ffa02298 /lib-src | |
| parent | e04e1ce238b1b588a23a7943eccda2f5bdb9aae1 (diff) | |
| download | emacs-872093579a7ca35aa65a89d4050204868b82d5ce.tar.gz emacs-872093579a7ca35aa65a89d4050204868b82d5ce.zip | |
(quote_file_name): Print the result instead of
returning it. Fix the return type accordingly.
(main): Under --eval, don't fail if left with additional
arguments after decoding options. Quote file names.
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/emacsclient.c | 62 |
1 files changed, 44 insertions, 18 deletions
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c index f0090752fab..dbdde16db02 100644 --- a/lib-src/emacsclient.c +++ b/lib-src/emacsclient.c | |||
| @@ -169,14 +169,15 @@ Report bugs to bug-gnu-emacs@gnu.org.\n", progname); | |||
| 169 | exit (0); | 169 | exit (0); |
| 170 | } | 170 | } |
| 171 | 171 | ||
| 172 | /* Return a copy of NAME, inserting a & | 172 | /* Inserting a & |
| 173 | before each &, each space, each newline, and any initial -. | 173 | before each &, each space, each newline, and any initial -. |
| 174 | Change spaces to underscores, too, so that the | 174 | Change spaces to underscores, too, so that the |
| 175 | return value never contains a space. */ | 175 | return value never contains a space. */ |
| 176 | 176 | ||
| 177 | char * | 177 | void |
| 178 | quote_file_name (name) | 178 | quote_file_name (name, stream) |
| 179 | char *name; | 179 | char *name; |
| 180 | FILE *stream; | ||
| 180 | { | 181 | { |
| 181 | char *copy = (char *) malloc (strlen (name) * 2 + 1); | 182 | char *copy = (char *) malloc (strlen (name) * 2 + 1); |
| 182 | char *p, *q; | 183 | char *p, *q; |
| @@ -206,7 +207,9 @@ quote_file_name (name) | |||
| 206 | } | 207 | } |
| 207 | *q++ = 0; | 208 | *q++ = 0; |
| 208 | 209 | ||
| 209 | return copy; | 210 | fprintf (stream, copy); |
| 211 | |||
| 212 | free (copy); | ||
| 210 | } | 213 | } |
| 211 | 214 | ||
| 212 | /* Like malloc but get fatal error if memory is exhausted. */ | 215 | /* Like malloc but get fatal error if memory is exhausted. */ |
| @@ -310,7 +313,7 @@ main (argc, argv) | |||
| 310 | /* Process options. */ | 313 | /* Process options. */ |
| 311 | decode_options (argc, argv); | 314 | decode_options (argc, argv); |
| 312 | 315 | ||
| 313 | if (argc - optind < 1) | 316 | if ((argc - optind < 1) && !eval) |
| 314 | { | 317 | { |
| 315 | fprintf (stderr, "%s: file name or argument required\n", progname); | 318 | fprintf (stderr, "%s: file name or argument required\n", progname); |
| 316 | fprintf (stderr, "Try `%s --help' for more information\n", progname); | 319 | fprintf (stderr, "Try `%s --help' for more information\n", progname); |
| @@ -476,24 +479,47 @@ To start the server in Emacs, type \"M-x server-start\".\n", | |||
| 476 | fprintf (out, "-eval "); | 479 | fprintf (out, "-eval "); |
| 477 | 480 | ||
| 478 | if (display) | 481 | if (display) |
| 479 | fprintf (out, "-display %s ", quote_file_name (display)); | 482 | { |
| 483 | fprintf (out, "-display "); | ||
| 484 | quote_file_name (display, out); | ||
| 485 | fprintf (out, " "); | ||
| 486 | } | ||
| 480 | 487 | ||
| 481 | for (i = optind; i < argc; i++) | 488 | if ((argc - optind > 0)) |
| 482 | { | 489 | { |
| 483 | if (eval) | 490 | for (i = optind; i < argc; i++) |
| 484 | ; /* Don't prepend any cwd or anything like that. */ | ||
| 485 | else if (*argv[i] == '+') | ||
| 486 | { | 491 | { |
| 487 | char *p = argv[i] + 1; | 492 | if (eval) |
| 488 | while (isdigit ((unsigned char) *p) || *p == ':') p++; | 493 | ; /* Don't prepend any cwd or anything like that. */ |
| 489 | if (*p != 0) | 494 | else if (*argv[i] == '+') |
| 490 | fprintf (out, "%s/", quote_file_name (cwd)); | 495 | { |
| 496 | char *p = argv[i] + 1; | ||
| 497 | while (isdigit ((unsigned char) *p) || *p == ':') p++; | ||
| 498 | if (*p != 0) | ||
| 499 | { | ||
| 500 | quote_file_name (cwd, out); | ||
| 501 | fprintf (out, "/"); | ||
| 502 | } | ||
| 503 | } | ||
| 504 | else if (*argv[i] != '/') | ||
| 505 | { | ||
| 506 | quote_file_name (cwd, out); | ||
| 507 | fprintf (out, "/"); | ||
| 508 | } | ||
| 509 | |||
| 510 | quote_file_name (argv[i], out); | ||
| 511 | fprintf (out, " "); | ||
| 491 | } | 512 | } |
| 492 | else if (*argv[i] != '/') | ||
| 493 | fprintf (out, "%s/", quote_file_name (cwd)); | ||
| 494 | |||
| 495 | fprintf (out, "%s ", quote_file_name (argv[i])); | ||
| 496 | } | 513 | } |
| 514 | else | ||
| 515 | { | ||
| 516 | while ((str = fgets (string, BUFSIZ, stdin))) | ||
| 517 | { | ||
| 518 | quote_file_name (str, out); | ||
| 519 | } | ||
| 520 | fprintf (out, " "); | ||
| 521 | } | ||
| 522 | |||
| 497 | fprintf (out, "\n"); | 523 | fprintf (out, "\n"); |
| 498 | fflush (out); | 524 | fflush (out); |
| 499 | 525 | ||