From: Michael Käppler Date: Sun, 13 Sep 2009 20:11:36 +0000 (+0200) Subject: Turn assoc calls into secure assoc-get calls. X-Git-Tag: release/2.13.4-1~38 X-Git-Url: https://git.donarmstrong.com/lilypond.git?a=commitdiff_plain;h=a4299bffa02ef189c2d8c04b1142df40cf97d006;p=lilypond.git Turn assoc calls into secure assoc-get calls. * First stage: Turn all (cdr (assoc calls into (assoc-get calls. --- diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index eeef0385c8..aab8a04a61 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -2260,10 +2260,10 @@ ;; (newline) (let* ((name-sym (car x)) (grob-entry (cdr x)) - (meta-entry (cdr (assoc 'meta grob-entry))) - (class (cdr (assoc 'class meta-entry))) + (meta-entry (assoc-get 'meta grob-entry)) + (class (assoc-get 'class meta-entry)) (ifaces-entry - (cdr (assoc 'interfaces meta-entry)))) + (assoc-get 'interfaces meta-entry))) (cond ((eq? 'Item class) diff --git a/scm/document-backend.scm b/scm/document-backend.scm index 41c2aab60c..7ab9f85fb0 100644 --- a/scm/document-backend.scm +++ b/scm/document-backend.scm @@ -63,7 +63,7 @@ (lambda (x) (let* ((metah (assoc 'meta (cdr x))) (meta (cdr metah)) - (ifaces (cdr (assoc 'interfaces meta)))) + (ifaces (assoc-get 'interfaces meta))) (map (lambda (iface) (hashq-set! @@ -112,9 +112,9 @@ node." (let* ((metah (assoc 'meta description)) (meta (cdr metah)) - (name (cdr (assoc 'name meta))) + (name (assoc-get 'name meta)) ;; (bla (display name)) - (ifaces (map lookup-interface (cdr (assoc 'interfaces meta)))) + (ifaces (map lookup-interface (assoc-get 'interfaces meta))) (ifacedoc (map ref-ify (sort (map (lambda (iface) diff --git a/scm/document-translation.scm b/scm/document-translation.scm index 390d6b0330..154750ab8d 100644 --- a/scm/document-translation.scm +++ b/scm/document-translation.scm @@ -19,12 +19,12 @@ (engraver-accepts-music-types? (cdr types) grav)))) (define (engraver-doc-string engraver in-which-contexts) - (let* ((propsr (cdr (assoc 'properties-read (ly:translator-description engraver)))) - (propsw (cdr (assoc 'properties-written (ly:translator-description engraver)))) - (accepted (cdr (assoc 'events-accepted (ly:translator-description engraver)))) + (let* ((propsr (assoc-get 'properties-read (ly:translator-description engraver))) + (propsw (assoc-get 'properties-written (ly:translator-description engraver))) + (accepted (assoc-get 'events-accepted (ly:translator-description engraver))) (name-sym (ly:translator-name engraver)) (name-str (symbol->string name-sym)) - (desc (cdr (assoc 'description (ly:translator-description engraver)))) + (desc (assoc-get 'description (ly:translator-description engraver))) (grobs (engraver-grobs engraver))) (string-append @@ -70,13 +70,13 @@ (apply append (map (lambda (x) - (let* ((context (cdr (assoc 'context-name x))) + (let* ((context (assoc-get 'context-name x)) (group (assq-ref x 'group-type)) (consists (append (if group (list group) '()) - (cdr (assoc 'consists x))))) + (assoc-get 'consists x)))) (if (member name-sym consists) (list context) '()))) @@ -148,16 +148,16 @@ (define (context-doc context-desc) - (let* ((name-sym (cdr (assoc 'context-name context-desc))) + (let* ((name-sym (assoc-get 'context-name context-desc)) (name (symbol->string name-sym)) - (aliases (map symbol->string (cdr (assoc 'aliases context-desc)))) + (aliases (map symbol->string (assoc-get 'aliases context-desc))) (desc-handle (assoc 'description context-desc)) (desc (if (and (pair? desc-handle) (string? (cdr desc-handle))) (cdr desc-handle) "(not documented)")) - (accepts (cdr (assoc 'accepts context-desc))) - (consists (cdr (assoc 'consists context-desc))) - (props (cdr (assoc 'property-ops context-desc))) + (accepts (assoc-get 'accepts context-desc)) + (consists (assoc-get 'consists context-desc)) + (props (assoc-get 'property-ops context-desc)) (grobs (context-grobs context-desc)) (grob-refs (map ref-ify (sort grobs ly:string-cistring (cdr (assoc 'grobs-created (ly:translator-description eg))))))) + (map symbol->string (assoc-get 'grobs-created (ly:translator-description eg)))))) (define (context-grobs context-desc) (let* ((group (assq-ref context-desc 'group-type)) @@ -222,7 +222,7 @@ (if group (list group) '()) - (cdr (assoc 'consists context-desc)))) + (assoc-get 'consists context-desc))) (grobs (apply append (map engraver-grobs consists)))) grobs)) diff --git a/scm/documentation-lib.scm b/scm/documentation-lib.scm index 8315a765c1..79da938b6b 100644 --- a/scm/documentation-lib.scm +++ b/scm/documentation-lib.scm @@ -2,7 +2,7 @@ ;;;; documentation-lib.scm -- Assorted Functions for generated documentation ;;;; ;;;; source file of the GNU LilyPond music typesetter -;;;; +;;;; ;;;; (c) 2000--2009 Han-Wen Nienhuys ;;;; Jan Nieuwenhuizen @@ -60,22 +60,22 @@ (define (texi-section-command level) - (cdr (assoc level '( - ;; Hmm, texinfo doesn't have ``part'' - (0 . "@top") - (1 . "@chapter") - (2 . "@section") - (3 . "@subsection") - (4 . "@unnumberedsubsubsec") - (5 . "@unnumberedsubsubsec"))))) + (assoc-get level '( + ;; Hmm, texinfo doesn't have ``part'' + (0 . "@top") + (1 . "@chapter") + (2 . "@section") + (3 . "@subsection") + (4 . "@unnumberedsubsubsec") + (5 . "@unnumberedsubsubsec")))) (define (texi-appendix-section-command level) - (cdr (assoc level '((0 . "@top") - (1 . "@appendix") - (2 . "@appendixsec") - (3 . "@appendixsubsec") - (4 . "@appendixsubsubsec") - (5 . "@appendixsubsubsec"))))) + (assoc-get level '((0 . "@top") + (1 . "@appendix") + (2 . "@appendixsec") + (3 . "@appendixsubsec") + (4 . "@appendixsubsubsec") + (5 . "@appendixsubsubsec")))) (define (one-item->texi label-desc-pair) "Document one (LABEL . DESC); return empty string if LABEL is empty string." @@ -100,13 +100,13 @@ string-to-use). If QUOTE? is #t, embed table in a @quotation environment." "Generate what is between @menu and @end menu." (let ((maxwid (apply max (map (lambda (x) (string-length (car x))) items-alist)))) - + (string-append "\n@menu" (apply string-append (map (lambda (x) (string-append - (string-pad-right + (string-pad-right (string-append "\n* " (car x) ":: ") (+ maxwid 8)) (cdr x))) @@ -155,7 +155,7 @@ string-to-use). If QUOTE? is #t, embed table in a @quotation environment." (define (human-listify lst) "Produce a textual enumeration from LST, a list of strings" - + (cond ((null? lst) "none") ((null? (cdr lst)) (car lst)) @@ -177,7 +177,7 @@ with init values from ALIST (1st optional argument) (alist (if (pair? rest) (car rest) '())) (type?-name (string->symbol (string-append (symbol->string where) "-type?"))) - (doc-name (string->symbol + (doc-name (string->symbol (string-append (symbol->string where) "-doc"))) (type (object-property sym type?-name)) (typename (type-name type)) @@ -186,7 +186,7 @@ with init values from ALIST (1st optional argument) (if (eq? desc #f) (ly:error (_ "cannot find description for property ~S (~S)") sym where)) - + (cons (string-append "@code{" name "} " "(" typename ")" diff --git a/scm/fret-diagrams.scm b/scm/fret-diagrams.scm index d0883a48ac..993e838921 100644 --- a/scm/fret-diagrams.scm +++ b/scm/fret-diagrams.scm @@ -268,11 +268,11 @@ with magnification @var{mag} of the string @var{text}." (* size (assoc-get 'xo-padding details 0.2))) ; needed only here (parameters (fret-parse-marking-list marking-list my-fret-count)) (capo-fret (assoc-get 'capo-fret parameters 0)) - (dot-list (cdr (assoc 'dot-list parameters))) - (xo-list (cdr (assoc 'xo-list parameters))) - (fret-range (cdr (assoc 'fret-range parameters))) + (dot-list (assoc-get 'dot-list parameters)) + (xo-list (assoc-get 'xo-list parameters)) + (fret-range (assoc-get 'fret-range parameters)) (my-fret-count (fret-count fret-range)) - (barre-list (cdr (assoc 'barre-list parameters))) + (barre-list (assoc-get 'barre-list parameters)) (barre-type (assoc-get 'barre-type details 'curved)) (fret-diagram-stencil '())) diff --git a/scm/memory-trace.scm b/scm/memory-trace.scm index 9da1c30eda..345d1327f0 100644 --- a/scm/memory-trace.scm +++ b/scm/memory-trace.scm @@ -34,7 +34,7 @@ (if (eq? (current-thread) trace-thread) #t ;; do nothing. (let* - ((cells (cdr (assoc 'total-cells-allocated (gc-stats)))) + ((cells (assoc-get 'total-cells-allocated (gc-stats))) (proc (arg-procedure args)) (time (tms:utime (times))) (stack (extract-trace continuation))) @@ -67,7 +67,7 @@ (set! trace-points '()) (set! continue-tracing #t) (set! trace-count 0) - (set! start-memory (cdr (assoc 'total-cells-allocated (gc-stats)))) + (set! start-memory (assoc-get 'total-cells-allocated (gc-stats))) (set! start-time (tms:utime (times))) (install-tracepoint)) @@ -100,10 +100,10 @@ (for-each (lambda (r) (let* - ((mem (- (cdr (assoc 'cells r)) start-memory)) - (proc (cdr (assoc 'proc r))) - (stack (cdr (assoc 'stack r))) - (time (- (cdr (assoc 'time r)) start-time))) + ((mem (- (assoc-get 'cells r) start-memory)) + (proc (assoc-get 'proc r)) + (stack (assoc-get 'stack r)) + (time (- (assoc-get 'time r) start-time))) (format graph-out "~a ~a\n" time mem) (if stack @@ -113,7 +113,7 @@ (- mem last-mem) proc) (do ((j 0 (1+ j)) - (stack (cdr (assoc 'stack r)) stack)) + (stack (assoc-get 'stack r) stack)) ((>= j (vector-length stack))) (format stacks-out "\t~a\n" diff --git a/scm/music-functions.scm b/scm/music-functions.scm index 3846727a1a..549b175d1e 100644 --- a/scm/music-functions.scm +++ b/scm/music-functions.scm @@ -480,11 +480,11 @@ OTTAVATION to `8va', or whatever appropriate." (ly:context-unset-property where 'ottavation))) (let* ((offset (* -7 octavation)) - (string (cdr (assoc octavation '((2 . "15ma") - (1 . "8va") - (0 . #f) - (-1 . "8vb") - (-2 . "15mb")))))) + (string (assoc-get octavation '((2 . "15ma") + (1 . "8va") + (0 . #f) + (-1 . "8vb") + (-2 . "15mb"))))) (ly:context-set-property! context 'middleCOffset offset) (ly:context-set-property! context 'ottavation string) (ly:set-middle-C! context))) @@ -671,7 +671,7 @@ inside of and outside of chord construct." " (let ((meta (ly:grob-property grob 'meta))) - (if (equal? (cdr (assoc 'name meta)) grob-name) + (if (equal? (assoc-get 'name meta) grob-name) (set! (ly:grob-property grob symbol) val)))) diff --git a/scm/output-socket.scm b/scm/output-socket.scm index 5534c2816c..c86047815a 100644 --- a/scm/output-socket.scm +++ b/scm/output-socket.scm @@ -68,7 +68,7 @@ (tag (if (and cause (integer? (ly:event-property cause 'input-tag))) (ly:event-property cause 'input-tag) -1)) - (name (cdr (assoc 'name (ly:grob-property grob 'meta))))) + (name (assoc-get 'name (ly:grob-property grob 'meta)))) (apply format (append (list "cause ~a \"~a\" ~a ~a ~a ~a\n" tag name) diff --git a/scm/parser-clef.scm b/scm/parser-clef.scm index a6d178eaef..62bfef5ee9 100644 --- a/scm/parser-clef.scm +++ b/scm/parser-clef.scm @@ -116,7 +116,7 @@ ((symbol . middleCClefPosition) (value . ,(+ oct (caddr e) - (cdr (assoc (cadr e) c0-pitch-alist))))) + (assoc-get (cadr e) c0-pitch-alist)))) ((symbol . clefPosition) (value . ,(caddr e))) ((symbol . clefOctavation) (value . ,(- oct)))))) (recalc-mid-C (make-music 'ApplyContext)) diff --git a/scm/part-combiner.scm b/scm/part-combiner.scm index 81beaf6ae7..c874f09d1c 100644 --- a/scm/part-combiner.scm +++ b/scm/part-combiner.scm @@ -1,7 +1,7 @@ ;;;; part-combiner.scm -- Part combining, staff changes. ;;;; ;;;; source file of the GNU LilyPond music typesetter -;;;; +;;;; ;;;; (c) 2004--2009 Han-Wen Nienhuys ;; todo: figure out how to make module, @@ -19,7 +19,7 @@ ;; of (SYMBOL . RESULT-INDEX), which indicates where ;; said spanner was started. (spanner-state #:init-value '() #:accessor span-state)) - + (define-method (write (x ) file) (display (when x) file) (display " evs = " file) @@ -49,7 +49,7 @@ ;; (is #:init-keyword #:voice-states #:accessor voice-states) (synced #:init-keyword #:synced #:init-value #f #:getter synced?)) - + (define-method (write (x ) f) (display (when x) f) @@ -82,7 +82,7 @@ "Merge lists VS1 and VS2, containing Voice-state objects into vector of Split-state objects, crosslinking the Split-state vector and Voice-state objects -" +" (define (helper ss-idx ss-list idx1 idx2) (let* ((state1 (if (< idx1 (vector-length vs1)) (vector-ref vs1 idx1) #f)) (state2 (if (< idx2 (vector-length vs2)) (vector-ref vs2 idx2) #f)) @@ -114,13 +114,13 @@ Voice-state objects (define (helper index active) "Analyse EVS at INDEX, given state ACTIVE." - + (define (analyse-tie-start active ev) (if (equal? (ly:event-property ev 'class) 'tie-event) (acons 'tie (split-index (vector-ref voice-state-vec index)) active) active)) - + (define (analyse-tie-end active ev) (if (equal? (ly:event-property ev 'class) 'note-event) (assoc-remove! active 'tie) @@ -132,12 +132,12 @@ Voice-state objects (equal? STOP (ly:event-property ev 'span-direction)))) (assoc-remove! (assoc-remove! active 'cresc) 'decr) active)) - + (define (active i b) b) (set! (configuration (vector-ref result i)) x))) - + (define (put x) ;; (display (list "putting " x "\n")) (set! (configuration (vector-ref result result-idx)) x)) - + (define (current-voice-state now-state voice-num) (define vs ((if (= 1 voice-num) car cdr) (voice-states now-state))) (if (or (not vs) (equal? (when now-state) (when vs))) vs (previous-voice-state vs))) - + (define (try-solo type start-idx current-idx) "Find a maximum stretch that can be marked as solo. Only set the mark when there are no spanners active. @@ -414,7 +414,7 @@ the mark when there are no spanners active. ;; ;; This includes rests. This isn't a problem: long rests ;; will be shared with the silent voice, and be marked - ;; as unisilence. Therefore, long rests won't + ;; as unisilence. Therefore, long rests won't ;; accidentally be part of a solo. ;; (put-range type start-idx current-idx) @@ -423,7 +423,7 @@ the mark when there are no spanners active. (try-solo type start-idx (1+ current-idx))))) ;; try-solo start-idx)) - + (define (analyse-moment result-idx) "Analyse 'apart starting at RESULT-IDX. Return next index. " (let* ((now-state (vector-ref result result-idx)) @@ -449,11 +449,11 @@ the mark when there are no spanners active. (equal? (when vs2) (when now-state)) (null? (previous-span-state vs2))) (try-solo 'solo2 result-idx result-idx)) - + (else (1+ result-idx))) ;; analyse-moment (1+ result-idx)))) - + (if (< result-idx (vector-length result)) (if (equal? (configuration (vector-ref result result-idx)) 'apart) (analyse-solo12 (analyse-moment result-idx)) diff --git a/scm/song.scm b/scm/song.scm index c5ecc89da6..130208a753 100644 --- a/scm/song.scm +++ b/scm/song.scm @@ -87,7 +87,7 @@ ((note? object) (let ((pitch (ly:pitch-semitones (note-pitch object)))) (format #f "~a~a~a~a" - (cdr (assoc (modulo pitch 12) pp-pitch-names)) + (assoc-get (modulo pitch 12) pp-pitch-names) (let ((octave (+ (inexact->exact (floor (/ pitch 12))) 1))) (cond ((= octave 0)