Compare commits

...

2 Commits

Author SHA1 Message Date
8f2fbcdb2b csope is awesome 2023-09-25 21:51:45 +02:00
01d82b8fca one more bug 2023-09-25 21:51:40 +02:00
3 changed files with 10 additions and 11 deletions

View File

@ -121,7 +121,7 @@ typedef struct {
int flags; int flags;
int state; int state;
int width; int width;
int width2; int match_width;
char * whitelist; char * whitelist;
char * blacklist; char * blacklist;
} compiler_state; } compiler_state;
@ -148,7 +148,7 @@ void HOOK_ALL(const int from,
.input = *s, .input = *s,
.to = ASSERT_HALT(to), .to = ASSERT_HALT(to),
.pattern_width = cs->width, .pattern_width = cs->width,
.match_width = cs->width2, .match_width = cs->match_width,
}; };
vector_push(&regex->delta_table, vector_push(&regex->delta_table,
&delta); &delta);
@ -504,7 +504,7 @@ regex_t * regex_compile(const char * const pattern) {
blacklist[0] = '\0'; blacklist[0] = '\0';
cs.flags &= (IS_AT_THE_BEGINNING | FORCE_START_OF_STRING); cs.flags &= (IS_AT_THE_BEGINNING | FORCE_START_OF_STRING);
cs.width = 1; cs.width = 1;
cs.width2 = 1; cs.match_width = 1;
// Translate char // Translate char
switch (*s) { switch (*s) {
@ -572,7 +572,7 @@ regex_t * regex_compile(const char * const pattern) {
// --- // ---
++cs.state; ++cs.state;
cs.width = 0; cs.width = 0;
cs.width2 = 0; cs.match_width = 0;
HOOK_ALL(0, whitelist, +1, &cs, regex); HOOK_ALL(0, whitelist, +1, &cs, regex);
cs.width = 1; cs.width = 1;
OFFSHOOT(0, +1, 1, 0, &cs, regex); OFFSHOOT(0, +1, 1, 0, &cs, regex);

View File

@ -117,12 +117,11 @@ signed main() {
puts(""); puts("");
TEST(R"del(/\*[\d\D]*\*/)del", "908", false); TEST(R"del(/\*[\d\D]*\*/)del", "908", false);
TEST(R"del(/\*[\d\D]*\*/)del", "/*908*/", true); TEST(R"del(/\*[\d\D]*\*/)del", "/*908*/", true);
TEST(R"del(/\*[\d\D]*\*/)del", "/*asd*/", true); TEST(R"del(/\*[\d\D]*\*/)del", "/*asd*/", true);
TEST(R"del(/\*[\d\D]*\*/)del", "/* 908 */", true); TEST(R"del(/\*[\d\D]*\*/)del", "/* asd */", true);
TEST(R"del(/\*[\d\D]*\*/)del", "/* asd */", true); TEST(R"del(/\*[\d\D]*\*/)del", "/* as* */", true);
TEST(R"del(/\*[\d\D]*\*/)del", "/* as\nd */", true);
if (test_counter == passed_tests) { if (test_counter == passed_tests) {
fputs("\033[32m", stdout); fputs("\033[32m", stdout);

View File

@ -23,7 +23,7 @@ void asprint_match_t( char * * destination,
static static
void print_leader(const bool passed, const int n) { void print_leader(const bool passed, const int n) {
if (passed) { if (passed) {
printf("\033[32;1mSuccess\033[0m. %02d\033[1m - \033[0m", n); printf("\033[32;1mSuccess\033[0m. %02d\033[1m - \033[0m", n);
} else { } else {
printf("\033[31;1mFailure\033[0m. %02d\033[1m - \033[0m", n); printf("\033[31;1mFailure\033[0m. %02d\033[1m - \033[0m", n);
} }