New start/stop splitting.

This commit is contained in:
Dominik Pantůček 2023-03-13 22:06:29 +01:00
parent 8764877e40
commit 924f5d6675

View file

@ -122,11 +122,15 @@
;; returns a list of the symbol representing the type and start/stop
;; symbol. It returns false otherwise.
(define (split-start/stop-symbol s)
(cond ((eq? s 'studentstart) '(student start))
((eq? s 'studentstop) '(student stop))
((eq? s 'suspendstart) '(suspend start))
((eq? s 'suspendstop) '(suspend stop))
(else #f)))
(let* ((ss (symbol->string s))
(mstart (irregex-search (string->irregex "(start|stop)") ss)))
(if mstart
(let* ((istart (irregex-match-start-index mstart))
(bstring (substring ss 0 istart))
(sstring (substring ss istart)))
(list (string->symbol bstring)
(string->symbol sstring)))
#f)))
;; Processes member line adding given value v to the dictionary d
;; under key k. Special handling for start/stop symbols means given
@ -209,6 +213,9 @@
(test-equal? split-member-line (split-member-line " nick value ") '(nick "value"))
(test-equal? split-member-line (split-member-line " nick value1 value2 ") '(nick "value1 value2"))
(test-exn split-member-line (split-member-line "key value"))
(test-equal? split-start/stop-symbol (split-start/stop-symbol 'suspendstart) '(suspend start))
(test-equal? split-start/stop-symbol (split-start/stop-symbol 'teststop) '(test stop))
(test-false split-start/stop-symbol (split-start/stop-symbol 'normalkey))
))
)