73 | | (setf (server-capabilities connection) |
74 | | (reduce #'(lambda (x y) |
75 | | ;; O(n^2), but we're talking small lists anyway... |
76 | | ;; maybe I should have chosen a hash interface |
77 | | ;; after all... |
78 | | (if (assoc (first y) x :test #'string=) |
79 | | x |
80 | | (cons y x))) |
81 | | (append |
82 | | (mapcar #'(lambda (x) |
83 | | (let ((eq-pos (position #\= x))) |
84 | | (if eq-pos |
85 | | (list (subseq x 0 eq-pos) |
86 | | (subseq x (1+ eq-pos))) |
87 | | (list x)))) capabilities) |
88 | | (server-capabilities connection)) |
89 | | :initial-value '())) |
| 73 | (flet ((split-arg (x) |
| 74 | (let ((eq-pos (position #\= x))) |
| 75 | (if eq-pos |
| 76 | (list (subseq x 0 eq-pos) (subseq x (1+ eq-pos))) |
| 77 | (list x)))) |
| 78 | (decode-arg (text) |
| 79 | ;; decode \xHH to (code-char HH) |
| 80 | (format nil "~{~A~}" |
| 81 | (do* ((start 0 (+ 4 pos)) |
| 82 | (pos (search "\\x" text) |
| 83 | (search "\\x" text :start2 (1+ pos))) |
| 84 | (points)) |
| 85 | ((null pos) |
| 86 | (reverse (push (subseq text start) points))) |
| 87 | (push (subseq text start pos) points) |
| 88 | (push (code-char (parse-integer text |
| 89 | :start (+ 2 pos) |
| 90 | :end (+ 4 pos) |
| 91 | :junk-allowed nil |
| 92 | :radix 16)) |
| 93 | points)))) |
| 94 | (negate-param (param) |
| 95 | (if (eq #\- (char (first param) 0)) |
| 96 | (assoc (subseq (first param) 1) *default-isupport-values* |
| 97 | :test #'string=) |
| 98 | param))) |
| 99 | (setf (server-capabilities connection) |
| 100 | (reduce #'(lambda (x y) |
| 101 | ;; O(n^2), but we're talking small lists anyway... |
| 102 | ;; maybe I should have chosen a hash interface |
| 103 | ;; after all... |
| 104 | (if (assoc (first y) x :test #'string=) |
| 105 | x |
| 106 | (cons y x))) |
| 107 | (append |
| 108 | (mapcar #'(lambda (x) |
| 109 | (if (second x) |
| 110 | (list (first x) (decode-arg (second x))) |
| 111 | x)) |
| 112 | (remove nil (mapcar #'negate-param |
| 113 | (mapcar #'split-arg |
| 114 | capabilities)))) |
| 115 | (server-capabilities connection)) |
| 116 | :initial-value '()))) |