Leading space in continuation lines
Holger Weiss
holger at CIS.FU-Berlin.DE
Sat May 9 23:15:56 CEST 2009
* Gerhard Lausser <Gerhard.Lausser at consol.de> [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
-------------- next part --------------
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';
}
-------------- next part --------------
------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image
processing features enabled. http://p.sf.net/sfu/kodak-com
-------------- next part --------------
_______________________________________________
Nagios-devel mailing list
Nagios-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-devel
More information about the Developers
mailing list