less chaotic string literals
This commit is contained in:
parent
a7d0792a3c
commit
d9acf97269
@ -53,7 +53,7 @@ typedef struct {
|
||||
// ### Regex creation/destruction ###
|
||||
// ----------------------------------
|
||||
static int escape_1_to_1(const char c, char * whitelist) {
|
||||
switch(c) {
|
||||
switch (c) {
|
||||
case 't': {
|
||||
strcat(whitelist, "\t");
|
||||
} return 1;
|
||||
@ -95,22 +95,50 @@ static int escape_1_to_1(const char c, char * whitelist) {
|
||||
static int escape_1_to_N(const char c, char * whitelist) {
|
||||
switch(c) {
|
||||
case 'i': {
|
||||
const char identifier_chars[] = "@0123456789_\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337";
|
||||
const char identifier_chars[] = "@0123456789_"
|
||||
"\300\301\302\303\304"
|
||||
"\305\306\307\310\311"
|
||||
"\312\313\314\315\316"
|
||||
"\317\320\321\322\323"
|
||||
"\324\325\326\327\330"
|
||||
"\331\332\333\334\335"
|
||||
"\336\337";
|
||||
strcpy(whitelist, identifier_chars);
|
||||
return sizeof(identifier_chars)-1;
|
||||
};
|
||||
case 'I': {
|
||||
const char identifier_chars[] = "@_\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337";
|
||||
const char identifier_chars[] = "@_"
|
||||
"\300\301\302\303\304"
|
||||
"\305\306\307\310\311"
|
||||
"\312\313\314\315\316"
|
||||
"\317\320\321\322\323"
|
||||
"\324\325\326\327\330"
|
||||
"\331\332\333\334\335"
|
||||
"\336\337";
|
||||
strcpy(whitelist, identifier_chars);
|
||||
return sizeof(identifier_chars)-1;
|
||||
};
|
||||
case 'k': {
|
||||
const char keyword_chars[] = "@0123456789_\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337";
|
||||
const char keyword_chars[] = "@0123456789_"
|
||||
"\300\301\302\303\304"
|
||||
"\305\306\307\310\311"
|
||||
"\312\313\314\315\316"
|
||||
"\317\320\321\322\323"
|
||||
"\324\325\326\327\330"
|
||||
"\331\332\333\334\335"
|
||||
"\336\337";
|
||||
strcpy(whitelist, keyword_chars);
|
||||
return sizeof(keyword_chars)-1;
|
||||
};
|
||||
case 'K': {
|
||||
const char keyword_chars[] = "@_\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337";
|
||||
const char keyword_chars[] = "@_"
|
||||
"\300\301\302\303\304"
|
||||
"\305\306\307\310\311"
|
||||
"\312\313\314\315\316"
|
||||
"\317\320\321\322\323"
|
||||
"\324\325\326\327\330"
|
||||
"\331\332\333\334\335"
|
||||
"\336\337";
|
||||
strcpy(whitelist, keyword_chars);
|
||||
return sizeof(keyword_chars)-1;
|
||||
};
|
||||
@ -125,12 +153,40 @@ static int escape_1_to_N(const char c, char * whitelist) {
|
||||
return sizeof(filename_chars)-1;
|
||||
};
|
||||
case 'p': {
|
||||
const char printable_chars[] = "@\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337";
|
||||
const char printable_chars[] = "@"
|
||||
"\241\242\243\244\245"
|
||||
"\246\247\250\251\252"
|
||||
"\253\254\255\256\257"
|
||||
"\260\261\262\263\264"
|
||||
"\265\266\267\270\271"
|
||||
"\272\273\274\275\276"
|
||||
"\277"
|
||||
"\300\301\302\303\304"
|
||||
"\305\306\307\310\311"
|
||||
"\312\313\314\315\316"
|
||||
"\317\320\321\322\323"
|
||||
"\324\325\326\327\330"
|
||||
"\331\332\333\334\335"
|
||||
"\336\337";
|
||||
strcpy(whitelist, printable_chars);
|
||||
return sizeof(printable_chars)-1;
|
||||
};
|
||||
case 'P': {
|
||||
const char printable_chars[] = "@\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337";
|
||||
const char printable_chars[] = "@"
|
||||
"\241\242\243\244\245"
|
||||
"\246\247\250\251\252"
|
||||
"\253\254\255\256\257"
|
||||
"\260\261\262\263\264"
|
||||
"\265\266\267\270\271"
|
||||
"\272\273\274\275\276"
|
||||
"\277"
|
||||
"\300\301\302\303\304"
|
||||
"\305\306\307\310\311"
|
||||
"\312\313\314\315\316"
|
||||
"\317\320\321\322\323"
|
||||
"\324\325\326\327\330"
|
||||
"\331\332\333\334\335"
|
||||
"\336\337";
|
||||
strcpy(whitelist, printable_chars);
|
||||
return sizeof(printable_chars)-1;
|
||||
};
|
||||
@ -145,7 +201,9 @@ static int escape_1_to_N(const char c, char * whitelist) {
|
||||
return sizeof(digit_chars)-1;
|
||||
};
|
||||
case 'x': {
|
||||
const char hex_chars[] = "0123456789abcdefABCDEF";
|
||||
const char hex_chars[] = "0123456789"
|
||||
"abcdef"
|
||||
"ABCDEF";
|
||||
strcpy(whitelist, hex_chars);
|
||||
return sizeof(hex_chars)-1;
|
||||
};
|
||||
@ -155,17 +213,23 @@ static int escape_1_to_N(const char c, char * whitelist) {
|
||||
return sizeof(oct_chars)-1;
|
||||
};
|
||||
case 'w': {
|
||||
const char word_chars[] = "0123456789abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ_";
|
||||
const char word_chars[] = "0123456789"
|
||||
"abcdefghijklmnopqrstuwxyz"
|
||||
"ABCDEFGHIJKLMNOPQRSTUWXYZ"
|
||||
"_";
|
||||
strcpy(whitelist, word_chars);
|
||||
return sizeof(word_chars)-1;
|
||||
};
|
||||
case 'h': {
|
||||
const char very_word_chars[] = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ_";
|
||||
const char very_word_chars[] = "abcdefghijklmnopqrstuwxyz"
|
||||
"ABCDEFGHIJKLMNOPQRSTUWXYZ"
|
||||
"_";
|
||||
strcpy(whitelist, very_word_chars);
|
||||
return sizeof(very_word_chars)-1;
|
||||
};
|
||||
case 'a': {
|
||||
const char alpha_chars[] = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ";
|
||||
const char alpha_chars[] = "abcdefghijklmnopqrstuwxyz"
|
||||
"ABCDEFGHIJKLMNOPQRSTUWXYZ";
|
||||
strcpy(whitelist, alpha_chars);
|
||||
return sizeof(alpha_chars)-1;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user