summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ffab7ee)
raw | patch | inline | side by side (parent: ffab7ee)
author | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | |
Sat, 15 Mar 2008 20:34:15 +0000 (20:34 +0000) | ||
committer | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | |
Sat, 15 Mar 2008 20:34:15 +0000 (20:34 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1947 f882894a-f735-0410-b71e-b25c423dba1c
lib/parse_ini.c | patch | blob | history |
diff --git a/lib/parse_ini.c b/lib/parse_ini.c
index b555316e0ab18b82838d403a360280f365a3478b..38bcb39bfefe83fac7a64484c69f2866371b20a7 100644 (file)
--- a/lib/parse_ini.c
+++ b/lib/parse_ini.c
stanzastate=WRONGSTANZA;
for(i=0; i<stanza_len; i++){
c=fgetc(f);
+ /* Strip leading whitespace */
+ if(i==0) for(c; isspace(c); c=fgetc(f));
/* nope, read to the end of the line */
if(c!=stanza[i]) {
GOBBLE_TO(f, c, '\n');
/* if it matched up to here and the next char is ']'... */
if(i==stanza_len){
c=fgetc(f);
+ /* Strip trailing whitespace */
+ for(c; isspace(c); c=fgetc(f));
if(c==']') stanzastate=RIGHTSTANZA;
}
break;
/* calculate the length of "--foo" */
opt_len=1+optend-optptr;
/* 1-character params needs only one dash */
- if (opt_len==1)
+ if(opt_len==1)
cfg_len=1+(opt_len);
else
cfg_len=2+(opt_len);
cfg_len+=1+val_len;
}
/* if valptr==valend then we have "=" but no "bar" */
- else if (valptr==lineend) {
+ else if(valptr==lineend) {
equals=1;
cfg_len+=1;
}
read_pos=0;
optnew->arg=(char *)malloc(cfg_len+1);
/* 1-character params needs only one dash */
- if (opt_len==1) {
+ if(opt_len==1) {
strncpy(&optnew->arg[read_pos], "-", 1);
read_pos+=1;
} else {
optnew->arg[read_pos]='\0';
/* ...and put that to the end of the list */
- if (*optlst==NULL) {
+ if(*optlst==NULL) {
*optlst=optnew;
} else {
- while (opttmp->next!=NULL) {
+ while(opttmp->next!=NULL) {
opttmp=opttmp->next;
}
opttmp->next = optnew;