diff options
| author | Nick Roberts | 2007-06-28 01:39:09 +0000 |
|---|---|---|
| committer | Nick Roberts | 2007-06-28 01:39:09 +0000 |
| commit | 77676c1bd322ec1adfffb918daef9689989d8ed0 (patch) | |
| tree | cb5755b715d1b477a4986e292f70036542373a75 | |
| parent | de949ffac9bda1bbe86bd8c521f142e2056b540e (diff) | |
| download | emacs-77676c1bd322ec1adfffb918daef9689989d8ed0.tar.gz emacs-77676c1bd322ec1adfffb918daef9689989d8ed0.zip | |
* pcvs-util.el (cvs-strings->string, cvs-string->strings): Rename
and move to...
* subr.el (strings->string, string->strings): ...here.
| -rw-r--r-- | lisp/pcvs-util.el | 31 |
1 files changed, 1 insertions, 30 deletions
diff --git a/lisp/pcvs-util.el b/lisp/pcvs-util.el index 3945d7ba67c..58c605a19d2 100644 --- a/lisp/pcvs-util.el +++ b/lisp/pcvs-util.el | |||
| @@ -186,35 +186,6 @@ arguments. If ARGS is not a list, no argument will be passed." | |||
| 186 | "Tell whether STR1 is a prefix of STR2." | 186 | "Tell whether STR1 is a prefix of STR2." |
| 187 | (eq t (compare-strings str2 nil (length str1) str1 nil nil))) | 187 | (eq t (compare-strings str2 nil (length str1) str1 nil nil))) |
| 188 | 188 | ||
| 189 | ;; (string->strings (strings->string X)) == X | ||
| 190 | (defun cvs-strings->string (strings &optional separator) | ||
| 191 | "Concatenate the STRINGS, adding the SEPARATOR (default \" \"). | ||
| 192 | This tries to quote the strings to avoid ambiguity such that | ||
| 193 | (cvs-string->strings (cvs-strings->string strs)) == strs | ||
| 194 | Only some SEPARATORs will work properly." | ||
| 195 | (let ((sep (or separator " "))) | ||
| 196 | (mapconcat | ||
| 197 | (lambda (str) | ||
| 198 | (if (string-match "[\\\"]" str) | ||
| 199 | (concat "\"" (replace-regexp-in-string "[\\\"]" "\\\\\\&" str) "\"") | ||
| 200 | str)) | ||
| 201 | strings sep))) | ||
| 202 | |||
| 203 | ;; (string->strings (strings->string X)) == X | ||
| 204 | (defun cvs-string->strings (string &optional separator) | ||
| 205 | "Split the STRING into a list of strings. | ||
| 206 | It understands elisp style quoting within STRING such that | ||
| 207 | (cvs-string->strings (cvs-strings->string strs)) == strs | ||
| 208 | The SEPARATOR regexp defaults to \"\\s-+\"." | ||
| 209 | (let ((sep (or separator "\\s-+")) | ||
| 210 | (i (string-match "[\"]" string))) | ||
| 211 | (if (null i) (split-string string sep t) ; no quoting: easy | ||
| 212 | (append (unless (eq i 0) (split-string (substring string 0 i) sep t)) | ||
| 213 | (let ((rfs (read-from-string string i))) | ||
| 214 | (cons (car rfs) | ||
| 215 | (cvs-string->strings (substring string (cdr rfs)) | ||
| 216 | sep))))))) | ||
| 217 | |||
| 218 | ;;;; | 189 | ;;;; |
| 219 | ;;;; file names | 190 | ;;;; file names |
| 220 | ;;;; | 191 | ;;;; |
| @@ -240,7 +211,7 @@ The SEPARATOR regexp defaults to \"\\s-+\"." | |||
| 240 | (defconst cvs-qtypedesc-string1 (cvs-qtypedesc-create 'identity 'identity t)) | 211 | (defconst cvs-qtypedesc-string1 (cvs-qtypedesc-create 'identity 'identity t)) |
| 241 | (defconst cvs-qtypedesc-string (cvs-qtypedesc-create 'identity 'identity)) | 212 | (defconst cvs-qtypedesc-string (cvs-qtypedesc-create 'identity 'identity)) |
| 242 | (defconst cvs-qtypedesc-strings | 213 | (defconst cvs-qtypedesc-strings |
| 243 | (cvs-qtypedesc-create 'cvs-string->strings 'cvs-strings->string nil)) | 214 | (cvs-qtypedesc-create 'string->strings 'strings->string nil)) |
| 244 | 215 | ||
| 245 | (defun cvs-query-read (default prompt qtypedesc &optional hist-sym) | 216 | (defun cvs-query-read (default prompt qtypedesc &optional hist-sym) |
| 246 | (let* ((qtypedesc (or qtypedesc cvs-qtypedesc-strings)) | 217 | (let* ((qtypedesc (or qtypedesc cvs-qtypedesc-strings)) |