summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2011-08-30 16:28:59 -0700
committerGravatar Linus Torvalds <torvalds@linux-foundation.org>2011-08-30 16:28:59 -0700
commit83e0bf8b520c54a9ef0b90ccf676022ae27e7737 (patch)
tree142901c423a414c5bd6cec0b65bff525bb10c496
parent8a670bfb5cf11a0b5bb02ab447fff31f589bb90a (diff)
downloadsubsurface-83e0bf8b520c54a9ef0b90ccf676022ae27e7737.tar.gz
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>
-rw-r--r--parse.c36
1 files changed, 31 insertions, 5 deletions
diff --git a/parse.c b/parse.c
index 67aa5a0c2..4f7ba6498 100644
--- a/parse.c
+++ b/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,9 +117,10 @@ static void record_dive(struct dive *dive)
static void nonmatch(const char *type, const char *fullname, const char *name, char *buffer)
{
- printf("Unable to match %s '(%.*s)%s' (%s)\n", type,
- (int) (name - fullname), fullname, name,
- buffer);
+ if (verbose)
+ printf("Unable to match %s '(%.*s)%s' (%s)\n", type,
+ (int) (name - fullname), fullname, name,
+ buffer);
free(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;
}