solved the \< situation; \> WIP

This commit is contained in:
anon 2023-09-22 20:37:20 +02:00
parent 8d642f14ce
commit 3d56f3021b

View File

@ -68,9 +68,9 @@ bool is_magic(const char c) {
"\331\332\333\334\335" \ "\331\332\333\334\335" \
"\336\337" "\336\337"
#define JEGER_CHAR_SET_file_extra "/.-_+,#$%~=" #define JEGER_CHAR_SET_file_extra "/.-_+,#$%~="
#define JEGER_CHAR_SET_whitespace " \t\v\n" #define JEGER_CHAR_SET_whitespace " " "\t\v\n"
static const char JEGER_CHAR_very_word_chars[] = static const char JEGER_CHAR_symbol_chars[] =
JEGER_CHAR_SET_underscore JEGER_CHAR_SET_underscore
JEGER_CHAR_SET_lower JEGER_CHAR_SET_lower
JEGER_CHAR_SET_upper JEGER_CHAR_SET_upper
@ -318,9 +318,9 @@ int escape_1_to_N(const char c,
return sizeof(word_chars)-1; return sizeof(word_chars)-1;
}; };
case 'h': { case 'h': {
// #global JEGER_CHAR_very_word_chars // #global JEGER_CHAR_symbol_chars
strcpy(target_list, JEGER_CHAR_very_word_chars); strcpy(target_list, JEGER_CHAR_symbol_chars);
return sizeof(JEGER_CHAR_very_word_chars)-1; return sizeof(JEGER_CHAR_symbol_chars)-1;
}; };
case 'a': { case 'a': {
const char alpha_chars[] = JEGER_CHAR_SET_lower const char alpha_chars[] = JEGER_CHAR_SET_lower
@ -503,7 +503,7 @@ regex_t * regex_compile(const char * const pattern) {
if (compile_escape(*s, &cs)) { if (compile_escape(*s, &cs)) {
s += 1; s += 1;
} else if (is_hologram_escape(*s)) { } else if (is_hologram_escape(*s)) {
; s -= 1;
} else { } else {
assert("Unknown escape."); assert("Unknown escape.");
} }
@ -518,6 +518,12 @@ regex_t * regex_compile(const char * const pattern) {
} break; } break;
} }
/* Ew */
if (*s == '\\'
&& is_hologram_escape(*(s+1))) {
++s;
}
// Compile char // Compile char
switch (*s) { switch (*s) {
// holograms // holograms
@ -533,18 +539,28 @@ regex_t * regex_compile(const char * const pattern) {
s += 1; s += 1;
} break; } break;
case '<': { case '<': {
cs.flags |= IS_NEGATIVE | INCREMENT_STATE; unsigned true_inc = 1;
if (cs.flags & IS_AT_THE_BEGINNING) { if ((cs.flags & DO_CATCH)
ABSOLUTE_OFFSHOOT(0, JEGER_INIT_STATE+1, 0, 0, regex); || (cs.flags & IS_NEGATIVE)) {
OFFSHOOT(0, +1, 1, 1, &cs, regex);
OFFSHOOT(+1, +2, 1, 1, &cs, regex);
++true_inc;
} else {
cs.flags |= INCREMENT_STATE;
} }
strcat(blacklist, JEGER_CHAR_very_word_chars); cs.flags |= IS_NEGATIVE;
OFFSHOOT(0, 0, 1, 0, &cs, regex); if (cs.flags & IS_AT_THE_BEGINNING) {
ABSOLUTE_OFFSHOOT(0, JEGER_INIT_STATE + true_inc, 0, 0, regex);
}
strcat(blacklist, JEGER_CHAR_symbol_chars);
//OFFSHOOT(0 + (true_inc-1), +true_inc, 1, 0, &cs, regex);
s += 1; s += 1;
} break; } break;
case '>': { case '>': {
HOOK_ALL(0, whitelist, 0, &cs, regex);
cs.flags |= IS_NEGATIVE | INCREMENT_STATE; cs.flags |= IS_NEGATIVE | INCREMENT_STATE;
strcat(blacklist, JEGER_CHAR_very_word_chars); strcat(blacklist, JEGER_CHAR_symbol_chars);
OFFSHOOT(0, 1, 0, 0, &cs, regex); OFFSHOOT(+1, +2, 0, 0, &cs, regex);
s += 1; s += 1;
} break; } break;
// quantifiers // quantifiers
@ -729,8 +745,8 @@ match_t * regex_match(const regex_t * const regex,
// Find all matches // Find all matches
{ {
const char * s = string; const char * s = string;
do {
int initial_state; int initial_state;
do {
initial_state = (int)(!(is_start_of_string && (s == string))); initial_state = (int)(!(is_start_of_string && (s == string)));
*match = (match_t){ *match = (match_t){