|
@@ -49,6 +49,21 @@ is replaced with replacement."
|
49
|
49
|
when pos do (write-string replacement out)
|
50
|
50
|
while pos)))
|
51
|
51
|
|
|
52
|
+; This function is pretty ugly but I was tired when I wrote it and just wanted it to work.
|
|
53
|
+; TODO: Clean this up
|
|
54
|
+(defun split-quoted (str)
|
|
55
|
+ (let ((my-list nil)
|
|
56
|
+ (my-string (make-array 0 :element-type 'character :fill-pointer 0 :adjustable t))
|
|
57
|
+ (encountered-quote nil))
|
|
58
|
+ (loop for c across str do
|
|
59
|
+ (if (eq c #\")
|
|
60
|
+ (setf encountered-quote (not encountered-quote)))
|
|
61
|
+ (if (or (not (eq c #\Space)) encountered-quote)
|
|
62
|
+ (vector-push-extend c my-string)
|
|
63
|
+ (progn (setf my-list (append my-list (list my-string)))
|
|
64
|
+ (setf my-string (make-array 0 :element-type 'character :fill-pointer 0 :adjustable t)))))
|
|
65
|
+ (setf my-list (append my-list (list my-string)))))
|
|
66
|
+
|
52
|
67
|
(defun empty-string? (str)
|
53
|
68
|
(string= "" str))
|
54
|
69
|
|
|
@@ -88,7 +103,7 @@ is replaced with replacement."
|
88
|
103
|
(set-maildir line hash))))
|
89
|
104
|
|
90
|
105
|
(defun test-for-command (line)
|
91
|
|
- (member (first(split (string-trim '(#\Space #\Tab) line) " ")) *commands* :test #'equal))
|
|
106
|
+ (member (first(split-quoted (string-trim '(#\Space #\Tab) line))) *commands* :test #'equal))
|
92
|
107
|
|
93
|
108
|
(defun clean-line (line)
|
94
|
109
|
(let ((cleaned-line (string-trim '(#\Space #\Tab) line)))
|
|
@@ -96,7 +111,7 @@ is replaced with replacement."
|
96
|
111
|
|
97
|
112
|
(defun hash-add-command (line hash)
|
98
|
113
|
(let* ((cleaned-line (clean-line line))
|
99
|
|
- (line-list (split cleaned-line " ")))
|
|
114
|
+ (line-list (split-quoted cleaned-line)))
|
100
|
115
|
(sethash "command" hash (first line-list))
|
101
|
116
|
(sethash "args" hash (subseq line-list 1))
|
102
|
117
|
hash))
|