Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed several uses of LOOP to be standards-compliant

  • Loading branch information...
commit e02212fcf3eea8a3b3a920f141855cb0a3e139a3 1 parent fc9855b
@jwiegley authored
Showing with 52 additions and 58 deletions.
  1. +12 −15 core/ledger.lisp
  2. +18 −19 driver.lisp
  3. +22 −24 parsers/textual/textual.lisp
View
27 core/ledger.lisp
@@ -315,26 +315,23 @@ The result is of type JOURNAL."
(list (list-iterator (journal-contents journal))))
(entry-class (find-class 'entry)))
(lambda ()
- (loop
- while contents-iterators
- for item = (funcall (first contents-iterators))
- if (null item)
- do (setf contents-iterators
- (cdr contents-iterators))
- else if (eq (class-of item) entry-class)
- return item
- if (typep item 'journal)
- do (push (list-iterator (journal-contents item))
- contents-iterators)))))
+ (loop while contents-iterators do
+ (let ((item (funcall (first contents-iterators))))
+ (if (null item)
+ (pop contents-iterators)
+ (progn
+ (if (eq (class-of item) entry-class)
+ (return item))
+ (if (typep item 'journal)
+ (push (list-iterator (journal-contents item))
+ contents-iterators)))))))))
(defmethod entries-iterator ((entry entry))
(list-iterator (list entry)))
(defun entries-list (object)
- (loop
- with iterator = (entries-iterator object)
- for entry = (funcall iterator)
- while entry collect entry))
+ (loop with iterator = (entries-iterator object)
+ for entry = (funcall iterator) while entry collect entry))
(defmacro map-entries (callable object)
`(map-iterator ,callable (entries-iterator ,object)))
View
37 driver.lisp
@@ -10,12 +10,11 @@
(car exprs)
(with-output-to-string (out)
(write-char #\( out)
- (let ((first t))
- (loop for expr in exprs do
- (if first
- (setf first nil)
- (write-char #\| out))
- (princ expr out)))
+ (loop with first = t for expr in exprs do
+ (if first
+ (setf first nil)
+ (write-char #\| out))
+ (princ expr out))
(write-char #\) out)))))
(defun process-command-line (&rest args)
@@ -25,7 +24,7 @@
(if (char= #\: (aref arg 0))
(rplaca cell (make-symbol arg))
(if-let ((number (ignore-errors (parse-integer arg))))
- (rplaca cell number))))
+ (rplaca cell number))))
(let (pathnames keywords)
;; Handle all of the option-like arguments
@@ -84,18 +83,18 @@
(setf args (cdr args))
;; Extract the account and payee regexps
- (loop while (and args (stringp (first args)))
- for arg = (first args) do
- (if (string= arg "--")
- (setf in-payee-regexps t)
- (if in-payee-regexps
- (if (char= #\- (aref arg 0))
- (push (subseq arg 1) not-payee-regexps)
- (push arg payee-regexps))
- (if (char= #\- (aref arg 0))
- (push (subseq arg 1) not-account-regexps)
- (push arg account-regexps))))
- (setf args (rest args)))
+ (loop while (and args (stringp (first args))) do
+ (let ((arg (first args)))
+ (if (string= arg "--")
+ (setf in-payee-regexps t)
+ (if in-payee-regexps
+ (if (char= #\- (aref arg 0))
+ (push (subseq arg 1) not-payee-regexps)
+ (push arg payee-regexps))
+ (if (char= #\- (aref arg 0))
+ (push (subseq arg 1) not-account-regexps)
+ (push arg account-regexps))))
+ (setf args (rest args))))
(setf account-regexps (regexp-opt account-regexps)
not-account-regexps (regexp-opt not-account-regexps)
View
46 parsers/textual/textual.lisp
@@ -265,30 +265,28 @@
(declare (type binder binder))
(let ((journal (make-instance 'journal :binder binder))
(line-number 1))
- (loop
- for c = (peek-char nil in nil)
- while c do
- (let ((handler
- (cdr
- (assoc-if
- #'(lambda (key)
- (cond
- ((characterp key)
- (char= c key))
- ((listp key)
- (member c key :test #'char=))
- ((functionp key)
- (funcall key c))
- (t
- (error "Unexpected element in `*directive-handlers*': ~S"
- key))))
- *directive-handlers*))))
- (if handler
- (incf line-number (funcall handler in line-number journal))
- (progn
- (format t "Unhandled directive (line ~D): ~C~%" line-number c)
- (read-line in nil)
- (incf line-number)))))
+ (loop for c = (peek-char nil in nil) while c do
+ (let ((handler
+ (cdr
+ (assoc-if
+ #'(lambda (key)
+ (cond
+ ((characterp key)
+ (char= c key))
+ ((listp key)
+ (member c key :test #'char=))
+ ((functionp key)
+ (funcall key c))
+ (t
+ (error "Unexpected element in `*directive-handlers*': ~S"
+ key))))
+ *directive-handlers*))))
+ (if handler
+ (incf line-number (funcall handler in line-number journal))
+ (progn
+ (format t "Unhandled directive (line ~D): ~C~%" line-number c)
+ (read-line in nil)
+ (incf line-number)))))
journal))
(defun ledger-text-directive/include (argument)
Please sign in to comment.
Something went wrong with that request. Please try again.