diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2009-02-22 12:29:58 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2009-02-22 12:29:58 +0200 |
commit | e7860f6f4b7da3e45eee6d2100dfb42823d8106f (patch) | |
tree | a9dca4490c567054391579b627ae5db14995f5dd /src/cmdline.opt | |
parent | 0b63c31eadfe5d4e94c7014bd0f3bd4370783d19 (diff) | |
download | wydawca-e7860f6f4b7da3e45eee6d2100dfb42823d8106f.tar.gz wydawca-e7860f6f4b7da3e45eee6d2100dfb42823d8106f.tar.bz2 |
Minor improvements
* src/report.c: New file
* src/Makefile.am (wydawca_SOURCES): Add report.c
* src/cmdline.opt: Group options.
New option -D (--define).
* src/directive.c (process_directives): Call report_init before processing
and report_finish afterwards.
* src/triplet.c: New meta-variable `report'.
* src/vtab.c (move_file, archive_file, symlink_file, rmsymlink_file): Update
report stack.
* src/wydawca.h: Include obstack.h
(report_init, report_add, report_finish): New protos.
(report_string): New declaration.
* src/builtin.c, src/meta.c: Remove obstack inclusion.
Diffstat (limited to 'src/cmdline.opt')
-rw-r--r-- | src/cmdline.opt | 85 |
1 files changed, 63 insertions, 22 deletions
diff --git a/src/cmdline.opt b/src/cmdline.opt index cb269f6..153199b 100644 --- a/src/cmdline.opt +++ b/src/cmdline.opt @@ -14,15 +14,44 @@ You should have received a copy of the GNU General Public License along with wydawca. If not, see <http://www.gnu.org/licenses/>. */ +static struct obstack pp_cmd_stack; +static int pp_cmd_stack_init; + OPTIONS_BEGIN(gnu, "wydawca", [<wydawca synchronizes files from a set of upload directories with the corresponding distribution sites>]) +GROUP(Selecting program mode) + +OPTION(lint,t,, + [<parse configuration file and exit>]) +BEGIN + lint_mode = 1; + log_to_stderr = 1; +END + +OPTION(,E,, + [<preprocess config and exit>]) +BEGIN + preprocess_only = 1; +END + +OPTION(dry-run,n,, + [<do nothing, print almost everything; implies `--debug --stderr', + use additional `--debug' options to get even more info>]) +BEGIN + log_to_stderr = 1; + debug_level++; + dry_run_mode = 1; +END + OPTION(config-file,c,FILE, [<use FILE instead of the default configuration>]) BEGIN conffile = optarg; END +GROUP(Logging) + OPTION(cron,,, [<log to syslog>]) ALIAS(syslog) @@ -36,11 +65,7 @@ BEGIN log_to_stderr = 1; END -OPTION(debug,d,, - [<increase debugging level>]) -BEGIN - debug_level++; -END +GROUP(Preprocessor control) OPTION(include-directory,I,[DIR], [<add include directory>]) @@ -48,20 +73,24 @@ BEGIN gconf_preproc_add_include_dir (optarg); END -OPTION(dry-run,n,, - [<do nothing, print almost everything; implies `--debug --stderr', - use additional `--debug' options to get even more info>]) +OPTION(define,D,SYMBOL[=VALUE], + [<define a preprocessor symbol>]) BEGIN - log_to_stderr = 1; - debug_level++; - dry_run_mode = 1; -END - -OPTION(lint,t,, - [<parse configuration file and exit>]) -BEGIN - lint_mode = 1; - log_to_stderr = 1; + char *p; + + if (!pp_cmd_stack_init) + { + obstack_init (&pp_cmd_stack); + pp_cmd_stack_init = 1; + } + obstack_grow (&pp_cmd_stack, " \"-D", 4); + for (p = optarg; *p; p++) + { + if (*p == '\\' || *p == '"') + obstack_1grow (&pp_cmd_stack, '\\'); + obstack_1grow (&pp_cmd_stack, *p); + } + obstack_1grow (&pp_cmd_stack, '"'); END OPTION(preprocessor,,COMMAND, @@ -76,10 +105,12 @@ BEGIN gconf_preprocessor = NULL; END -OPTION(,E,, - [<preprocess config and exit>]) +GROUP(Debugging) + +OPTION(debug,d,, + [<increase debugging level>]) BEGIN - preprocess_only = 1; + debug_level++; END OPTION(dump-grammar-trace,,, @@ -94,6 +125,7 @@ BEGIN gconf_lex_trace (1); END +GROUP([<Additional help>]) OPTION(config-help,,, [<show configuration file summary>]) BEGIN @@ -106,5 +138,14 @@ OPTIONS_END void parse_options(int argc, char *argv[]) { - GETOPT(argc, argv) + GETOPT(argc, argv) + if (pp_cmd_stack_init && gconf_preprocessor) + { + char *defs = obstack_finish (&pp_cmd_stack); + char *cmd = xmalloc (strlen (gconf_preprocessor) + strlen (defs) + 1); + strcpy (cmd, gconf_preprocessor); + strcat (cmd, defs); + gconf_preprocessor = cmd; + obstack_free (&pp_cmd_stack, NULL); + } } |