From b0b52255bdad06a3ed6e807ca7aeb5930f1ec450 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Wed, 29 Jan 2020 00:03:50 +0000 Subject: fix(fun/wcl): Use 'eql' for byte comparisons The fact that this works is just an implementation-specific detail. In theory, 'eq' will only compare object instance equality and not value. Thanks to /u/patrec from HN for pointing this out. --- fun/wcl/wc.lisp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'fun') diff --git a/fun/wcl/wc.lisp b/fun/wcl/wc.lisp index a3d5cd1206..81576d41aa 100644 --- a/fun/wcl/wc.lisp +++ b/fun/wcl/wc.lisp @@ -12,7 +12,7 @@ (iter (for byte in-stream file-stream using #'read-byte) (for previous-byte previous byte) - (for is-newline = (eq newline byte)) + (for is-newline = (eql newline byte)) ;; Count each byte (sum 1 into bytes) @@ -22,12 +22,12 @@ ;; Count every "word", unless the preceding character already ;; was a space or we are at the beginning of the file. - (when (or (eq space previous-byte) - (eq newline previous-byte) + (when (or (eql space previous-byte) + (eql newline previous-byte) (not previous-byte)) (next-iteration)) - (counting (or is-newline (eq space byte)) + (counting (or is-newline (eql space byte)) into words) (declare (fixnum bytes newlines words)) -- cgit 1.4.1