diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2005-09-26 12:51:24 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2005-09-26 12:51:24 +0000 |
commit | 6635ff5bfd4a5c1e52e3e9666c080d296fc7231b (patch) | |
tree | 5d7719be4723759a6cbfb5cd637337aacf4669b9 | |
parent | 9ad5a64c8b1478abf6f629b7c06a0a6ab9c7efb2 (diff) | |
download | cflow-6635ff5bfd4a5c1e52e3e9666c080d296fc7231b.tar.gz cflow-6635ff5bfd4a5c1e52e3e9666c080d296fc7231b.tar.bz2 |
Use --no-OPTION instead of --OPTION=no
-rw-r--r-- | doc/cflow.texi | 41 | ||||
-rw-r--r-- | src/main.c | 122 |
2 files changed, 105 insertions, 58 deletions
diff --git a/doc/cflow.texi b/doc/cflow.texi index 90370f1..7fe34b8 100644 --- a/doc/cflow.texi +++ b/doc/cflow.texi @@ -129,7 +129,6 @@ files. It is a good idea to add a node @samp{POSIX} discussing this.} @node Quick Start, Direct and Reverse, Intro, Top @chapter Simple Ways to Analyze Programs with @command{cflow}. -@UNREVISED{} Let's begin our acquaintance with the GNU @command{cflow} utility with an example. Suppose you have a simple implementation of @command{whoami} command and you wish to obtain a graph of function @@ -875,7 +874,6 @@ listing of type names defined by @code{typedef} keyword. @node Configuration, Makefiles, Cross-References, Top @chapter Configuration Files and Variables. -@UNREVISED{} As shown in the previous chapters, GNU @command{cflow} is highly configurable. Different command line options have different effects, as specifying new operation modes or altering some aspects of the @@ -936,18 +934,11 @@ following configuration file: It may sometimes be necessary to cancel the effect of a command line option. For example, you might specify @option{--brief} in your configuration file, but then occasionally need to obtain verbose -graph. To make this possible, most of GNU @command{cflow} options take -an optional argument: a boolean value (@samp{yes} or @samp{no}), -specifying whether to enable or disable this option. Thus, setting -@option{--brief=no} cancels the effect of the previous -@option{--brief} option. @FIXME{This is very inconvenient, since (a) -this makes it impossible to cluster options, as in @command{cflow --nl}; (b) not all options take a boolean value, some of them -(e.g. @option{--cpp}) have a @option{--no-@var{option}} counterpart, -and some (e.g. @option{-r}) do not allow cancellation at all. Ideally, -each @dfn{toggle} option should have a @option{--no-} counterpart. For -the time being I will have to implement this in @file{main.c}, but in -the future I plan to introduce this support into @command{argp} module.} +graph. To cancel effect of any GNU @command{cflow} option that does +not take arguments, prepend @samp{no-} to the corresponding long +option name. Thus, specifying @option{--no-brief} cancels the effect +of the previous @option{--brief} option. @FIXME{The @samp{--no-} support +should be implemented in @command{argp} module.} @node Makefiles, Options, Configuration, Top @chapter Using @command{cflow} in Makefiles. @@ -1026,7 +1017,15 @@ cflow.cflow: $(cflow_CFLOW_INPUT) cflow.rc Makefile references to more in-depth explanations in the body of the manual. Both short and long option forms are listed, so you can use this table as a quick reference. - + + Any simple option (i.e. the one that does not take arguments) +have also its @samp{no-} counterpart, that cancels its effect. For +example, @option{--no-number} disables previous +@option{--number} option. It is provided to cancel default options +specified in the configuration file. + + The @samp{no-} prefix is applicable only to long option names. + @table @option @cindex @option{-a} @cindex @option{--ansi} @@ -1038,8 +1037,8 @@ declarations}. This might speed up the processing in some cases. @cindex @option{-b} @cindex @option{--brief} -@item -b [@var{bool}] -@item --brief[=@var{bool}] +@item -b +@item --brief Brief output. @xref{--brief}. @cindex @option{--cpp} @@ -1151,8 +1150,8 @@ For more information, @xref{Symbols}. @cindex @option{-n} @cindex @option{--number} -@item -n [@var{booll}] -@itemx --number[=@var{bool}] +@item -n +@itemx --number Print line numbers. @xref{--number}. @cindex @option{-o} @@ -1206,8 +1205,8 @@ abbreviation of the above is also accepted. @xref{--symbol}. @cindex @option{-S} @cindex @option{--use-indentation} -@item -S [@var{bool}] -@itemx --use-indentation[=@var{bool}] +@item -S +@itemx --use-indentation Use source file indentation as a hint. Currently this means that the closing curly brace (@samp{@}}) in the column zero forces @command{cflow} to close current function definition. Use this option @@ -23,14 +23,27 @@ const char *argp_program_version = "cflow (" PACKAGE_NAME ") " VERSION; const char *argp_program_bug_address = "<" PACKAGE_BUGREPORT ">"; -static char doc[] = N_("generate a program flowgraph"); - -#define OPT_DEFINES 256 -#define OPT_LEVEL_INDENT 257 -#define OPT_DEBUG 258 -#define OPT_PREPROCESS 259 -#define OPT_NO_PREPROCESS 260 -#define OPT_EMACS 261 +/* TRANSLATORS: Please, preserve the vertical tabulation (^K character) + in this message */ +static char doc[] = N_("generate a program flowgraph\vThe effect of any option, not taking an argument, can be cancelled by prepending 'no-' to the corresponding long option name (e.g. --no-cpp cancels --cpp)"); + +enum option_code { + OPT_DEFINES = 256, + OPT_LEVEL_INDENT, + OPT_DEBUG, + OPT_PREPROCESS, + OPT_NO_PREPROCESS, + OPT_EMACS, + OPT_NO_USE_INDENTATION, + OPT_NO_ANSI, + OPT_NO_TREE, + OPT_NO_BRIEF, + OPT_NO_EMACS, + OPT_NO_VERBOSE, + OPT_NO_NUMBER, + OPT_NO_PRINT_LEVEL, + OPT_NO_REVERSE +}; static struct argp_option options[] = { #define GROUP_ID 0 @@ -38,12 +51,10 @@ static struct argp_option options[] = { N_("General options:"), GROUP_ID }, { "depth", 'd', N_("NUMBER"), 0, N_("Set the depth at which the flowgraph is cut off"), GROUP_ID+1 }, - { "include", 'i', N_("SPEC"), 0, - N_("Control the number of included symbols. SPEC is a string consisting of characters, specifying what class of symbols to include in the output (see below)."), GROUP_ID+1 }, - - + { "include", 'i', N_("CLASSES"), 0, + N_("Include specified classes of symbols (see below). Prepend CLASSES with ^ or - to exclude them from the output"), GROUP_ID+1 }, { "format", 'f', N_("NAME"), 0, - N_("Use given output format NAME. Valid names are gnu (default) and posix"), + N_("Use given output format NAME. Valid names are `gnu' (default) and `posix'"), GROUP_ID+1 }, { "reverse", 'r', NULL, 0, N_("Print reverse call tree"), GROUP_ID+1 }, @@ -56,14 +67,7 @@ static struct argp_option options[] = { N_("Set output file name (default -, meaning stdout)"), GROUP_ID+1 }, - { NULL, 0, NULL, 0, - N_("Valid SPEC symbols for --include option:"), GROUP_ID+2 }, - {" +", 0, NULL, OPTION_DOC|OPTION_NO_TRANS, - N_("Include symbols denoted by the following letters (default)"), - GROUP_ID+3 }, - {" - or ^", 0, NULL, OPTION_DOC|OPTION_NO_TRANS, - N_("Exclude symbols denoted by the following letters"), - GROUP_ID+3 }, + { NULL, 0, NULL, 0, N_("Symbols classes for --include argument"), GROUP_ID+2 }, {" x", 0, NULL, OPTION_DOC|OPTION_NO_TRANS, N_("all data symbols, both external and static"), GROUP_ID+3 }, {" _", 0, NULL, OPTION_DOC|OPTION_NO_TRANS, @@ -72,19 +76,24 @@ static struct argp_option options[] = { N_("static symbols"), GROUP_ID+3 }, {" t", 0, NULL, OPTION_DOC|OPTION_NO_TRANS, N_("typedefs (for cross-references only)"), GROUP_ID+3 }, + #undef GROUP_ID #define GROUP_ID 10 { NULL, 0, NULL, 0, N_("Parser control:"), GROUP_ID }, - { "use-indentation", 'S', N_("BOOL"), OPTION_ARG_OPTIONAL, + { "use-indentation", 'S', NULL, 0, N_("Rely on indentation"), GROUP_ID+1 }, + { "no-use-indentation", OPT_NO_USE_INDENTATION, NULL, OPTION_HIDDEN, + "", GROUP_ID+1 }, { "ansi", 'a', NULL, 0, N_("Assume input to be written in ANSI C"), GROUP_ID+1 }, + { "no-ansi", OPT_NO_ANSI, NULL, OPTION_HIDDEN, + "", GROUP_ID+1 }, { "pushdown", 'p', N_("NUMBER"), 0, N_("Set initial token stack size to NUMBER"), GROUP_ID+1 }, - { "symbol", 's', N_("SYM:TYPE"), 0, - N_("Make cflow believe the symbol SYM is of type TYPE. Valid types are: keyword (or kw), modifier, identifier, type, wrapper. Any unambiguous abbreviation of the above is also accepted"), GROUP_ID+1 }, + { "symbol", 's', N_("SYMBOL:TYPE"), 0, + N_("Register SYMBOL with given TYPE. Valid types are: keyword (or kw), modifier, identifier, type, wrapper. Any unambiguous abbreviation of the above is also accepted"), GROUP_ID+1 }, { "main", 'm', N_("NAME"), 0, N_("Assume main function to be called NAME"), GROUP_ID+1 }, { "define", 'D', N_("NAME[=DEFN]"), 0, @@ -96,31 +105,43 @@ static struct argp_option options[] = { { "preprocess", OPT_PREPROCESS, N_("COMMAND"), OPTION_ARG_OPTIONAL, N_("Run the specified preprocessor command"), GROUP_ID+1 }, { "cpp", 0, NULL, OPTION_ALIAS, NULL, GROUP_ID+1 }, - { "no-preprocess", OPT_NO_PREPROCESS, NULL, 0, - N_("Do not preprocess the sources"), GROUP_ID+1 }, - { "no-cpp", 0, NULL, OPTION_ALIAS, NULL, GROUP_ID+1 }, + { "no-preprocess", OPT_NO_PREPROCESS, NULL, OPTION_HIDDEN, + "", GROUP_ID+1 }, + { "no-cpp", 0, NULL, OPTION_ALIAS|OPTION_HIDDEN, NULL, GROUP_ID+1 }, #undef GROUP_ID #define GROUP_ID 20 { NULL, 0, NULL, 0, N_("Output control:"), GROUP_ID }, - { "number", 'n', N_("BOOL"), OPTION_ARG_OPTIONAL, + { "number", 'n', NULL, 0, N_("Print line numbers"), GROUP_ID+1 }, + { "no-number", OPT_NO_NUMBER, NULL, OPTION_HIDDEN, + "", GROUP_ID+1 }, { "print-level", 'l', NULL, 0, N_("Print nesting level along with the call tree"), GROUP_ID+1 }, + { "no-print-level", OPT_NO_PRINT_LEVEL, NULL, OPTION_HIDDEN, + "", GROUP_ID+1 }, { "level-indent", OPT_LEVEL_INDENT, "STRING", 0, N_("Use STRING when indenting to each new level"), GROUP_ID+1 }, { "tree", 'T', NULL, 0, N_("Draw ASCII art tree"), GROUP_ID+1 }, - { "brief", 'b', N_("BOOL"), OPTION_ARG_OPTIONAL, + { "no-tree", OPT_NO_TREE, NULL, OPTION_HIDDEN, + "", GROUP_ID+1 }, + { "brief", 'b', NULL, 0, N_("Brief output"), GROUP_ID+1 }, + { "no-brief", OPT_NO_BRIEF, NULL, OPTION_HIDDEN, + "", GROUP_ID+1 }, { "emacs", OPT_EMACS, NULL, 0, N_("Additionally format output for use with GNU Emacs"), GROUP_ID+1 }, + { "no-emacs", OPT_NO_EMACS, NULL, OPTION_HIDDEN, + "", GROUP_ID+1 }, #undef GROUP_ID #define GROUP_ID 30 { NULL, 0, NULL, 0, N_("Informational options:"), GROUP_ID }, { "verbose", 'v', NULL, 0, N_("Be verbose on output"), GROUP_ID+1 }, + { "no-verbose", OPT_NO_VERBOSE, NULL, OPTION_HIDDEN, + "", GROUP_ID+1 }, { "license", 'L', 0, 0, N_("Print license and exit"), GROUP_ID+1 }, { "debug", OPT_DEBUG, "NUMBER", OPTION_ARG_OPTIONAL, @@ -197,8 +218,6 @@ char *start_name = "main"; /* Name of start symbol */ Consptr arglist; /* List of command line arguments */ -#define boolean_value(arg) ((arg) ? ((arg)[0] == 'y' || (arg)[0] == 'Y') : 1) - /* Given the option_type array and (possibly abbreviated) option argument * find the type corresponding to that argument. * Return 0 if the argument does not match any one of OPTYPE entries @@ -391,7 +410,7 @@ parse_level_string(const char *str, char **return_ptr) if (p == text) { goto copy; } - num = strtol(str+1, &str, 10); + num = strtol(str+1, (char**)&str, 10); c = p[-1]; for (i = 1; i < num; i++) { *p++ = c; @@ -485,6 +504,9 @@ parse_opt (int key, char *arg, struct argp_state *state) case 'a': strict_ansi = 1; break; + case OPT_NO_ANSI: + strict_ansi = 0; + break; case OPT_DEBUG: debug = arg ? atoi(arg) : 1; break; @@ -496,7 +518,10 @@ parse_opt (int key, char *arg, struct argp_state *state) set_print_option(arg); break; case 'S': - use_indentation = boolean_value(arg); + use_indentation = 1; + break; + case OPT_NO_USE_INDENTATION: + use_indentation = 0; break; case 'T': print_as_tree = 1; @@ -505,20 +530,31 @@ parse_opt (int key, char *arg, struct argp_state *state) set_level_indent("end0=+-"); set_level_indent("end1=\\\\-"); break; + case OPT_NO_TREE: + print_as_tree = 0; + level_indent[0] = level_indent[1] = NULL; + level_end[0] = level_end[0] = NULL; + break; case 'b': - brief_listing = boolean_value(arg); + brief_listing = 1; + break; + case OPT_NO_BRIEF: + brief_listing = 0; break; case 'd': max_depth = atoi(arg); if (max_depth < 0) max_depth = 0; break; - case OPT_DEFINES: + case OPT_DEFINES: /* FIXME: Not used. */ record_defines = 1; break; case OPT_EMACS: emacs_option = 1; break; + case OPT_NO_EMACS: + emacs_option = 0; + break; case 'f': if (select_output_driver(arg)) argp_error(state, _("%s: No such output driver"), optarg); @@ -553,12 +589,18 @@ parse_opt (int key, char *arg, struct argp_state *state) break; case 'l': print_levels = 1; - break; + break; + case OPT_NO_PRINT_LEVEL: + print_levels = 0; + break; case 'm': start_name = strdup(arg); break; case 'n': - print_line_numbers = boolean_value(arg); + print_line_numbers = 1; + break; + case OPT_NO_NUMBER: + print_line_numbers = 0; break; case 'o': outname = strdup(arg); @@ -571,12 +613,18 @@ parse_opt (int key, char *arg, struct argp_state *state) case 'r': reverse_tree = 1; break; + case OPT_NO_REVERSE: + reverse_tree = 0; + break; case 's': symbol_override(arg); break; case 'v': verbose = 1; break; + case OPT_NO_VERBOSE: + verbose = 0; + break; case 'x': print_option = PRINT_XREF; break; |