Introduction
Introduction Statistics Contact Development Disclaimer Help
show usage on invalid flags or any arguments - json2tsv - JSON to TSV converter
git clone git://git.codemadness.org/json2tsv
Log
Files
Refs
README
LICENSE
---
commit f4ae5c240dbe7ca52eb9b7a7ab0a94a4fe3b6f06
parent e569792c8bc41e19f1702ae57bbfbebc9fc64bff
Author: Hiltjo Posthuma <[email protected]>
Date: Sun, 29 Dec 2019 18:42:53 +0100
show usage on invalid flags or any arguments
Diffstat:
M json2tsv.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/json2tsv.c b/json2tsv.c
@@ -66,6 +66,13 @@ processnode(struct json_node *nodes, size_t depth, const cha…
putchar('\n');
}
+void
+usage(const char *argv0)
+{
+ fprintf(stderr, "usage: %s [-n] [-r]\n", argv0);
+ exit(1);
+}
+
int
main(int argc, char *argv[])
{
@@ -77,12 +84,13 @@ main(int argc, char *argv[])
}
for (i = 1; i < argc; i++) {
- if (argv[i][0] != '-')
- continue;
+ if (argv[i][0] != '-' || argv[i][1] == '\0')
+ usage(argv[0]);
for (j = 1; argv[i][j]; j++) {
switch (argv[i][j]) {
case 'n': nflag = 1; break;
case 'r': rflag = 1; break;
+ default: usage(argv[0]); break;
}
}
}
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.