Commit 0475c1c5 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add ability to tell if a char is valid "XML Name" or "XML Name Start".



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4431 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 4d39775d
......@@ -31,16 +31,18 @@
/* from libvarnish/vct.c */
#define VCT_SP (1<<0)
#define VCT_CRLF (1<<1)
#define VCT_LWS (VCT_CRLF | VCT_SP)
#define VCT_CTL (1<<2)
#define VCT_ALPHA (1<<3)
#define VCT_SEPARATOR (1<<4)
#define VCT_DIGIT (1<<5)
#define VCT_HEX (1<<6)
#define VCT_SP (1<<0)
#define VCT_CRLF (1<<1)
#define VCT_LWS (VCT_CRLF | VCT_SP)
#define VCT_CTL (1<<2)
#define VCT_ALPHA (1<<3)
#define VCT_SEPARATOR (1<<4)
#define VCT_DIGIT (1<<5)
#define VCT_HEX (1<<6)
#define VCT_XMLNAMESTART (1<<7)
#define VCT_XMLNAME (1<<8)
extern const unsigned char vct_typtab[256];
extern const uint16_t vct_typtab[256];
static inline int
vct_is(unsigned char x, unsigned char y)
......@@ -56,6 +58,8 @@ vct_is(unsigned char x, unsigned char y)
#define vct_isalpha(x) vct_is(x, VCT_ALPHA)
#define vct_issep(x) vct_is(x, VCT_SEPARATOR)
#define vct_issepctl(x) vct_is(x, VCT_SEPARATOR | VCT_CTL)
#define vct_isxmlnamestart(x) vct_is(x, VCT_XMLNAMES)
#define vct_isxmlname(x) vct_is(x, VCT_XMLNAMESTART | VCT_XMLNM)
/* NB: VCT always operate in ASCII, don't replace 0x0d with \r etc. */
#define vct_skipcrlf(p) (p[0] == 0x0d && p[1] == 0x0a ? 2 : 1)
......@@ -33,6 +33,7 @@
#include "svnid.h"
SVNID("$Id$")
#include <stdint.h>
#include <vct.h>
/* NB: VCT always operate in ASCII, don't replace 0x0d with \r etc. */
......@@ -40,7 +41,7 @@ SVNID("$Id$")
#define VCT_UPALPHA VCT_ALPHA
#define VCT_LOALPHA VCT_ALPHA
unsigned const char vct_typtab[256] = {
const uint16_t vct_typtab[256] = {
[0x00] = VCT_CTL,
[0x01] = VCT_CTL,
[0x02] = VCT_CTL,
......@@ -78,80 +79,146 @@ unsigned const char vct_typtab[256] = {
[0x28] = VCT_SEPARATOR,
[0x29] = VCT_SEPARATOR,
[0x2c] = VCT_SEPARATOR,
[0x2d] = VCT_XMLNAME,
[0x2e] = VCT_XMLNAME,
[0x2f] = VCT_SEPARATOR,
[0x30] = VCT_DIGIT | VCT_HEX,
[0x31] = VCT_DIGIT | VCT_HEX,
[0x32] = VCT_DIGIT | VCT_HEX,
[0x33] = VCT_DIGIT | VCT_HEX,
[0x34] = VCT_DIGIT | VCT_HEX,
[0x35] = VCT_DIGIT | VCT_HEX,
[0x36] = VCT_DIGIT | VCT_HEX,
[0x37] = VCT_DIGIT | VCT_HEX,
[0x38] = VCT_DIGIT | VCT_HEX,
[0x39] = VCT_DIGIT | VCT_HEX,
[0x3a] = VCT_SEPARATOR,
[0x30] = VCT_DIGIT | VCT_HEX | VCT_XMLNAME,
[0x31] = VCT_DIGIT | VCT_HEX | VCT_XMLNAME,
[0x32] = VCT_DIGIT | VCT_HEX | VCT_XMLNAME,
[0x33] = VCT_DIGIT | VCT_HEX | VCT_XMLNAME,
[0x34] = VCT_DIGIT | VCT_HEX | VCT_XMLNAME,
[0x35] = VCT_DIGIT | VCT_HEX | VCT_XMLNAME,
[0x36] = VCT_DIGIT | VCT_HEX | VCT_XMLNAME,
[0x37] = VCT_DIGIT | VCT_HEX | VCT_XMLNAME,
[0x38] = VCT_DIGIT | VCT_HEX | VCT_XMLNAME,
[0x39] = VCT_DIGIT | VCT_HEX | VCT_XMLNAME,
[0x3a] = VCT_SEPARATOR | VCT_XMLNAMESTART,
[0x3b] = VCT_SEPARATOR,
[0x3c] = VCT_SEPARATOR,
[0x3d] = VCT_SEPARATOR,
[0x3e] = VCT_SEPARATOR,
[0x3f] = VCT_SEPARATOR,
[0x40] = VCT_SEPARATOR,
[0x41] = VCT_UPALPHA | VCT_HEX,
[0x42] = VCT_UPALPHA | VCT_HEX,
[0x43] = VCT_UPALPHA | VCT_HEX,
[0x44] = VCT_UPALPHA | VCT_HEX,
[0x45] = VCT_UPALPHA | VCT_HEX,
[0x46] = VCT_UPALPHA | VCT_HEX,
[0x47] = VCT_UPALPHA,
[0x48] = VCT_UPALPHA,
[0x49] = VCT_UPALPHA,
[0x4a] = VCT_UPALPHA,
[0x4b] = VCT_UPALPHA,
[0x4c] = VCT_UPALPHA,
[0x4d] = VCT_UPALPHA,
[0x4e] = VCT_UPALPHA,
[0x4f] = VCT_UPALPHA,
[0x50] = VCT_UPALPHA,
[0x51] = VCT_UPALPHA,
[0x52] = VCT_UPALPHA,
[0x53] = VCT_UPALPHA,
[0x54] = VCT_UPALPHA,
[0x55] = VCT_UPALPHA,
[0x56] = VCT_UPALPHA,
[0x57] = VCT_UPALPHA,
[0x58] = VCT_UPALPHA,
[0x59] = VCT_UPALPHA,
[0x5a] = VCT_UPALPHA,
[0x41] = VCT_UPALPHA | VCT_HEX | VCT_XMLNAMESTART,
[0x42] = VCT_UPALPHA | VCT_HEX | VCT_XMLNAMESTART,
[0x43] = VCT_UPALPHA | VCT_HEX | VCT_XMLNAMESTART,
[0x44] = VCT_UPALPHA | VCT_HEX | VCT_XMLNAMESTART,
[0x45] = VCT_UPALPHA | VCT_HEX | VCT_XMLNAMESTART,
[0x46] = VCT_UPALPHA | VCT_HEX | VCT_XMLNAMESTART,
[0x47] = VCT_UPALPHA | VCT_XMLNAMESTART,
[0x48] = VCT_UPALPHA | VCT_XMLNAMESTART,
[0x49] = VCT_UPALPHA | VCT_XMLNAMESTART,
[0x4a] = VCT_UPALPHA | VCT_XMLNAMESTART,
[0x4b] = VCT_UPALPHA | VCT_XMLNAMESTART,
[0x4c] = VCT_UPALPHA | VCT_XMLNAMESTART,
[0x4d] = VCT_UPALPHA | VCT_XMLNAMESTART,
[0x4e] = VCT_UPALPHA | VCT_XMLNAMESTART,
[0x4f] = VCT_UPALPHA | VCT_XMLNAMESTART,
[0x50] = VCT_UPALPHA | VCT_XMLNAMESTART,
[0x51] = VCT_UPALPHA | VCT_XMLNAMESTART,
[0x52] = VCT_UPALPHA | VCT_XMLNAMESTART,
[0x53] = VCT_UPALPHA | VCT_XMLNAMESTART,
[0x54] = VCT_UPALPHA | VCT_XMLNAMESTART,
[0x55] = VCT_UPALPHA | VCT_XMLNAMESTART,
[0x56] = VCT_UPALPHA | VCT_XMLNAMESTART,
[0x57] = VCT_UPALPHA | VCT_XMLNAMESTART,
[0x58] = VCT_UPALPHA | VCT_XMLNAMESTART,
[0x59] = VCT_UPALPHA | VCT_XMLNAMESTART,
[0x5a] = VCT_UPALPHA | VCT_XMLNAMESTART,
[0x5b] = VCT_SEPARATOR,
[0x5c] = VCT_SEPARATOR,
[0x5d] = VCT_SEPARATOR,
[0x61] = VCT_LOALPHA | VCT_HEX,
[0x62] = VCT_LOALPHA | VCT_HEX,
[0x63] = VCT_LOALPHA | VCT_HEX,
[0x64] = VCT_LOALPHA | VCT_HEX,
[0x65] = VCT_LOALPHA | VCT_HEX,
[0x66] = VCT_LOALPHA | VCT_HEX,
[0x67] = VCT_LOALPHA,
[0x68] = VCT_LOALPHA,
[0x69] = VCT_LOALPHA,
[0x6a] = VCT_LOALPHA,
[0x6b] = VCT_LOALPHA,
[0x6c] = VCT_LOALPHA,
[0x6d] = VCT_LOALPHA,
[0x6e] = VCT_LOALPHA,
[0x6f] = VCT_LOALPHA,
[0x70] = VCT_LOALPHA,
[0x71] = VCT_LOALPHA,
[0x72] = VCT_LOALPHA,
[0x73] = VCT_LOALPHA,
[0x74] = VCT_LOALPHA,
[0x75] = VCT_LOALPHA,
[0x76] = VCT_LOALPHA,
[0x77] = VCT_LOALPHA,
[0x78] = VCT_LOALPHA,
[0x79] = VCT_LOALPHA,
[0x7a] = VCT_LOALPHA,
[0x5f] = VCT_XMLNAMESTART,
[0x61] = VCT_LOALPHA | VCT_HEX | VCT_XMLNAMESTART,
[0x62] = VCT_LOALPHA | VCT_HEX | VCT_XMLNAMESTART,
[0x63] = VCT_LOALPHA | VCT_HEX | VCT_XMLNAMESTART,
[0x64] = VCT_LOALPHA | VCT_HEX | VCT_XMLNAMESTART,
[0x65] = VCT_LOALPHA | VCT_HEX | VCT_XMLNAMESTART,
[0x66] = VCT_LOALPHA | VCT_HEX | VCT_XMLNAMESTART,
[0x67] = VCT_LOALPHA | VCT_XMLNAMESTART,
[0x68] = VCT_LOALPHA | VCT_XMLNAMESTART,
[0x69] = VCT_LOALPHA | VCT_XMLNAMESTART,
[0x6a] = VCT_LOALPHA | VCT_XMLNAMESTART,
[0x6b] = VCT_LOALPHA | VCT_XMLNAMESTART,
[0x6c] = VCT_LOALPHA | VCT_XMLNAMESTART,
[0x6d] = VCT_LOALPHA | VCT_XMLNAMESTART,
[0x6e] = VCT_LOALPHA | VCT_XMLNAMESTART,
[0x6f] = VCT_LOALPHA | VCT_XMLNAMESTART,
[0x70] = VCT_LOALPHA | VCT_XMLNAMESTART,
[0x71] = VCT_LOALPHA | VCT_XMLNAMESTART,
[0x72] = VCT_LOALPHA | VCT_XMLNAMESTART,
[0x73] = VCT_LOALPHA | VCT_XMLNAMESTART,
[0x74] = VCT_LOALPHA | VCT_XMLNAMESTART,
[0x75] = VCT_LOALPHA | VCT_XMLNAMESTART,
[0x76] = VCT_LOALPHA | VCT_XMLNAMESTART,
[0x77] = VCT_LOALPHA | VCT_XMLNAMESTART,
[0x78] = VCT_LOALPHA | VCT_XMLNAMESTART,
[0x79] = VCT_LOALPHA | VCT_XMLNAMESTART,
[0x7a] = VCT_LOALPHA | VCT_XMLNAMESTART,
[0x7b] = VCT_SEPARATOR,
[0x7d] = VCT_SEPARATOR,
[0x7f] = VCT_CTL,
[0xb7] = VCT_XMLNAME,
[0xc0] = VCT_XMLNAMESTART,
[0xc1] = VCT_XMLNAMESTART,
[0xc2] = VCT_XMLNAMESTART,
[0xc3] = VCT_XMLNAMESTART,
[0xc4] = VCT_XMLNAMESTART,
[0xc5] = VCT_XMLNAMESTART,
[0xc6] = VCT_XMLNAMESTART,
[0xc7] = VCT_XMLNAMESTART,
[0xc8] = VCT_XMLNAMESTART,
[0xc9] = VCT_XMLNAMESTART,
[0xca] = VCT_XMLNAMESTART,
[0xcb] = VCT_XMLNAMESTART,
[0xcc] = VCT_XMLNAMESTART,
[0xcd] = VCT_XMLNAMESTART,
[0xce] = VCT_XMLNAMESTART,
[0xcf] = VCT_XMLNAMESTART,
[0xd0] = VCT_XMLNAMESTART,
[0xd1] = VCT_XMLNAMESTART,
[0xd2] = VCT_XMLNAMESTART,
[0xd3] = VCT_XMLNAMESTART,
[0xd4] = VCT_XMLNAMESTART,
[0xd5] = VCT_XMLNAMESTART,
[0xd6] = VCT_XMLNAMESTART,
[0xd8] = VCT_XMLNAMESTART,
[0xd9] = VCT_XMLNAMESTART,
[0xda] = VCT_XMLNAMESTART,
[0xdb] = VCT_XMLNAMESTART,
[0xdc] = VCT_XMLNAMESTART,
[0xdd] = VCT_XMLNAMESTART,
[0xde] = VCT_XMLNAMESTART,
[0xdf] = VCT_XMLNAMESTART,
[0xe0] = VCT_XMLNAMESTART,
[0xe1] = VCT_XMLNAMESTART,
[0xe2] = VCT_XMLNAMESTART,
[0xe3] = VCT_XMLNAMESTART,
[0xe4] = VCT_XMLNAMESTART,
[0xe5] = VCT_XMLNAMESTART,
[0xe6] = VCT_XMLNAMESTART,
[0xe7] = VCT_XMLNAMESTART,
[0xe8] = VCT_XMLNAMESTART,
[0xe9] = VCT_XMLNAMESTART,
[0xea] = VCT_XMLNAMESTART,
[0xeb] = VCT_XMLNAMESTART,
[0xec] = VCT_XMLNAMESTART,
[0xed] = VCT_XMLNAMESTART,
[0xee] = VCT_XMLNAMESTART,
[0xef] = VCT_XMLNAMESTART,
[0xf0] = VCT_XMLNAMESTART,
[0xf1] = VCT_XMLNAMESTART,
[0xf2] = VCT_XMLNAMESTART,
[0xf3] = VCT_XMLNAMESTART,
[0xf4] = VCT_XMLNAMESTART,
[0xf5] = VCT_XMLNAMESTART,
[0xf6] = VCT_XMLNAMESTART,
[0xf8] = VCT_XMLNAMESTART,
[0xf9] = VCT_XMLNAMESTART,
[0xfa] = VCT_XMLNAMESTART,
[0xfb] = VCT_XMLNAMESTART,
[0xfc] = VCT_XMLNAMESTART,
[0xfd] = VCT_XMLNAMESTART,
[0xfe] = VCT_XMLNAMESTART,
[0xff] = VCT_XMLNAMESTART,
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment