X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=isl_arg.c;h=3e2188b3cbc7d8b917143d524345e1b85733c536;hb=de51a9bc4da5dd3f1f9f57c2362da6f9752c44e0;hp=fe9aa463861341dc4f2bf6e9808824210f2e14b7;hpb=f8746213d57f57c347c38f1750f36bea45da7582;p=platform%2Fupstream%2Fisl.git diff --git a/isl_arg.c b/isl_arg.c index fe9aa46..3e2188b 100644 --- a/isl_arg.c +++ b/isl_arg.c @@ -1,7 +1,7 @@ /* * Copyright 2008-2009 Katholieke Universiteit Leuven * - * Use of this software is governed by the GNU LGPLv2.1 license + * Use of this software is governed by the MIT license * * Written by Sven Verdoolaege, K.U.Leuven, Departement * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium @@ -1117,7 +1117,7 @@ static void print_version_and_exit(struct isl_arg *decl) static int drop_argument(int argc, char **argv, int drop, int n) { - for (; drop < argc; ++drop) + for (; drop + n < argc; ++drop) argv[drop] = argv[drop + n]; return argc - n; @@ -1144,6 +1144,23 @@ static int next_arg(struct isl_arg *arg, int a) return -1; } +/* Unless ISL_ARG_SKIP_HELP is set, check if any of the arguments is + * equal to "--help" and if so call print_help_and_exit. + */ +static void check_help(struct isl_args *args, int argc, char **argv, void *opt, + unsigned flags) +{ + int i; + + if (ISL_FL_ISSET(flags, ISL_ARG_SKIP_HELP)) + return; + + for (i = 1; i < argc; ++i) { + if (strcmp(argv[i], "--help") == 0) + print_help_and_exit(args->args, argv[0], opt); + } +} + int isl_args_parse(struct isl_args *args, int argc, char **argv, void *opt, unsigned flags) { @@ -1154,10 +1171,7 @@ int isl_args_parse(struct isl_args *args, int argc, char **argv, void *opt, n = n_arg(args->args); - for (i = 1; i < argc; ++i) { - if (strcmp(argv[i], "--help") == 0) - print_help_and_exit(args->args, argv[0], opt); - } + check_help(args, argc, argv, opt, flags); for (i = 1; i < argc; ++i) { if ((strcmp(argv[i], "--version") == 0 ||