mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
Add 'verbose' flag
Now that we actually parse some of the dives, don't spam stdout with the list of stuff we can't parse by default. Add a 'verbose' flag, which enables that output when set. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
8a670bfb5c
commit
83e0bf8b52
1 changed files with 31 additions and 5 deletions
30
parse.c
30
parse.c
|
@ -7,6 +7,8 @@
|
|||
#include <libxml/parser.h>
|
||||
#include <libxml/tree.h>
|
||||
|
||||
static int verbose;
|
||||
|
||||
/*
|
||||
* Some silly typedefs to make our units very explicit.
|
||||
*
|
||||
|
@ -115,6 +117,7 @@ static void record_dive(struct dive *dive)
|
|||
|
||||
static void nonmatch(const char *type, const char *fullname, const char *name, char *buffer)
|
||||
{
|
||||
if (verbose)
|
||||
printf("Unable to match %s '(%.*s)%s' (%s)\n", type,
|
||||
(int) (name - fullname), fullname, name,
|
||||
buffer);
|
||||
|
@ -570,13 +573,36 @@ static void parse(const char *filename)
|
|||
xmlCleanupParser();
|
||||
}
|
||||
|
||||
static void parse_argument(const char *arg)
|
||||
{
|
||||
const char *p = arg+1;
|
||||
|
||||
do {
|
||||
switch (*p) {
|
||||
case 'v':
|
||||
verbose++;
|
||||
continue;
|
||||
default:
|
||||
fprintf(stderr, "Bad argument '%s'\n", arg);
|
||||
exit(1);
|
||||
}
|
||||
} while (*++p);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
|
||||
LIBXML_TEST_VERSION
|
||||
|
||||
for (i = 1; i < argc; i++)
|
||||
parse(argv[i]);
|
||||
for (i = 1; i < argc; i++) {
|
||||
const char *a = argv[i];
|
||||
|
||||
if (a[0] == '-') {
|
||||
parse_argument(a);
|
||||
continue;
|
||||
}
|
||||
parse(a);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue