fix(cli): possible divide-by-zero when calculating similarity
If given two empty strings (which doesn't happens anywhere in the codebase atm, but just in case).
This commit is contained in:
parent
979495cf33
commit
42d84e7e21
1 changed files with 7 additions and 7 deletions
|
@ -169,10 +169,10 @@ OPTIONS:
|
|||
(s2 (downcase s2))
|
||||
(s1len (length s1))
|
||||
(s2len (length s2)))
|
||||
(/ (if (or (zerop s1len)
|
||||
(zerop s2len))
|
||||
0.0
|
||||
(let ((i 0) (j 0) (score 0) jlast)
|
||||
(if (or (zerop s1len)
|
||||
(zerop s2len))
|
||||
0.0
|
||||
(/ (let ((i 0) (j 0) (score 0) jlast)
|
||||
(while (< i s1len)
|
||||
(unless jlast (setq jlast j))
|
||||
(if (and (< j s2len)
|
||||
|
@ -186,9 +186,9 @@ OPTIONS:
|
|||
(setq j (or jlast j)
|
||||
jlast nil)
|
||||
(cl-incf i))))
|
||||
(* 2.0 score)))
|
||||
(+ (length s1)
|
||||
(length s2)))))
|
||||
(* 2.0 score))
|
||||
(+ (length s1)
|
||||
(length s2))))))
|
||||
|
||||
;;; Help: printers
|
||||
;; TODO Parameterize optional args with `cl-defun'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue