diff options
| author | Dmitry Antipov | 2015-01-14 10:08:44 +0300 |
|---|---|---|
| committer | Dmitry Antipov | 2015-01-14 10:08:44 +0300 |
| commit | d7e26b44109f4068d41a075fa89d11c1a8156f66 (patch) | |
| tree | 141efe83d87a6bfceeadb4e04e38979e5df3c8c1 /src | |
| parent | 01ebf7a3655541ef09cee068bddffbc1b38c69c8 (diff) | |
| download | emacs-d7e26b44109f4068d41a075fa89d11c1a8156f66.tar.gz emacs-d7e26b44109f4068d41a075fa89d11c1a8156f66.zip | |
Consolidate common path transformation code.
* process.h (remove_slash_colon): New function.
* callproc.c (encode_current_directory, call_process):
* process.c (Fstart_process): Use it.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 4 | ||||
| -rw-r--r-- | src/callproc.c | 13 | ||||
| -rw-r--r-- | src/process.c | 7 | ||||
| -rw-r--r-- | src/process.h | 13 |
4 files changed, 23 insertions, 14 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 5055ed16fb4..12678166317 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -6,6 +6,10 @@ | |||
| 6 | Do not check for STRING_MULTIBYTE because encode_file_name | 6 | Do not check for STRING_MULTIBYTE because encode_file_name |
| 7 | is a no-op for unibyte strings. | 7 | is a no-op for unibyte strings. |
| 8 | 8 | ||
| 9 | * process.h (remove_slash_colon): New function. | ||
| 10 | * callproc.c (encode_current_directory, call_process): | ||
| 11 | * process.c (Fstart_process): Use it. | ||
| 12 | |||
| 9 | 2015-01-14 Paul Eggert <eggert@cs.ucla.edu> | 13 | 2015-01-14 Paul Eggert <eggert@cs.ucla.edu> |
| 10 | 14 | ||
| 11 | Use bool for boolean in xmenu.c, xml.c | 15 | Use bool for boolean in xmenu.c, xml.c |
diff --git a/src/callproc.c b/src/callproc.c index 970a2017b38..63ab9bf70db 100644 --- a/src/callproc.c +++ b/src/callproc.c | |||
| @@ -131,11 +131,9 @@ encode_current_directory (void) | |||
| 131 | report_file_error ("Setting current directory", | 131 | report_file_error ("Setting current directory", |
| 132 | BVAR (current_buffer, directory)); | 132 | BVAR (current_buffer, directory)); |
| 133 | 133 | ||
| 134 | /* Remove "/:" from dir. */ | 134 | /* Remove "/:" from DIR and encode it. */ |
| 135 | if (! NILP (Fstring_match (build_string ("^/:"), dir, Qnil))) | 135 | dir = ENCODE_FILE (remove_slash_colon (dir)); |
| 136 | dir = Fsubstring (dir, make_number (2), Qnil); | ||
| 137 | 136 | ||
| 138 | dir = ENCODE_FILE (dir); | ||
| 139 | if (! file_accessible_directory_p (dir)) | 137 | if (! file_accessible_directory_p (dir)) |
| 140 | report_file_error ("Setting current directory", | 138 | report_file_error ("Setting current directory", |
| 141 | BVAR (current_buffer, directory)); | 139 | BVAR (current_buffer, directory)); |
| @@ -467,11 +465,8 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd, | |||
| 467 | report_file_error ("Searching for program", args[0]); | 465 | report_file_error ("Searching for program", args[0]); |
| 468 | } | 466 | } |
| 469 | 467 | ||
| 470 | /* If program file name starts with /: for quoting a magic name, | 468 | /* Remove "/:" from PATH. */ |
| 471 | discard that. */ | 469 | path = remove_slash_colon (path); |
| 472 | if (SBYTES (path) > 2 && SREF (path, 0) == '/' | ||
| 473 | && SREF (path, 1) == ':') | ||
| 474 | path = Fsubstring (path, make_number (2), Qnil); | ||
| 475 | 470 | ||
| 476 | SAFE_NALLOCA (new_argv, 1, nargs < 4 ? 2 : nargs - 2); | 471 | SAFE_NALLOCA (new_argv, 1, nargs < 4 ? 2 : nargs - 2); |
| 477 | 472 | ||
diff --git a/src/process.c b/src/process.c index 9015383b8b5..166bf851a8e 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -1517,11 +1517,8 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */) | |||
| 1517 | tem = program; | 1517 | tem = program; |
| 1518 | } | 1518 | } |
| 1519 | 1519 | ||
| 1520 | /* If program file name starts with /: for quoting a magic name, | 1520 | /* Remove "/:" from TEM. */ |
| 1521 | discard that. */ | 1521 | tem = remove_slash_colon (tem); |
| 1522 | if (SBYTES (tem) > 2 && SREF (tem, 0) == '/' | ||
| 1523 | && SREF (tem, 1) == ':') | ||
| 1524 | tem = Fsubstring (tem, make_number (2), Qnil); | ||
| 1525 | 1522 | ||
| 1526 | { | 1523 | { |
| 1527 | Lisp_Object arg_encoding = Qnil; | 1524 | Lisp_Object arg_encoding = Qnil; |
diff --git a/src/process.h b/src/process.h index 7803672d61a..58b1daecfe6 100644 --- a/src/process.h +++ b/src/process.h | |||
| @@ -237,4 +237,17 @@ extern Lisp_Object network_interface_list (void); | |||
| 237 | extern Lisp_Object network_interface_info (Lisp_Object); | 237 | extern Lisp_Object network_interface_info (Lisp_Object); |
| 238 | #endif | 238 | #endif |
| 239 | 239 | ||
| 240 | /* If program file NAME starts with /: for quoting a magic | ||
| 241 | name, remove that, preserving the multibyteness of NAME. */ | ||
| 242 | |||
| 243 | INLINE Lisp_Object | ||
| 244 | remove_slash_colon (Lisp_Object name) | ||
| 245 | { | ||
| 246 | return | ||
| 247 | ((SBYTES (name) > 2 && SREF (name, 0) == '/' && SREF (name, 1) == ':') | ||
| 248 | ? make_specified_string (SSDATA (name) + 2, SCHARS (name) - 2, | ||
| 249 | SBYTES (name) - 2, STRING_MULTIBYTE (name)) | ||
| 250 | : name); | ||
| 251 | } | ||
| 252 | |||
| 240 | INLINE_HEADER_END | 253 | INLINE_HEADER_END |