aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-05-20 09:23:00 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2011-05-20 09:23:00 +0300
commit1e71f32eb0839e8ae9daa436d706c8e6cd116d5a (patch)
tree4172bbef9326dc5344f27f85c043fd7655cb9fc3 /src
parentc820e08d8ab56265450204fe374ef31c5d6259cd (diff)
downloadcfpeek-1e71f32eb0839e8ae9daa436d706c8e6cd116d5a.tar.gz
cfpeek-1e71f32eb0839e8ae9daa436d706c8e6cd116d5a.tar.bz2
Minor improvements.
* src/cfpeek.c (all_option): Remove. (main): If no paths are given, scan entire tree. * src/cmdline.opt: Remove the --all option. * src/guile.c (_guile_node_print): Do not descend into subnodes. * grecs: Update.
Diffstat (limited to 'src')
-rw-r--r--src/cfpeek.c30
-rw-r--r--src/cmdline.opt8
-rw-r--r--src/guile.c5
3 files changed, 24 insertions, 19 deletions
diff --git a/src/cfpeek.c b/src/cfpeek.c
index 7974100..55bceb2 100644
--- a/src/cfpeek.c
+++ b/src/cfpeek.c
@@ -20,7 +20,6 @@
int file_index;
int flags = GRECS_NODE_FLAG_PATH|GRECS_NODE_FLAG_VALUE;
int quiet_option;
-int all_option;
int reduce_option;
int sort_option;
unsigned max_matches;
@@ -155,6 +154,23 @@ print_node(struct grecs_node *node)
cfpeek_print(node);
}
+static enum grecs_tree_recurse_res
+eval_rec(enum grecs_tree_recurse_op op, struct grecs_node *node, void *data)
+{
+ if (op == grecs_tree_recurse_set)
+ script_run(node);
+ return grecs_tree_recurse_ok;
+}
+
+static void
+scan_tree(struct grecs_node *tree)
+{
+ if (script_file || script_expr) {
+ grecs_tree_recurse(tree, eval_rec, NULL);
+ } else
+ cfpeek_print(tree);
+}
+
int
main(int argc, char **argv)
{
@@ -183,18 +199,10 @@ main(int argc, char **argv)
grecs_tree_reduce(tree, NULL, 0);
if (sort_option)
grecs_tree_sort(tree, node_ident_cmp);
- if (all_option) {
- if (argc > 1) {
- grecs_error(NULL, 0, "too many arguments for --all");
- exit(EX_USAGE);
- }
- cfpeek_print(tree);
- exit(0);
- }
if (argc < 2) {
- grecs_error(NULL, 0, "not enough arguments");
- exit(EX_USAGE);
+ scan_tree(tree);
+ exit(0);
}
cfp = &cfpeek_engine[mode];
diff --git a/src/cmdline.opt b/src/cmdline.opt
index c47f756..c0d3453 100644
--- a/src/cmdline.opt
+++ b/src/cmdline.opt
@@ -151,7 +151,7 @@ set_flag(const char *str)
OPTIONS_BEGIN("cfpeek",
[<Get variables from a configuration file>],
- [<FILE PATH [PATH...]>],
+ [<FILE [PATH...]>],
[<gnu>],
[<copyright_year=2011>],
[<copyright_holder=Sergey Poznyakoff>])
@@ -180,12 +180,6 @@ BEGIN
quiet_option++;
END
-OPTION(all,a,,
- [<print all settings>])
-BEGIN
- all_option = 1;
-END
-
GROUP(Modifiers)
OPTION(parser,p,[<GRECS|META1|BIND|GIT|PATH>],
diff --git a/src/guile.c b/src/guile.c
index 68b75a3..f682714 100644
--- a/src/guile.c
+++ b/src/guile.c
@@ -138,7 +138,10 @@ _guile_node_print(SCM smob, SCM port, scm_print_state *pstate)
if (np->node->type == grecs_node_root)
scm_puts(".", port);
else
- grecs_format_node(np->node, GRECS_NODE_FLAG_DEFAULT, &clos);
+ grecs_format_node(np->node,
+ GRECS_NODE_FLAG_DEFAULT|
+ GRECS_NODE_FLAG_NODESCEND,
+ &clos);
scm_puts(">", port);
return 1;
}

Return to:

Send suggestions and report system problems to the System administrator.