[4.0] 0913f09 Add y (years) time unit support to VCL

Federico G. Schwindt fgsch at lodoss.net
Tue Jun 24 11:31:56 CEST 2014


commit 0913f097cdd55ae2b49e090c04f355d0dd9b1664
Author: Federico G. Schwindt <fgsch at lodoss.net>
Date:   Tue Jun 17 13:37:27 2014 +0100

    Add y (years) time unit support to VCL
    
    Follows the change in the std vmod a while ago.

diff --git a/bin/varnishtest/tests/v00016.vtc b/bin/varnishtest/tests/v00016.vtc
index 1107f86..dfe69ae 100644
--- a/bin/varnishtest/tests/v00016.vtc
+++ b/bin/varnishtest/tests/v00016.vtc
@@ -73,7 +73,7 @@ varnish v1 -vcl {
 
 }
 
-varnish v1 -errvcl {Unknown time unit 'k'.  Legal are 'ms', 's', 'm', 'h', 'd' and 'w'} {
+varnish v1 -errvcl {Unknown time unit 'k'.  Legal are 'ms', 's', 'm', 'h', 'd', 'w' and 'y'} {
 	backend b { .host = "127.0.0.1"; }
 	sub vcl_backend_response { set beresp.ttl = 1. k; }
 }
diff --git a/doc/sphinx/reference/vcl.rst b/doc/sphinx/reference/vcl.rst
index 9ae2aa7..3f8a831 100644
--- a/doc/sphinx/reference/vcl.rst
+++ b/doc/sphinx/reference/vcl.rst
@@ -115,6 +115,8 @@ so 1.5w is allowed.
   w
     weeks
 
+  y
+    years
 
 Integers
 --------
diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c
index c143cf1..8e4e234 100644
--- a/lib/libvcc/vcc_expr.c
+++ b/lib/libvcc/vcc_expr.c
@@ -74,10 +74,12 @@ vcc_TimeUnit(struct vcc *tl)
 		sc = 60.0 * 60.0 * 24.0;
 	else if (vcc_IdIs(tl->t, "w"))
 		sc = 60.0 * 60.0 * 24.0 * 7.0;
+	else if (vcc_IdIs(tl->t, "y"))
+		sc = 60.0 * 60.0 * 24.0 * 365.0;
 	else {
 		VSB_printf(tl->sb, "Unknown time unit ");
 		vcc_ErrToken(tl, tl->t);
-		VSB_printf(tl->sb, ".  Legal are 'ms', 's', 'm', 'h', 'd' and 'w'\n");
+		VSB_printf(tl->sb, ".  Legal are 'ms', 's', 'm', 'h', 'd', 'w' and 'y'\n");
 		vcc_ErrWhere(tl, tl->t);
 		return (1.0);
 	}



More information about the varnish-commit mailing list