From 1c869295b643d256a99de90f67d32b442f6f0586 Mon Sep 17 00:00:00 2001 From: David Kastrup Date: Fri, 15 Feb 2013 10:50:43 +0100 Subject: [PATCH] Issue3181: Replace several misuses of eq? on numerical values Numerical values don't carry identity, so (eq? 0 0) may or may not evaluate to #t. Those need to be replaced by eqv? or, where both items are guaranteed to be a number, = . --- ...s-with-minimum-accidentals-smart-transpose.ly | 4 ++-- input/regression/glissando-index.ly | 2 +- ly/event-listener.ly | 2 +- scm/define-event-classes.scm | 2 +- scm/define-markup-commands.scm | 8 ++++---- scm/stencil.scm | 4 ++-- scm/translation-functions.scm | 16 ++++++++-------- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Documentation/snippets/transposing-pitches-with-minimum-accidentals-smart-transpose.ly b/Documentation/snippets/transposing-pitches-with-minimum-accidentals-smart-transpose.ly index 2b647d0854..9d1e274ff5 100644 --- a/Documentation/snippets/transposing-pitches-with-minimum-accidentals-smart-transpose.ly +++ b/Documentation/snippets/transposing-pitches-with-minimum-accidentals-smart-transpose.ly @@ -43,10 +43,10 @@ In this manner, the most natural enharmonic notes are chosen. ;; for historical reasons (n (ly:pitch-notename p))) (cond - ((and (> a 1) (or (eq? n 6) (eq? n 2))) + ((and (> a 1) (or (= n 6) (= n 2))) (set! a (- a 2)) (set! n (+ n 1))) - ((and (< a -1) (or (eq? n 0) (eq? n 3))) + ((and (< a -1) (or (= n 0) (= n 3))) (set! a (+ a 2)) (set! n (- n 1)))) (cond diff --git a/input/regression/glissando-index.ly b/input/regression/glissando-index.ly index f3d53a7902..5611773909 100644 --- a/input/regression/glissando-index.ly +++ b/input/regression/glissando-index.ly @@ -7,6 +7,6 @@ \relative c' { \once \override Voice.Glissando.style = #(lambda (grob) - (if (eq? 1 (ly:grob-property grob 'glissando-index)) 'zigzag 'default)) + (if (= 1 (ly:grob-property grob 'glissando-index)) 'zigzag 'default)) 1 \glissando s1 } diff --git a/ly/event-listener.ly b/ly/event-listener.ly index 6c0f75970e..9e5282de89 100644 --- a/ly/event-listener.ly +++ b/ly/event-listener.ly @@ -66,7 +66,7 @@ program using the output of this function to interpret grace notes however they want (half duration, quarter duration? before beat, after beat? etc.)." (if - (eq? 0 (ly:moment-grace-numerator moment)) + (zero? (ly:moment-grace-numerator moment)) (ly:format "~a" (format-moment moment)) ;; grace notes have a negative numerator, so no "-" necessary (ly:format diff --git a/scm/define-event-classes.scm b/scm/define-event-classes.scm index 09dfbf79a3..c8ecbcf227 100644 --- a/scm/define-event-classes.scm +++ b/scm/define-event-classes.scm @@ -140,7 +140,7 @@ (list 'unquote `(ly:make-moment ,(ly:moment-main-numerator e) ,(ly:moment-main-denominator e) - . ,(if (eq? 0 (ly:moment-grace-numerator e)) + . ,(if (zero? (ly:moment-grace-numerator e)) '() (list (ly:moment-grace-numerator e) (ly:moment-grace-denominator e)))))) diff --git a/scm/define-markup-commands.scm b/scm/define-markup-commands.scm index 7dd0f967ed..92b4b704eb 100755 --- a/scm/define-markup-commands.scm +++ b/scm/define-markup-commands.scm @@ -898,7 +898,7 @@ samplePath = (new-commands (map (lambda (x) (cond ;; for rmoveto, rlineto - ((and (relative? x) (eq? 3 (length x))) + ((and (relative? x) (= 3 (length x))) (let ((cp (cons (+ (car current-point) (second x)) @@ -908,7 +908,7 @@ samplePath = (list (car cp) (cdr cp)))) ;; for rcurveto - ((and (relative? x) (eq? 7 (length x))) + ((and (relative? x) (= 7 (length x))) (let* ((old-cp current-point) (cp (cons (+ (car old-cp) @@ -923,12 +923,12 @@ samplePath = (car cp) (cdr cp)))) ;; for moveto, lineto - ((eq? 3 (length x)) + ((= 3 (length x)) (set-point (cons (second x) (third x))) (drop x 1)) ;; for curveto - ((eq? 7 (length x)) + ((= 7 (length x)) (set-point (cons (sixth x) (seventh x))) (drop x 1)) diff --git a/scm/stencil.scm b/scm/stencil.scm index 9b0db9a3fd..4be305bd0b 100644 --- a/scm/stencil.scm +++ b/scm/stencil.scm @@ -381,7 +381,7 @@ defined by @code{fill}." (reduce min +inf.0 (map caadr x)) (reduce max -inf.0 (map cadadr x)))) (map (lambda (x) - (if (eq? (length x) 8) + (if (= (length x) 8) (apply bezier-min-max x) (apply line-min-max x))) (map (lambda (x y) @@ -403,7 +403,7 @@ respectively." ;; modify pointlist to scale the coordinates (path (map (lambda (x) (apply - (if (eq? 6 (length x)) + (if (= 6 (length x)) (lambda (x1 x2 x3 x4 x5 x6) (list 'curveto (* x1 x-scale) diff --git a/scm/translation-functions.scm b/scm/translation-functions.scm index 665d259743..7f3305665e 100644 --- a/scm/translation-functions.scm +++ b/scm/translation-functions.scm @@ -345,8 +345,8 @@ if no fingering is present." (and x y)) #t (map (lambda (specced-fret) - (or (eq? 0 specced-fret) - (eq? 0 fret) + (or (zero? specced-fret) + (zero? fret) (>= maximum-stretch (abs (- fret specced-fret))))) specified-frets)))) @@ -355,7 +355,7 @@ if no fingering is present." notes?" (let* ((fret (calc-fret pitch string tuning))) (and (or (and (not restrain-open-strings) - (eq? fret 0)) + (zero? fret)) (>= fret minimum-fret)) (integer? fret) (close-enough fret)))) @@ -364,7 +364,7 @@ notes?" "Is @var{pitch} and open-string note on @var{string}, given the current tuning?" (let* ((fret (calc-fret pitch string tuning))) - (eq? fret 0))) + (zero? fret))) (define (set-fret! pitch-entry string finger) (let ((this-fret (calc-fret (car pitch-entry) @@ -400,7 +400,7 @@ the current tuning?" (for-each (lambda (pitch-entry string-fret-finger) (let* ((string (list-ref string-fret-finger 0)) - (finger (if (eq? (length string-fret-finger) 3) + (finger (if (= (length string-fret-finger) 3) (list-ref string-fret-finger 2) '())) (pitch (car pitch-entry)) @@ -408,8 +408,8 @@ the current tuning?" #f finger))) (if (or (not (null? string)) - (eq? digit 0)) - (if (eq? digit 0) + (eqv? digit 0)) + (if (eqv? digit 0) ;; here we handle fingers of 0 -- open strings (let ((fit-string (find (lambda (string) @@ -458,7 +458,7 @@ the current tuning?" (let* ((string-fret-finger (list-ref string-fret-fingers (cdr pitch-entry))) (string (list-ref string-fret-finger 0)) - (finger (if (eq? (length string-fret-finger) 3) + (finger (if (= (length string-fret-finger) 3) (list-ref string-fret-finger 2) '())) (pitch (car pitch-entry)) -- 2.39.2