/[meta-cvs]/meta-cvs/F-628E7937593CAF250343DE067F906E0D
ViewVC logotype

Contents of /meta-cvs/F-628E7937593CAF250343DE067F906E0D

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Sun Jan 20 07:12:03 2002 UTC (12 years, 3 months ago) by kaz
Branch: MAIN
Adding all existing source files.
1 ;; $Id: F-628E7937593CAF250343DE067F906E0D,v 1.1 2002/01/20 07:12:03 kaz Exp $
2 ;; $Name: $
3
4 (provide "split")
5
6 (defun split-fields (in-string delim-char-string)
7 "Split string into rigid fields based on delimiter characters.
8 Each individual delimiter character separates two fields.
9 Example: (split-fields \":c:#a\" \":#\") ==> (\"\" \"c\" \"\" \"a\")"
10 (let (list (token ""))
11 (dotimes (index (length in-string))
12 (let ((ch (aref in-string index)))
13 (cond
14 ((find ch delim-char-string)
15 (push token list)
16 (setf token ""))
17 (t (setf token (format nil "~a~a" token ch))))))
18 (push token list)
19 (nreverse list)))
20
21 (defun split-words (in-string delim-char-string)
22 "Munge sequences of delimiter characters. The pieces
23 in between are returned as a list of strings.
24 Example: (split-words \" a b cde f \" \" \") ==> (\"a\" \"b\" \"cde\" \"f\")"
25 (let (list (token "") (state :parsing-delim))
26 (dotimes (i (length in-string))
27 (let ((ch (aref in-string i)))
28 (if (not (find ch delim-char-string))
29 (progn (setf token (format nil "~a~a" token ch))
30 (setf state :parsing-token))
31 (when (eq state :parsing-token)
32 (push token list)
33 (setf token "")
34 (setf state :parsing-delim)))))
35 (when (not (equal token ""))
36 (push token list))
37 (nreverse list)))

  ViewVC Help
Powered by ViewVC 1.1.5