[augeas-devel] [PATCH] * src/lens.c (lns_check_rec): allow 'let rec' with regular RHS

lutter at redhat.com lutter at redhat.com
Fri Jul 23 20:35:23 UTC 2010


From: David Lutterkort <lutter at redhat.com>

If the user writes 'let rec l = rhs' and the RHS does not mention l, just
mark the lens as regular and carry on.
---
 src/lens.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/src/lens.c b/src/lens.c
index 41fcd50..29859f5 100644
--- a/src/lens.c
+++ b/src/lens.c
@@ -2023,9 +2023,15 @@ struct value *lns_check_rec(struct info *info,
     struct value *result = NULL;
 
     ensure(rec->tag == L_REC, info);
-    ensure(body->recursive, info);
     ensure(rec->rec_internal, info);
 
+    /* The user might have written down a regular lens with 'let rec' */
+    if (! body->recursive) {
+        result = make_lens_value(ref(body));
+        ERR_NOMEM(result == NULL, info);
+        return result;
+    }
+
     /* To help memory management, we avoid the cycle inherent ina recursive
      * lens by using two instances of an L_REC lens. One is marked with
      * rec_internal, and used inside the body of the lens. The other is the
-- 
1.7.1.1




More information about the augeas-devel mailing list