diff --git a/member-file.scm b/member-file.scm index 995b88c..5512504 100644 --- a/member-file.scm +++ b/member-file.scm @@ -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)) )) )