Commit d7e26b44 authored by Dmitry Antipov's avatar Dmitry Antipov
Browse files

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.
parent 01ebf7a3
...@@ -6,6 +6,10 @@ ...@@ -6,6 +6,10 @@
Do not check for STRING_MULTIBYTE because encode_file_name Do not check for STRING_MULTIBYTE because encode_file_name
is a no-op for unibyte strings. is a no-op for unibyte strings.
   
* process.h (remove_slash_colon): New function.
* callproc.c (encode_current_directory, call_process):
* process.c (Fstart_process): Use it.
2015-01-14 Paul Eggert <eggert@cs.ucla.edu> 2015-01-14 Paul Eggert <eggert@cs.ucla.edu>
   
Use bool for boolean in xmenu.c, xml.c Use bool for boolean in xmenu.c, xml.c
......
...@@ -131,11 +131,9 @@ encode_current_directory (void) ...@@ -131,11 +131,9 @@ encode_current_directory (void)
report_file_error ("Setting current directory", report_file_error ("Setting current directory",
BVAR (current_buffer, directory)); BVAR (current_buffer, directory));
/* Remove "/:" from dir. */ /* Remove "/:" from DIR and encode it. */
if (! NILP (Fstring_match (build_string ("^/:"), dir, Qnil))) dir = ENCODE_FILE (remove_slash_colon (dir));
dir = Fsubstring (dir, make_number (2), Qnil);
dir = ENCODE_FILE (dir);
if (! file_accessible_directory_p (dir)) if (! file_accessible_directory_p (dir))
report_file_error ("Setting current directory", report_file_error ("Setting current directory",
BVAR (current_buffer, directory)); BVAR (current_buffer, directory));
...@@ -467,11 +465,8 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd, ...@@ -467,11 +465,8 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd,
report_file_error ("Searching for program", args[0]); report_file_error ("Searching for program", args[0]);
} }
/* If program file name starts with /: for quoting a magic name, /* Remove "/:" from PATH. */
discard that. */ path = remove_slash_colon (path);
if (SBYTES (path) > 2 && SREF (path, 0) == '/'
&& SREF (path, 1) == ':')
path = Fsubstring (path, make_number (2), Qnil);
SAFE_NALLOCA (new_argv, 1, nargs < 4 ? 2 : nargs - 2); SAFE_NALLOCA (new_argv, 1, nargs < 4 ? 2 : nargs - 2);
......
...@@ -1517,11 +1517,8 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */) ...@@ -1517,11 +1517,8 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */)
tem = program; tem = program;
} }
/* If program file name starts with /: for quoting a magic name, /* Remove "/:" from TEM. */
discard that. */ tem = remove_slash_colon (tem);
if (SBYTES (tem) > 2 && SREF (tem, 0) == '/'
&& SREF (tem, 1) == ':')
tem = Fsubstring (tem, make_number (2), Qnil);
{ {
Lisp_Object arg_encoding = Qnil; Lisp_Object arg_encoding = Qnil;
......
...@@ -237,4 +237,17 @@ extern Lisp_Object network_interface_list (void); ...@@ -237,4 +237,17 @@ extern Lisp_Object network_interface_list (void);
extern Lisp_Object network_interface_info (Lisp_Object); extern Lisp_Object network_interface_info (Lisp_Object);
#endif #endif
/* If program file NAME starts with /: for quoting a magic
name, remove that, preserving the multibyteness of NAME. */
INLINE Lisp_Object
remove_slash_colon (Lisp_Object name)
{
return
((SBYTES (name) > 2 && SREF (name, 0) == '/' && SREF (name, 1) == ':')
? make_specified_string (SSDATA (name) + 2, SCHARS (name) - 2,
SBYTES (name) - 2, STRING_MULTIBYTE (name))
: name);
}
INLINE_HEADER_END INLINE_HEADER_END
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment