summaryrefslogtreecommitdiff
path: root/reformatter
diff options
context:
space:
mode:
authorJohn Stamp <jstamp@users.sourceforge.net>2009-07-16 20:13:00 -0700
committerLloyd Hilaiel <lloyd@hilaiel.com>2009-09-09 08:53:23 -0600
commitd3f3c4a00f4b27ab275f354d894b367ab08c1fd3 (patch)
treeda5621501542ba2d8429231cbfe5ae6b22dd8ecc /reformatter
parent120bb4f9676be3bf9949d651f425e360531e40cf (diff)
downloadyajl-d3f3c4a00f4b27ab275f354d894b367ab08c1fd3.tar.gz
Fix handling multiple options in json_reformat and json_verify
Diffstat (limited to 'reformatter')
-rw-r--r--reformatter/json_reformat.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/reformatter/json_reformat.c b/reformatter/json_reformat.c
index a85f2ea..18828de 100644
--- a/reformatter/json_reformat.c
+++ b/reformatter/json_reformat.c
@@ -141,16 +141,20 @@ main(int argc, char ** argv)
/* allow comments */
yajl_parser_config cfg = { 1, 1 };
int done = 0;
-
- /* check arguments. We expect exactly one! */
- if (argc == 2) {
- if (!strcmp("-m", argv[1])) {
- conf.beautify = 0;
- } else if (!strcmp("-u", argv[1])) {
- cfg.checkUTF8 = 0;
- } else {
- usage(argv[0]);
+ /* check arguments.*/
+ if (argc > 1 && argc < 4) {
+ int i;
+
+ for (i=1; i < argc;i++) {
+ if (!strcmp("-m", argv[i])) {
+ conf.beautify = 0;
+ } else if (!strcmp("-u", argv[i])) {
+ cfg.checkUTF8 = 0;
+ } else {
+ fprintf(stderr, "unrecognized option: '%s'\n\n", argv[i]);
+ usage(argv[0]);
+ }
}
} else if (argc != 1) {
usage(argv[0]);