Re: [Nagios-devel] Leading space in continuation lines

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

Re: [Nagios-devel] Leading space in continuation lines

Post by Guest »


--0F1p//8PRICkK4MW
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

* Gerhard Lausser [2009-05-02 13:49]:
> I attached a patch for base/utils.c(mmap_fgets_multiline) (v3.10) which cuts
> off leading white space from continuation lines.

Of course, this breaks configurations which do stuff like

command_line $USER1$/check_foo one\
two

and expect to get this parsed with white space between "one" and "two".
However, this incompatibility is probably negligible, and I guess most
users would prefer if leading white space was stripped from continuation
lines.

So, I'd appreciate if the patch was committed. I've attached a version
of the diff which updates cgi/cgiutils.c:mmap_fgets_multiline(), too,
and which simplifies the code a bit.

Holger

--0F1p//8PRICkK4MW
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
filename="nagios-3.1.0.stripspacefromcont.2.patch"

diff --git a/base/utils.c b/base/utils.c
index 88b46e3..8eca8a2 100644
--- a/base/utils.c
+++ b/base/utils.c
@@ -3498,6 +3498,7 @@ char *mmap_fgets(mmapfile *temp_mmapfile){
char *mmap_fgets_multiline(mmapfile *temp_mmapfile){
char *buf=NULL;
char *tempbuf=NULL;
+ char *stripped=NULL;
int len=0;
int len2=0;
int end=0;
@@ -3520,11 +3521,15 @@ char *mmap_fgets_multiline(mmapfile *temp_mmapfile){
buf[len]='\x0';
}
else{
- len=strlen(tempbuf);
+ /* strip leading white space from continuation lines */
+ stripped=tempbuf;
+ while(*stripped==' ' || *stripped=='\t')
+ stripped++;
+ len=strlen(stripped);
len2=strlen(buf);
if((buf=(char *)realloc(buf,len+len2+1))==NULL)
break;
- strcat(buf,tempbuf);
+ strcat(buf,stripped);
len+=len2;
buf[len]='\x0';
}
diff --git a/cgi/cgiutils.c b/cgi/cgiutils.c
index a373ec3..ab7652e 100644
--- a/cgi/cgiutils.c
+++ b/cgi/cgiutils.c
@@ -1243,6 +1243,7 @@ char *mmap_fgets(mmapfile *temp_mmapfile){
char *mmap_fgets_multiline(mmapfile *temp_mmapfile){
char *buf=NULL;
char *tempbuf=NULL;
+ char *stripped=NULL;
int len=0;
int len2=0;
int end=0;
@@ -1265,11 +1266,15 @@ char *mmap_fgets_multiline(mmapfile *temp_mmapfile){
buf[len]='\x0';
}
else{
- len=strlen(tempbuf);
+ /* strip leading white space from continuation lines */
+ stripped=tempbuf;
+ while(*stripped==' ' || *stripped=='\t')
+ stripped++;
+ len=strlen(stripped);
len2=strlen(buf);
if((buf=(char *)realloc(buf,len+len2+1))==NULL)
break;
- strcat(buf,tempbuf);
+ strcat(buf,stripped);
len+=len2;
buf[len]='\x0';
}

--0F1p//8PRICkK4MW--





This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked