[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master d7e26b4: Consolidate common path transformation cod
From: |
Dmitry Antipov |
Subject: |
[Emacs-diffs] master d7e26b4: Consolidate common path transformation code. |
Date: |
Wed, 14 Jan 2015 07:12:11 +0000 |
branch: master
commit d7e26b44109f4068d41a075fa89d11c1a8156f66
Author: Dmitry Antipov <address@hidden>
Commit: Dmitry Antipov <address@hidden>
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.
---
src/ChangeLog | 4 ++++
src/callproc.c | 13 ++++---------
src/process.c | 7 ++-----
src/process.h | 13 +++++++++++++
4 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/src/ChangeLog b/src/ChangeLog
index 5055ed1..1267816 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -6,6 +6,10 @@
Do not check for STRING_MULTIBYTE because encode_file_name
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 <address@hidden>
Use bool for boolean in xmenu.c, xml.c
diff --git a/src/callproc.c b/src/callproc.c
index 970a201..63ab9bf 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -131,11 +131,9 @@ encode_current_directory (void)
report_file_error ("Setting current directory",
BVAR (current_buffer, directory));
- /* Remove "/:" from dir. */
- if (! NILP (Fstring_match (build_string ("^/:"), dir, Qnil)))
- dir = Fsubstring (dir, make_number (2), Qnil);
+ /* Remove "/:" from DIR and encode it. */
+ dir = ENCODE_FILE (remove_slash_colon (dir));
- dir = ENCODE_FILE (dir);
if (! file_accessible_directory_p (dir))
report_file_error ("Setting current directory",
BVAR (current_buffer, directory));
@@ -467,11 +465,8 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int
filefd,
report_file_error ("Searching for program", args[0]);
}
- /* If program file name starts with /: for quoting a magic name,
- discard that. */
- if (SBYTES (path) > 2 && SREF (path, 0) == '/'
- && SREF (path, 1) == ':')
- path = Fsubstring (path, make_number (2), Qnil);
+ /* Remove "/:" from PATH. */
+ path = remove_slash_colon (path);
SAFE_NALLOCA (new_argv, 1, nargs < 4 ? 2 : nargs - 2);
diff --git a/src/process.c b/src/process.c
index 9015383..166bf85 100644
--- a/src/process.c
+++ b/src/process.c
@@ -1517,11 +1517,8 @@ usage: (start-process NAME BUFFER PROGRAM &rest
PROGRAM-ARGS) */)
tem = program;
}
- /* If program file name starts with /: for quoting a magic name,
- discard that. */
- if (SBYTES (tem) > 2 && SREF (tem, 0) == '/'
- && SREF (tem, 1) == ':')
- tem = Fsubstring (tem, make_number (2), Qnil);
+ /* Remove "/:" from TEM. */
+ tem = remove_slash_colon (tem);
{
Lisp_Object arg_encoding = Qnil;
diff --git a/src/process.h b/src/process.h
index 7803672..58b1dae 100644
--- a/src/process.h
+++ b/src/process.h
@@ -237,4 +237,17 @@ extern Lisp_Object network_interface_list (void);
extern Lisp_Object network_interface_info (Lisp_Object);
#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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master d7e26b4: Consolidate common path transformation code.,
Dmitry Antipov <=