From fbf024e07f80f547677f9d39e64dd4bdd4be99f3 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 21 Jan 2011 20:19:46 +0000 Subject: Fix command line argument handling when options are given. git-svn-id: http://svn.drobilla.net/serd/trunk@27 490d8e77-9747-427b-9fa3-0b8f29cee8a0 --- src/serdi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/serdi.c b/src/serdi.c index d793d65a..b14df3d3 100644 --- a/src/serdi.c +++ b/src/serdi.c @@ -158,6 +158,7 @@ main(int argc, char** argv) output_syntax = SERD_NTRIPLES; } else { fprintf(stderr, "unknown output format `%s'\n", argv[a]); + return 1; } } else { fprintf(stderr, "unknown option `%s'\n", argv[a]); @@ -165,7 +166,7 @@ main(int argc, char** argv) } } - const uint8_t* in_filename = (const uint8_t*)argv[a]; + const uint8_t* in_filename = (const uint8_t*)argv[a++]; if (!in_fd && serd_uri_string_has_scheme(in_filename)) { // Input is an absolute URI, ensure it's a file: URI and chop scheme @@ -181,8 +182,8 @@ main(int argc, char** argv) SerdString* base_uri_str = NULL; SerdURI base_uri; - if (argc > 2) { // Base URI given on command line - const uint8_t* const in_base_uri = (const uint8_t*)argv[2]; + if (a < argc) { // Base URI given on command line + const uint8_t* const in_base_uri = (const uint8_t*)argv[a++]; if (!serd_uri_parse((const uint8_t*)in_base_uri, &base_uri)) { fprintf(stderr, "invalid base URI `%s'\n", argv[2]); return 1; -- cgit v1.2.1