Add OP_EXPECT_NODASH opcode
This commit is contained in:
parent
4d93d217a4
commit
c1e5ea4393
3 changed files with 5 additions and 1 deletions
|
@ -176,6 +176,6 @@ route * r3_tree_match_route(const node *n, match_entry * entry);
|
|||
|
||||
int r3_pattern_to_opcode(char * pattern, int pattern_len);
|
||||
|
||||
enum { OP_EXPECT_DIGITS = 1, OP_EXPECT_WORDS, OP_EXPECT_NOSLASH };
|
||||
enum { OP_EXPECT_DIGITS = 1, OP_EXPECT_WORDS, OP_EXPECT_NOSLASH, OP_EXPECT_NODASH };
|
||||
|
||||
#endif /* !R3_NODE_H */
|
||||
|
|
|
@ -23,6 +23,9 @@ int r3_pattern_to_opcode(char * pattern, int pattern_len) {
|
|||
if ( strncmp(pattern, "[^/]+", pattern_len) == 0 ) {
|
||||
return OP_EXPECT_NOSLASH;
|
||||
}
|
||||
if ( strncmp(pattern, "[^-]+", pattern_len) == 0 ) {
|
||||
return OP_EXPECT_NODASH;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ START_TEST (test_pattern_to_opcode)
|
|||
ck_assert( r3_pattern_to_opcode("\\w+", sizeof("\\w+") - 1) == OP_EXPECT_WORDS );
|
||||
ck_assert( r3_pattern_to_opcode("\\d+", sizeof("\\d+") - 1) == OP_EXPECT_DIGITS );
|
||||
ck_assert( r3_pattern_to_opcode("[^/]+", sizeof("[^/]+") - 1) == OP_EXPECT_NOSLASH );
|
||||
ck_assert( r3_pattern_to_opcode("[^-]+", sizeof("[^-]+") - 1) == OP_EXPECT_NODASH );
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
|
Loading…
Reference in a new issue