This patch:
* Renames decode-path to split-path. This name is much more
consistent with other functions (e.g. split-string).
* Introduces split-string-by-char, which is analogous to split-string,
only it splits by a single character. Ben is against this, but as
split-string is very slow and and we already have the code, I think
it makes sense to export it.
split-path was supposed to be implemented in terms of
split-string-by-char, but it turns out that it is called VERY early
during XEmacs startup, so that's impossible.
src/ChangeLog:
1998-05-16 Hrvoje Niksic <hniksic(a)srce.hr>
* emacs.c (decode_path): Eliminate compiler warning.
(Fdecode_path): Renamed to Fsplit_path.
(Fsplit_string_by_char): New function.
lisp/ChangeLog:
1998-05-16 Hrvoje Niksic <hniksic(a)srce.hr>
* loadup.el (really-early-error-handler): Ditto.
* update-elc.el: Ditto.
* setup-paths.el (paths-construct-exec-path): Ditto.
* make-docfile.el: Ditto.
* find-paths.el (paths-decode-directory-path): Use split-path
instead of decode-path.
* files.el (parse-colon-path): Update docstring reference.
--- etc/NEWS.orig Sat May 16 02:00:44 1998
+++ etc/NEWS Sat May 16 02:00:47 1998
@@ -304,10 +304,10 @@
** The new `lwarn' function, analogous to `lmessage', allows printing
a formatted warning, with a non-default CLASS or LABEL.
-** The new function `decode-path' can now be used to explode the
-components of a colon-separated search path into a list of strings.
+** The new function `split-path' can now be used to explode the
+components of a colon-separated search path into a list.
- (decode-path "foo:bar")
+ (split-path "foo:bar")
=> ("foo" "bar")
** Specifiers and symbols whose value is a specifier are now allowed
--- src/emacs.c.orig Sat May 16 00:56:40 1998
+++ src/emacs.c Sat May 16 02:02:16 1998
@@ -2449,56 +2449,58 @@
#define SEPCHAR ':'
#endif
-/* Parse PATH as a list of strings separated by SEPCHAR, and return
- the list of Lisp strings. PATH should be in internal format. */
+/* Split STRING into a list of substrings. The substrings are the
+ parts of original STRING separated by SEPCHAR. */
static Lisp_Object
-decode_path_1 (CONST Bufbyte *path, Bytecount size, Emchar sepchar)
+split_string_by_emchar_1 (CONST Bufbyte *string, Bytecount size,
+ Emchar sepchar)
{
- Lisp_Object lpath = Qnil;
- CONST Bufbyte *end = path + size;
+ Lisp_Object result = Qnil;
+ CONST Bufbyte *end = string + size;
while (1)
{
- CONST Bufbyte *p = path;
+ CONST Bufbyte *p = string;
while (p < end)
{
if (charptr_emchar (p) == sepchar)
break;
INC_CHARPTR (p);
}
- /* #### Do dos2unix path conversion on the freshly created
- string here? I am not convinced that this function needs
- such mangling. */
- lpath = Fcons (make_string (path, p - path), lpath);
+ result = Fcons (make_string (string, p - string), result);
if (p < end)
{
- path = p;
- INC_CHARPTR (path); /* skip sepchar */
+ string = p;
+ INC_CHARPTR (string); /* skip sepchar */
}
else
break;
}
- return Fnreverse (lpath);
+ return Fnreverse (result);
}
-/* The same as the above, only PATH is an external C string (it is
- converted at FORMAT_FILENAME), and sepchar is hardcoded to SEPCHAR
+/* The same as the above, except PATH is an external C string (it is
+ converted as FORMAT_FILENAME), and sepchar is hardcoded to SEPCHAR
(':' or whatever). */
Lisp_Object
decode_path (CONST char *path)
{
int len;
+ Bufbyte *newpath;
if (!path)
return Qnil;
- /* #### Is this correct? Ben, heeelp! */
- GET_C_CHARPTR_INT_FILENAME_DATA_ALLOCA (path, path);
+ GET_C_CHARPTR_INT_FILENAME_DATA_ALLOCA (path, newpath);
- len = strlen (path);
+ len = strlen (newpath);
+ /* #### Does this make sense? It certainly does for
+ decode_env_path(), but it looks dubious here. Does any code
+ depend on decode_path("") returning nil instead of an empty
+ string? */
if (!len)
return Qnil;
- return decode_path_1 ((CONST Bufbyte *)path, (Bytecount)len, SEPCHAR);
+ return split_string_by_emchar_1 (newpath, (Bytecount)len, SEPCHAR);
}
Lisp_Object
@@ -2512,33 +2514,42 @@
return decode_path (path);
}
-DEFUN ("decode-path", Fdecode_path, 1, 2, 0, /*
-Explode a search path separated by SEPCHAR into a list of strings.
-If omitted, SEPCHAR defaults to the character specified by
-`path-separator'.
+/* Ben thinks this function should not exist or be exported to Lisp.
+ We use it to define split-path-string in subr.el (not!). */
+
+DEFUN ("split-string-by-char", Fsplit_string_by_char, 1, 2, 0, /*
+Split STRING into a list of substrings originally separated by SEPCHAR.
*/
- (path, sepchar))
+ (string, sepchar))
+{
+ CHECK_STRING (string);
+ CHECK_CHAR (sepchar);
+ return split_string_by_emchar_1 (XSTRING_DATA (string),
+ XSTRING_LENGTH (string),
+ XCHAR (sepchar));
+}
+
+/* #### This was supposed to be in subr.el, but is used VERY early in
+ the bootstrap process, so it goes here. Damn. */
+
+DEFUN ("split-path", Fsplit_path, 1, 1, 0, /*
+Explode a search path into a list of strings.
+The path components are separated with the characters specified
+with `path-separator'.
+*/
+ (path))
{
- Emchar sepch;
-
CHECK_STRING (path);
- if (NILP (sepchar))
- {
- while (!STRINGP (Vpath_separator)
- || (XSTRING_CHAR_LENGTH (Vpath_separator) != 1))
- Vpath_separator =
- signal_simple_continuable_error
- ("`path-separator' should be set to a one-character string",
- Vpath_separator);
- sepch = charptr_emchar (XSTRING_DATA (Vpath_separator));
- }
- else
- {
- CHECK_CHAR (sepchar);
- sepch = XCHAR (sepchar);
- }
- return decode_path_1 (XSTRING_DATA (path), XSTRING_LENGTH (path), sepch);
+ while (!STRINGP (Vpath_separator)
+ || (XSTRING_CHAR_LENGTH (Vpath_separator) != 1))
+ Vpath_separator = signal_simple_continuable_error
+ ("`path-separator' should be set to a single-character string",
+ Vpath_separator);
+
+ return (split_string_by_emchar_1
+ (XSTRING_DATA (path), XSTRING_LENGTH (path),
+ charptr_emchar (XSTRING_DATA (Vpath_separator))));
}
DEFUN ("noninteractive", Fnoninteractive, 0, 0, 0, /*
@@ -2626,7 +2637,8 @@
DEFSUBR (Fquantify_clear_data);
#endif /* QUANTIFY */
- DEFSUBR (Fdecode_path);
+ DEFSUBR (Fsplit_string_by_char);
+ DEFSUBR (Fsplit_path); /* #### */
defsymbol (&Qkill_emacs_hook, "kill-emacs-hook");
defsymbol (&Qsave_buffers_kill_emacs, "save-buffers-kill-emacs");
--- src/symbols.c.orig Sat May 16 01:02:20 1998
+++ src/symbols.c Sat May 16 01:02:58 1998
@@ -715,8 +715,9 @@
the user level, so there is no loss of generality.
If a symbol is "unbound", then the contents of its value cell is
- Qunbound. Despite appearances, this is *not* a symbol, but is
- a symbol-value-forward object.
+ Qunbound. Despite appearances, this is *not* a symbol, but is a
+ symbol-value-forward object. This is so that printing it results
+ in "INTERNAL EMACS BUG", in case it leaks to Lisp, somehow.
Logically all of the following objects are "symbol-value-magic"
objects, and there are some games played w.r.t. this (#### this
@@ -889,8 +890,7 @@
a symbol-value-buffer-local object, and most of the
low-level functions below do not accept them; you need
to call follow_varalias_pointers to get the actual
- symbol to operate on.
- */
+ symbol to operate on. */
static Lisp_Object
mark_symbol_value_buffer_local (Lisp_Object obj,
--- lisp/subr.el.orig Sat May 16 01:18:01 1998
+++ lisp/subr.el Sat May 16 02:03:52 1998
@@ -305,6 +305,19 @@
start (match-end 0)))
(nreverse (cons (substring string start) parts))))
+;; #### #### #### AAaargh! Must be in C, because it is used insanely
+;; early in the bootstrap process.
+;(defun split-path (path)
+; "Explode a search path into a list of strings.
+;The path components are separated with the characters specified
+;with `path-separator'."
+; (while (or (not stringp path-separator)
+; (/= (length path-separator) 1))
+; (setq path-separator (signal 'error (list "\
+;`path-separator' should be set to a single-character string"
+; path-separator))))
+; (split-string-by-char path (aref separator 0)))
+
(defmacro with-output-to-string (&rest forms)
"Collect output to `standard-output' while evaluating FORMS and return
it as a string."
--- lisp/files.el.orig Sat May 16 01:27:24 1998
+++ lisp/files.el Sat May 16 01:29:44 1998
@@ -395,7 +395,7 @@
If you think you want to use this, you probably don't. This function
is provided for backward compatibility. A more robust implementation
-of the same functionality is available as `decode-path', which see."
+of the same functionality is available as `split-path', which see."
(and cd-path
(let (cd-list (cd-start 0) cd-colon)
(setq cd-path (concat cd-path path-separator))
--- lisp/find-paths.el.orig Sat May 16 01:28:16 1998
+++ lisp/find-paths.el Sat May 16 01:28:27 1998
@@ -250,7 +250,7 @@
Non-\"\" comonents are converted into directory form.
If DROP-EMPTIES is non-NIL, \"\" components are dropped from the output.
Otherwise, they are left alone."
- (let* ((components (decode-path string))
+ (let* ((components (split-path string))
(directories
(mapcar #'(lambda (component)
(if (string-equal "" component)
--- lisp/make-docfile.el.orig Sat May 16 01:28:56 1998
+++ lisp/make-docfile.el Sat May 16 01:29:09 1998
@@ -77,7 +77,7 @@
;; Then process the list of Lisp files.
(define-function 'defalias 'define-function)
-(setq load-path (decode-path (getenv "EMACSBOOTSTRAPLOADPATH")))
+(setq load-path (split-path (getenv "EMACSBOOTSTRAPLOADPATH")))
;; Then process the autoloads
(setq autoload-file-name "auto-autoloads.elc")
@@ -90,7 +90,7 @@
(setq
load-path
- (nconc load-path (decode-path (getenv "EMACSBOOTSTRAPLOADPATH"))))
+ (nconc load-path (split-path (getenv "EMACSBOOTSTRAPLOADPATH"))))
(let (preloaded-file-list)
(load (concat default-directory "../lisp/dumped-lisp.el"))
--- lisp/setup-paths.el.orig Sat May 16 01:29:18 1998
+++ lisp/setup-paths.el Sat May 16 01:29:20 1998
@@ -140,7 +140,7 @@
(packages-find-package-exec-path last-packages)
(let ((emacspath-envval (getenv "EMACSPATH")))
(and emacspath-envval
- (decode-path emacspath-envval)))
+ (split-path emacspath-envval)))
(and exec-directory
(list exec-directory))))
--- lisp/update-elc.el.orig Sat May 16 01:29:28 1998
+++ lisp/update-elc.el Sat May 16 01:29:29 1998
@@ -64,7 +64,7 @@
(define-function 'defalias 'define-function)
-(setq load-path (decode-path (getenv "EMACSBOOTSTRAPLOADPATH")))
+(setq load-path (split-path (getenv "EMACSBOOTSTRAPLOADPATH")))
(load "find-paths.el")
(load "packages.el")
--- lisp/loadup.el.orig Sat May 16 02:03:14 1998
+++ lisp/loadup.el Sat May 16 02:03:27 1998
@@ -47,7 +47,7 @@
(call-with-condition-handler 'really-early-error-handler
#'(lambda ()
;; message not defined yet ...
- (setq load-path (decode-path (getenv "EMACSBOOTSTRAPLOADPATH")))
+ (setq load-path (split-path (getenv "EMACSBOOTSTRAPLOADPATH")))
(external-debugging-output (format "\nUsing load-path %s" load-path))
--
Hrvoje Niksic <hniksic(a)srce.hr> | Student at FER Zagreb, Croatia
--------------------------------+--------------------------------
The meta-Turing test counts a thing as intelligent if it seeks to
devise and apply Turing tests to objects of its own creation.