[master] 3b2c6d3 Move libvcc away from is* macros

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Tue Jun 27 12:03:06 CEST 2017


commit 3b2c6d33465484014cd324fd832713a475ccddde
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Tue Jun 27 11:40:35 2017 +0200

    Move libvcc away from is* macros
    
    Refs #2354

diff --git a/include/vct.h b/include/vct.h
index 2893e6b..e1332d8 100644
--- a/include/vct.h
+++ b/include/vct.h
@@ -43,6 +43,8 @@
 #define VCT_TCHAR		(1<<9)
 #define VCT_NAME		(1<<10)
 #define VCT_VAR			(1<<11)
+#define VCT_VT			(1<<12)
+#define VCT_SPACE		(VCT_LWS | VCT_VT)
 
 extern const uint16_t vct_typtab[256];
 
@@ -60,8 +62,10 @@ vct_is(int x, uint16_t y)
 #define vct_ishex(x) vct_is(x, VCT_HEX)
 #define vct_islws(x) vct_is(x, VCT_LWS)
 #define vct_isctl(x) vct_is(x, VCT_CTL)
+#define vct_isspace(x) vct_is(x, VCT_SPACE)
 #define vct_isdigit(x) vct_is(x, VCT_DIGIT)
 #define vct_isalpha(x) vct_is(x, VCT_ALPHA)
+#define vct_isalnum(x) vct_is(x, VCT_ALPHA | VCT_DIGIT)
 #define vct_issep(x) vct_is(x, VCT_SEPARATOR)
 #define vct_issepctl(x) vct_is(x, VCT_SEPARATOR | VCT_CTL)
 #define vct_isident1(x) vct_isalpha(x)
diff --git a/lib/libvarnish/vct.c b/lib/libvarnish/vct.c
index 7d82dd3..d8e1118 100644
--- a/lib/libvarnish/vct.c
+++ b/lib/libvarnish/vct.c
@@ -54,7 +54,7 @@ const uint16_t vct_typtab[256] = {
 	[0x08]	=	VCT_CTL,
 	[0x09]	=	VCT_CTL | VCT_SP | VCT_SEPARATOR,
 	[0x0a]	=	VCT_CTL | VCT_CRLF,
-	[0x0b]	=	VCT_CTL,
+	[0x0b]	=	VCT_CTL | VCT_VT,
 	[0x0c]	=	VCT_CTL,
 	[0x0d]	=	VCT_CTL | VCT_CRLF,
 	[0x0e]	=	VCT_CTL,
diff --git a/lib/libvcc/vcc_token.c b/lib/libvcc/vcc_token.c
index c38ea32..a262ded 100644
--- a/lib/libvcc/vcc_token.c
+++ b/lib/libvcc/vcc_token.c
@@ -29,7 +29,6 @@
 
 #include "config.h"
 
-#include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -304,7 +303,7 @@ vcc_ExpectCid(struct vcc *tl, const char *what)
 	ERRCHK(tl);
 	/* XXX: too soon to use vct_invalid_name() */
 	for (q = tl->t->b; q < tl->t->e; q++) {
-		if (!isalnum(*q) && *q != '_') {
+		if (!vct_isalnum(*q) && *q != '_') {
 			VSB_printf(tl->sb, "Name of %s, ", what);
 			vcc_ErrToken(tl, tl->t);
 			VSB_printf(tl->sb,
@@ -371,7 +370,7 @@ vcc_Lexer(struct vcc *tl, struct source *sp)
 	for (p = sp->b; p < sp->e; ) {
 
 		/* Skip any whitespace */
-		if (isspace(*p)) {
+		if (vct_isspace(*p)) {
 			p++;
 			continue;
 		}
@@ -501,9 +500,9 @@ vcc_Lexer(struct vcc *tl, struct source *sp)
 		}
 
 		/* Match numbers { [0-9]+ } */
-		if (isdigit(*p)) {
+		if (vct_isdigit(*p)) {
 			for (q = p; q < sp->e; q++)
-				if (!isdigit(*q))
+				if (!vct_isdigit(*q))
 					break;
 			vcc_AddToken(tl, CNUM, p, q);
 			p = q;



More information about the varnish-commit mailing list