[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[augeas-devel] augeas: master - * src/jmt.c (build_trace): allow passing in a NULL item



Gitweb:        http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=aa5a167aa623d0be9aebcf845f97bf501c86aa5a
Commit:        aa5a167aa623d0be9aebcf845f97bf501c86aa5a
Parent:        ed87fff127e34806ab6f867240704549f2cc31c6
Author:        David Lutterkort <lutter redhat com>
AuthorDate:    Mon Jan 25 16:54:21 2010 -0800
Committer:     David Lutterkort <lutter redhat com>
CommitterDate: Mon Jan 25 18:04:33 2010 -0800

* src/jmt.c (build_trace): allow passing in a NULL item

---
 src/jmt.c |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/jmt.c b/src/jmt.c
index acc110c..04c17d5 100644
--- a/src/jmt.c
+++ b/src/jmt.c
@@ -760,14 +760,18 @@ build_nullable(struct jmt_parse *parse, ind_t pos,
 }
 
 static void build_trace(const char *msg, ind_t start, ind_t end,
-                struct item *x, int lvl) {
+                        struct item *x, int lvl) {
     for (int i=0; i < lvl; i++) putc(' ', stderr);
-    printf("%s %d..%d: (%d, %d) %d %s%s%s\n", msg,
-           start, end, x->state->num,
-           x->parent, x->links->lens,
-           is_complete(x->links) ? "C" : "",
-           is_predict(x->links) ? "P" : "",
-           is_scan(x->links) ? "S" : "");
+    if (x != NULL) {
+        printf("%s %d..%d: (%d, %d) %d %s%s%s\n", msg,
+               start, end, x->state->num,
+               x->parent, x->links->lens,
+               is_complete(x->links) ? "c" : "",
+               is_predict(x->links) ? "p" : "",
+               is_scan(x->links) ? "s" : "");
+    } else {
+        printf("%s %d..%d\n", msg, start, end);
+    }
 }
 
 static int ambig_check(struct jmt_visitor *visitor, struct lens *lens,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]