Revision: 6137
Author: iratqq
Date: Sun Jan 10 23:00:07 2010
Log: * scm/sj3.scm (sj3-lib-get-nth-candidate):
  - Check underflow of nth (recorrected r6120).

http://code.google.com/p/uim/source/detail?r=6137

Modified:
 /trunk/scm/sj3.scm

=======================================
--- /trunk/scm/sj3.scm  Fri Dec 25 09:01:03 2009
+++ /trunk/scm/sj3.scm  Sun Jan 10 23:00:07 2010
@@ -122,10 +122,12 @@
 (define (sj3-lib-get-nth-candidate sc seg nth)
   (let* ((yomi (sj3-get-nth-yomi sc seg))
          (cnt (sj3-lib-funcall sc sj3-lib-douoncnt yomi)))
-    (if (and (< nth cnt)
-             (<= 0 nth))
-        (car (sj3-lib-funcall sc sj3-lib-get-nth-douon yomi nth))
-        (list-ref (sj3-make-map-from-kana-string yomi) (- nth cnt)))))
+    (cond ((< nth 0)
+           (list-ref (sj3-make-map-from-kana-string yomi) 0))
+          ((< nth cnt)
+           (car (sj3-lib-funcall sc sj3-lib-get-nth-douon yomi nth)))
+          (else
+           (list-ref (sj3-make-map-from-kana-string yomi) (- nth cnt))))))
 (define (sj3-lib-release-context sc)
   #t)
 (define (sj3-lib-get-unconv-candidate sc seg-idx)

Reply via email to