Improving code for numbering by using less code. - clic - Clic is an command li… | |
git clone git://bitreich.org/clic/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65… | |
Log | |
Files | |
Refs | |
Tags | |
README | |
LICENSE | |
--- | |
commit f68b9416093b6f062124ad0cc8e3cabc046c4760 | |
parent e24337e15217c4b79767640c52e6e64ff16b0aaf | |
Author: Solene Rapenne <[email protected]> | |
Date: Tue, 7 Nov 2017 10:04:04 +0000 | |
Improving code for numbering by using less code. | |
Diffstat: | |
M clic.lisp | 13 ++++--------- | |
1 file changed, 4 insertions(+), 9 deletions(-) | |
--- | |
diff --git a/clic.lisp b/clic.lisp | |
@@ -55,7 +55,7 @@ | |
(if left-separator-position (+ 1 left-separator-position) … | |
(- count 1)))))) | |
-(defun formatted-output(line line-number) | |
+(defun formatted-output(line) | |
"Used to display gopher response with color one line at a time" | |
(let ((line-type (subseq line 0 1)) | |
(infos (split (subseq line 1) #\Tab))) | |
@@ -66,7 +66,8 @@ | |
(= (length infos) 4) | |
(member line-type *allowed-selectors* :test #'equal)) | |
- (let ((text (car infos)) | |
+ (let ((line-number (+ 1 (hash-table-count *links*))) | |
+ (text (car infos)) | |
(uri (cadr infos)) | |
(host (caddr infos)) | |
(port (parse-integer (cadddr infos)))) | |
@@ -180,18 +181,12 @@ | |
;; for each line we receive we display it | |
(loop for line = (read-line stream nil nil) | |
- counting | |
- (when (> (length line) 1) | |
- (or | |
- (string= "0" (subseq line 0 1)) | |
- (string= "1" (subseq line 0 1)))) | |
- into line-number | |
while line do | |
(when save-offline | |
(format save-offline "~a~%" line)) | |
(cond | |
((string= "1" type) | |
- (formatted-output line line-number)) | |
+ (formatted-output line)) | |
((string= "0" type) | |
(format t "~a~%" line)))) | |
(and save-offline (close save-offline))))))) |