summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 40c1231)
raw | patch | inline | side by side (parent: 40c1231)
author | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | |
Sat, 15 Mar 2008 20:47:43 +0000 (20:47 +0000) | ||
committer | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | |
Sat, 15 Mar 2008 20:47:43 +0000 (20:47 +0000) |
- parameters without argument after '=' are now assumed to be argument-less
- Add a testcase for space in stanza and various argument-less parameters
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1948 f882894a-f735-0410-b71e-b25c423dba1c
- Add a testcase for space in stanza and various argument-less parameters
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1948 f882894a-f735-0410-b71e-b25c423dba1c
lib/parse_ini.c | patch | blob | history | |
lib/tests/plugin.ini | patch | blob | history | |
lib/tests/test_ini.c | patch | blob | history |
diff --git a/lib/parse_ini.c b/lib/parse_ini.c
index 38bcb39bfefe83fac7a64484c69f2866371b20a7..ade77e5f84a9c40fe5b25023b984d9aa9f8d1954 100644 (file)
--- a/lib/parse_ini.c
+++ b/lib/parse_ini.c
else optend=NULL;
}
if(optend==NULL) optend=eqptr;
+//printf("o1: %c\n", *optptr[optend]);
--optend;
/* ^[[:space:]]*=foo is a syntax error */
if(optptr==eqptr) die(STATE_UNKNOWN, _("Config file error\n"));
equals=1;
cfg_len+=1;
}
+ /* A line with no equal sign isn't valid */
+ if(equals==0) die(STATE_UNKNOWN, _("Config file error\n"));
/* okay, now we have all the info we need, so we create a new np_arg_list
* element and set the argument...
read_pos+=2;
}
strncpy(&optnew->arg[read_pos], optptr, opt_len); read_pos+=opt_len;
- if(equals) optnew->arg[read_pos++]='=';
if(value) {
+ optnew->arg[read_pos++]='=';
strncpy(&optnew->arg[read_pos], valptr, val_len); read_pos+=val_len;
}
optnew->arg[read_pos]='\0';
diff --git a/lib/tests/plugin.ini b/lib/tests/plugin.ini
index eb869c63886ccb4a489d17b3c07616a5e84d45c2..d07fc4f363762c4fa1641c64c8506bb1e6164b48 100644 (file)
--- a/lib/tests/plugin.ini
+++ b/lib/tests/plugin.ini
u=admin
p=secret
+[check space_and_flags]
+foo=bar
+a=
+b=
+bar=
diff --git a/lib/tests/test_ini.c b/lib/tests/test_ini.c
index de9f8adf4e776accfe7805a16b22cc765726f610..9031f7f8abce45863a27f8bbb8750e55a8afe9a9 100644 (file)
--- a/lib/tests/test_ini.c
+++ b/lib/tests/test_ini.c
{
char *optstr=NULL;
- plan_tests(9);
+ plan_tests(10);
optstr=list2str(np_get_defaults("section@./config-tiny.ini", "check_disk"));
- ok( !strcmp(optstr, "--one=two --Foo=Bar --this=Your Mother! --blank="), "config-tiny.ini's section as expected");
+ ok( !strcmp(optstr, "--one=two --Foo=Bar --this=Your Mother! --blank"), "config-tiny.ini's section as expected");
my_free(optstr);
optstr=list2str(np_get_defaults("@./config-tiny.ini", "section"));
- ok( !strcmp(optstr, "--one=two --Foo=Bar --this=Your Mother! --blank="), "Used default section name, without specific");
+ ok( !strcmp(optstr, "--one=two --Foo=Bar --this=Your Mother! --blank"), "Used default section name, without specific");
my_free(optstr);
optstr=list2str(np_get_defaults("section_unknown@./config-tiny.ini", "section"));
- ok( !strcmp(optstr, "--one=two --Foo=Bar --this=Your Mother! --blank="), "Used default section name over specified one");
+ ok( !strcmp(optstr, "--one=two --Foo=Bar --this=Your Mother! --blank"), "Used default section name over specified one");
my_free(optstr);
optstr=list2str(np_get_defaults("Section Two@./config-tiny.ini", "check_disk"));
ok( !strcmp(optstr, "-u=admin -p=secret"), "plugin.ini's check_mysql2 as expected");
my_free(optstr);
+ optstr=list2str(np_get_defaults("check space_and_flags@./plugin.ini", "check_disk"));
+ ok( !strcmp(optstr, "--foo=bar -a -b --bar"), "plugin.ini space in stanza and flag arguments");
+ my_free(optstr);
+
return exit_status();
}