summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 20a8bf1)
raw | patch | inline | side by side (parent: 20a8bf1)
author | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | |
Mon, 31 Mar 2008 07:04:07 +0000 (07:04 +0000) | ||
committer | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | |
Mon, 31 Mar 2008 07:04:07 +0000 (07:04 +0000) |
Fix problem with duplicate function name (function should eventually move to /lib)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1969 f882894a-f735-0410-b71e-b25c423dba1c
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1969 f882894a-f735-0410-b71e-b25c423dba1c
lib/extra_opts.c | patch | blob | history | |
lib/tests/test_opts.c | patch | blob | history |
diff --git a/lib/extra_opts.c b/lib/extra_opts.c
index e4251215abf467102972e36723fa133386932a47..d46d124f494a53d216ad680e0002d5a15a37f5cb 100644 (file)
--- a/lib/extra_opts.c
+++ b/lib/extra_opts.c
/* FIXME: copied from utils.h; we should move a bunch of libs! */
int
-is_option (char *str)
+is_option2 (char *str)
{
if (!str)
return 0;
i--;
*argc-=1;
}else if(strcmp(argv[i], "--extra-opts")==0){
- if(!is_option(argv[i+1])){
+ if((i+1<*argc)&&!is_option2(argv[i+1])){
/* It is a argument with separate value */
argptr=argv[i+1];
/* Delete the extra-opts argument/value */
diff --git a/lib/tests/test_opts.c b/lib/tests/test_opts.c
index 54210fba8e8e8498b36f95b09c5431329e642e03..61370a9c03ddbc26187685365ad9001b141e3143 100644 (file)
--- a/lib/tests/test_opts.c
+++ b/lib/tests/test_opts.c
char **argv_test=NULL, **argv_known=NULL;
int i, argc_test;
- plan_tests(11);
+ plan_tests(12);
argv_test=(char **)malloc(2*sizeof(char **));
argv_test[0] = "prog_name";
argv_known[5] = NULL;
argv_test=np_extra_opts(&argc_test, argv_test, "check_disk");
ok(array_diff(argc_test, argv_test, 5, argv_known), "Default section 1");
+
+ argv_test=(char **)malloc(3*sizeof(char **));
+ argv_test[0] = "prog_name";
+ argv_test[1] = "--extra-opts";
+ argv_test[2] = NULL;
+ argc_test=2;
+ argv_known=(char **)realloc(argv_known, 3*sizeof(char **));
+ argv_known[0] = "prog_name";
+ argv_known[1] = "--foo=bar";
+ argv_known[2] = NULL;
+ argv_test=np_extra_opts(&argc_test, argv_test, "check_disk");
+ ok(array_diff(argc_test, argv_test, 2, argv_known), "Default section 2");
my_free(&argc_test,argv_test);
argv_test=(char **)malloc(6*sizeof(char **));
argv_known[4] = "val2";
argv_known[5] = NULL;
argv_test=np_extra_opts(&argc_test, argv_test, "check_disk");
- ok(array_diff(argc_test, argv_test, 5, argv_known), "Default section 2");
+ ok(array_diff(argc_test, argv_test, 5, argv_known), "Default section 3");
my_free(&argc_test,argv_test);
argv_test=(char **)malloc(6*sizeof(char **));