diff options
-rw-r--r-- | share/txr/stdlib/awk.tl | 9 | ||||
-rw-r--r-- | txr.1 | 12 |
2 files changed, 16 insertions, 5 deletions
diff --git a/share/txr/stdlib/awk.tl b/share/txr/stdlib/awk.tl index eccef632..466ab544 100644 --- a/share/txr/stdlib/awk.tl +++ b/share/txr/stdlib/awk.tl @@ -110,7 +110,7 @@ (t (put-string self.rec) (put-string self.ors)))) -(defun sys:range-test (val rec) +(defun sys:awk-test (val rec) (caseq (typeof val) ((regex fun) (call val rec)) (t val))) @@ -200,8 +200,8 @@ (qref ,awc rng-exprs)) rng-temp)) (rng (from-expr to-expr) - ^(sys:rng (sys:range-test ,from-expr ,(qref ,awc rng-rec-temp)) - (sys:range-test ,to-expr ,(qref ,awc rng-rec-temp)))) + ^(sys:rng (sys:awk-test ,from-expr ,(qref ,awc rng-rec-temp)) + (sys:awk-test ,to-expr ,(qref ,awc rng-rec-temp)))) (ff (. opip-args) ^(symacrolet ((f (rslot ,',aws-sym 'fields 'f-to-rec))) (set f [(opip ,*opip-args) f]))) @@ -215,7 +215,8 @@ (defmacro awk (:env e . clauses) (let ((awc (sys:awk-expander clauses))) (with-gensyms (aws-sym awk-begf-fun awk-fun awk-endf-fun awk-retval) - (let* ((p-actions-xform-unex (mapcar (aret ^(when ,@1 ,*@rest)) + (let* ((p-actions-xform-unex (mapcar (aret ^(when (sys:awk-test ,@1 rec) + ,*@rest)) awc.cond-actions)) (p-actions-xform (sys:expand ^(sys:awk-let ,awc ,aws-sym @@ -38320,7 +38320,17 @@ variable, and various variables are updated. Then, the condition-action clauses are processed, in the order in which they appear. Each .meta condition -is evaluated. If it yields true, then its associated +is evaluated. If the resulting value is a regular expression +or a function, then this regular expression or function is invoked on the value +stored in the record variable +.codn rec , +and the result is taken to be the truth value of +.metn condition . +Otherwise, if the resulting value of +.meta condition +is other than a function or regular expression, it is taken directly +to be the truth value. +If the condition is true, then its associated .meta action forms are evaluated. Either way, processing passes to the next condition clause (unless an explicit step is taken in one of the |