[4.0] a7927cb Nitpicks

Lasse Karstensen lkarsten at varnish-software.com
Mon Sep 22 16:38:26 CEST 2014


commit a7927cb856a0228eae512aad547d2f83368b21ef
Author: Per Buer <perbu at varnish-software.com>
Date:   Mon Sep 22 11:00:51 2014 +0200

    Nitpicks
    
    Conflicts:
    	lib/libvmod_std/vmod_std.c

diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc
index 01d9274..b15a603 100644
--- a/lib/libvmod_std/vmod.vcc
+++ b/lib/libvmod_std/vmod.vcc
@@ -202,10 +202,14 @@ Example
 $Function STRING strstr(STRING, STRING)
 
 Description
-	Returns true if the second string is a substring of the first
+	Returns the substring if the second string is a substring of the first
 	string. Note that the comparison is case sensitive. You can
 	use the tolower function on both strings if you want case
 	insensitivity.
+	
+        If there is no match a NULL pointer is returned which would
+        evaluate to false in an if-test.
+
 Example
 	if (std.strstr(req.url, req.http.x-restrict)) 
 
diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c
index e08229f..fd2bbbc 100644
--- a/lib/libvmod_std/vmod_std.c
+++ b/lib/libvmod_std/vmod_std.c
@@ -235,9 +235,10 @@ vmod_timestamp(const struct vrt_ctx *ctx, VCL_STRING label)
 VCL_STRING __match_proto__(td_std_strstr)
 vmod_strstr(const struct vrt_ctx *ctx, VCL_STRING mstr, VCL_STRING msubstr)
 {
-
         CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
-        char *match =  strstr(mstr, msubstr);
 
-	return(match);
+        if ((mstr == NULL) || (msubstr == NULL))
+		return (NULL);
+	else
+		return(strstr(mstr, msubstr));
 }



More information about the varnish-commit mailing list