aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-05-26 22:47:14 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2011-05-26 22:47:14 +0300
commit4e4076a31d6d951dcfab668709993fae6a2cc926 (patch)
tree70e0685eb961c0c52ea63728c27590d7adfb4cd9
parent1a1716dedf67740f21e6db479ce461fadcc05cc3 (diff)
downloadcfpeek-4e4076a31d6d951dcfab668709993fae6a2cc926.tar.gz
cfpeek-4e4076a31d6d951dcfab668709993fae6a2cc926.tar.bz2
Various fixes.
* grecs: Update. * configure.ac (GRECS_SETUP): Add syntax-doc flag. * doc/GNUmakefile (BUILT_SOURCES): Add scripting.texi. (scripting.texi): New rule. * doc/Makefile.am (BUILT_SOURCES): Remove scripting.texi. (scripting.texi): Move to GNUmakefile. * doc/cfpeek.texi: Update. * doc/macros.texi (runex): Remove @kbd * src/cmdline.opt (parse_options): Force default flags GRECS_NODE_FLAG_PATH|GRECS_NODE_FLAG_VALUE.
-rw-r--r--configure.ac2
-rw-r--r--doc/GNUmakefile6
-rw-r--r--doc/Makefile.am5
-rw-r--r--doc/cfpeek.texi94
-rw-r--r--doc/macros.texi2
m---------grecs0
-rw-r--r--src/cmdline.opt8
7 files changed, 100 insertions, 17 deletions
diff --git a/configure.ac b/configure.ac
index dd7b09e..4416c03 100644
--- a/configure.ac
+++ b/configure.ac
@@ -38,7 +38,7 @@ AC_HEADER_STDC
# Grecs subsystem
-GRECS_SETUP(grecs, [tests getopt git2chg all-parsers])
+GRECS_SETUP(grecs, [tests getopt git2chg all-parsers syntax-doc])
# GINT
diff --git a/doc/GNUmakefile b/doc/GNUmakefile
index 1a6492f..feca637 100644
--- a/doc/GNUmakefile
+++ b/doc/GNUmakefile
@@ -16,7 +16,11 @@
include Makefile
-BUILT_SOURCES += $(LISTINGS)
+BUILT_SOURCES += $(LISTINGS) scripting.texi
+
+scripting.texi: $(top_srcdir)/src/guile-procedures.texi
+ cat $(top_srcdir)/src/guile-procedures.texi | \
+ tr '\f' '\\' | sed '/^\\/d' > scripting.texi
$(LISTINGS): cfpeek.texi
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 515f94e..2cc6690 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -39,7 +39,6 @@ cfpeek_TEXINFOS=\
$(LISTINGS)
BUILT_SOURCES = \
- scripting.texi\
sample.texi
EXTRA_DIST = sample.conf GNUmakefile togit.scm
@@ -57,10 +56,6 @@ GENDOCS=gendocs.sh
TEXI2DVI=texi2dvi -t '@set $(RENDITION)' -E
-scripting.texi: $(top_srcdir)/src/guile-procedures.texi
- cat $(top_srcdir)/src/guile-procedures.texi | \
- tr '\f' '\\' | sed '/^\\/d' > scripting.texi
-
# Make sure you set TEXINPUTS.
# TEXINPUTS=/usr/share/texmf/pdftex/plain/misc/ is ok for most distributions
.PHONY: manual
diff --git a/doc/cfpeek.texi b/doc/cfpeek.texi
index f158573..1bbd03a 100644
--- a/doc/cfpeek.texi
+++ b/doc/cfpeek.texi
@@ -97,6 +97,8 @@ Tutorial
* Listing:: How to Produce File Listing.
* Lookups:: Statement Lookups.
* Pattern Lookups:: Searches Using Wildcard Patterns.
+* Parsers:: Using Various Parsers.
+* Nodes to Print::
* Scripts:: Using Scheme to Extend Cfpeek Functionality.
Using Scripts
@@ -166,9 +168,8 @@ The following typographic conventions are used throughout this
tutorial.
In the examples, @samp{$} represents a typical shell prompt. It
-precedes lines you should type; to make this more clear, those lines are
-shown in @kbd{this font}, as opposed to lines which represent the
-program output, which are shown in @samp{this font}.
+precedes lines you should type. Both command line and lines which
+represent the program output are shown in @samp{this font}.
The Scheme code is shown as follows:
@@ -190,6 +191,8 @@ x @result{} 2
* Listing:: How to Produce File Listing.
* Lookups:: Statement Lookups.
* Pattern Lookups:: Searches Using Wildcard Patterns.
+* Parsers:: Using Various Parsers.
+* Nodes to Print::
* Scripts:: Using Scheme to Extend Cfpeek Functionality.
@end menu
@@ -336,22 +339,32 @@ each of which modifies some aspect of the output. Most output flags
are boolean, i.e. they enable or disable the given feature. To
disable the feature, the flag must be prefixed with @samp{no}.
-The default output is equivalent to @option{--format=path,value,descend}.
-
@kwindex path, format flag
To list only the pathnames, use
@runex{list2, cfpeek --format=path sample.conf}
+The default output is equivalent to @option{--format=path,value,descend}.
+
+@kwindex value
+@kwindex descend
+The flags @samp{path} and @samp{value} mean to print the pathname of
+the statement and its value. The @samp{descend} flag affects the
+output of compound nodes. If this flag is set and a node matching the
+key is a compound node, @command{cfpeek} will output this node and all
+nodes below it (i.e. its descendant nodes). The @samp{descend} flag
+is meaningful only if at least one lookup key is supplied.
+
@kwindex delim, format flag
-You can also change the default component delimiter. For example, to
-use slash to delimit components:
+You can also use @option{--format} to change the default component
+delimiter. For example, to use slash to delimit components:
@runex{list3, cfpeek --format=delim=/ sample.conf}
@node Lookups
@section Statement Lookups
@cindex search key
+@cindex look-up key
@cindex statement look-up
When given more than one argument, @command{cfpeek} treats the rest of
arguments as @dfn{search keys}. It then searches for statements with
@@ -454,6 +467,73 @@ cycles. Secondly, if any of your identifiers contain @samp{*} or @samp{%}
characters, you will have to use @option{--literal} to prevent them
from being treated as wildcards.
+@node Parsers
+@section Using Various Parsers
+@cindex input formats
+@cindex input parsers
+@xopindex{parser,p,described}
+@command{Cfpeek} can handle input files in various formats. The
+default one is @samp{Grecs} format, introduced in previous sections.
+To process input files of another format, specify the @dfn{parser} to
+use via the @option{--parser} (@option{-p}) command line option. The
+argument to this option is one of: @samp{grecs}, @samp{bind},
+@samp{path}, @samp{meta1} or @samp{git}. @xref{Formats}, for a
+detailed description of each of these formats.
+
+For example, to select zone statements from the @file{/etc/named.conf}
+file:
+
+@example
+$ cfpeek --parser=bind /etc/named.conf '.*.zone'
+@end example
+
+@node Nodes to Print
+@section Specifying Nodes to Output
+Sometimes you may need to see not the node which matched the search
+key, but its parent or other ancestor node. Consider, for example,
+the following task: select from the @file{/etc/named.conf} file the names
+of all zones for which this nameserver is a master. To do so, you
+will need to find all @samp{zone.type} statements with the value
+@samp{master}, ascend to the parent node and print its value.
+
+@command{Cfpeek} provides two special formatting flags to that
+effect: @code{up} and @code{parent}. Both flags are used with
+the @option{--format} option.
+
+@kwindex up
+The @code{up} flag requires an integer number as its argument. It
+instructs @command{cfpeek} to ascend that many parent nodes before
+actually printing the node. For example, @option{--format=up=1} means
+``ascend to the parent of the matched node and print it''. This is
+exactly what we need to solve the above task, since the @samp{type}
+statement is a child of a @samp{zone} statement. Thus, the solution
+is:
+
+@example
+./cfpeek --format=up=1,nodescend,value --parser=bind \
+ /etc/named.conf .*.type=master
+@end example
+
+@noindent
+The @code{value} flag indicates that we want on output only values, without
+the corresponding pathnames. The @code{nodescend} flag tells
+@command{cfpeek} to not descend into compound statements when
+outputting them. It is necessary since we want only values of all
+relevant @samp{zone} statements, no their subordinate statements.
+
+@kwindex parent
+The @code{parent} flag act in the similar manner, but it identifies
+the ancestor by its keyword, instead of the relative nesting level.
+The statement
+
+@example
+--format=parent=zone
+@end example
+
+@noindent
+tells @command{cfpeek}, after finding a matching node, to ascend until
+a node with the identifier @samp{zone} is found, and then print this node.
+
@node Scripts
@section Using Scripts
@cindex Scheme
diff --git a/doc/macros.texi b/doc/macros.texi
index a086f04..03d0ef9 100644
--- a/doc/macros.texi
+++ b/doc/macros.texi
@@ -36,7 +36,7 @@
@macro runex{file,command}
@example
-$ @kbd{\command\}
+$ \command\
@include \file\.lst
@end example
@end macro
diff --git a/grecs b/grecs
-Subproject a98d3bcc6bcd42b4a2bc405183c531f4dcccd06
+Subproject 8893389e6bbd27b03d77b7ffa63061e543e8df0
diff --git a/src/cmdline.opt b/src/cmdline.opt
index 944bb9d..8ddfffd 100644
--- a/src/cmdline.opt
+++ b/src/cmdline.opt
@@ -335,8 +335,12 @@ parse_options(int argc, char *argv[])
print_help_hook = flags_help;
GETOPT(argc, argv, file_index, exit(EX_USAGE))
if (!(flags_on & _GRECS_NODE_MASK_OUTPUT))
- flags_on |= GRECS_NODE_FLAG_DEFAULT;
- flags = flags_on & ~flags_off;
+ flags_on |= GRECS_NODE_FLAG_PATH|GRECS_NODE_FLAG_VALUE;
+ flags = flags_on & ~flags_off;
+ if (!(flags & (GRECS_NODE_FLAG_PATH|GRECS_NODE_FLAG_VALUE))) {
+ grecs_warning(NULL, 0, "assuming --format=path,value");
+ flags |= GRECS_NODE_FLAG_PATH|GRECS_NODE_FLAG_VALUE;
+ }
if (preproc_settings == PREPROC_DEFAULT)
grecs_preprocessor = DEFAULT_PREPROCESSOR;
if (pp_cmd_acc && grecs_preprocessor) {

Return to:

Send suggestions and report system problems to the System administrator.