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

Contents of /meta-cvs/F-628E7937593CAF250343DE067F906E0D

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations)
Sat Jan 26 02:37:53 2002 UTC (12 years, 2 months ago) by kaz
Branch: MAIN
CVS Tags: cvs-options-passthrough, mcvs-0-1, mcvs-0-0
Changes since 1.1: +3 -2 lines
Copyright notices.
1 kaz 1.2 ;;; This source file is part of the MCVS program,
2     ;;; which is distributed under the GNU license.
3     ;;; Copyright 2002 Kaz Kylheku
4 kaz 1.1
5     (provide "split")
6    
7     (defun split-fields (in-string delim-char-string)
8     "Split string into rigid fields based on delimiter characters.
9     Each individual delimiter character separates two fields.
10     Example: (split-fields \":c:#a\" \":#\") ==> (\"\" \"c\" \"\" \"a\")"
11     (let (list (token ""))
12     (dotimes (index (length in-string))
13     (let ((ch (aref in-string index)))
14     (cond
15     ((find ch delim-char-string)
16     (push token list)
17     (setf token ""))
18     (t (setf token (format nil "~a~a" token ch))))))
19     (push token list)
20     (nreverse list)))
21    
22     (defun split-words (in-string delim-char-string)
23     "Munge sequences of delimiter characters. The pieces
24     in between are returned as a list of strings.
25     Example: (split-words \" a b cde f \" \" \") ==> (\"a\" \"b\" \"cde\" \"f\")"
26     (let (list (token "") (state :parsing-delim))
27     (dotimes (i (length in-string))
28     (let ((ch (aref in-string i)))
29     (if (not (find ch delim-char-string))
30     (progn (setf token (format nil "~a~a" token ch))
31     (setf state :parsing-token))
32     (when (eq state :parsing-token)
33     (push token list)
34     (setf token "")
35     (setf state :parsing-delim)))))
36     (when (not (equal token ""))
37     (push token list))
38     (nreverse list)))

  ViewVC Help
Powered by ViewVC 1.1.5