Switch pattern compilation code to const char*

This commit is contained in:
Danila Fedorin 2017-07-20 22:01:24 -07:00
parent 8d1178788a
commit 6d520028b4
2 changed files with 6 additions and 6 deletions

View File

@ -170,7 +170,7 @@ typedef struct pattern_s pattern;
* @param id the id of the pattern.
* @return LIBLEX_SUCCESS if all goes well, otherwise some other liblex_result.
*/
liblex_result pattern_compile(pattern* ptrn, char* expression, int id);
liblex_result pattern_compile(pattern* ptrn, const char* expression, int id);
/**
* Frees a pattern NFA allocated by pattern_compile.
* @param root the root node to start freeing from.

View File

@ -172,7 +172,7 @@ liblex_result _pattern_free(pattern_node* root, int size){
sprs set;
liblex_result result;
sprs_init(&set);
result = (sprs_setup(&set, size) == LIBDS_SUCCESS) ? LIBLEX_SUCCESS : LIBLEX_MALLOC;
result = (sprs_setup(&set, (size_t) size) == LIBDS_SUCCESS) ? LIBLEX_SUCCESS : LIBLEX_MALLOC;
if(result == LIBLEX_SUCCESS){
_pattern_node_find_all(root, &set);
sprs_foreach(&set, NULL, compare_always, _pattern_node_foreach_free);
@ -181,7 +181,7 @@ liblex_result _pattern_free(pattern_node* root, int size){
return result;
}
liblex_result _pattern_read_value(char* read_into, char* string, int* index){
liblex_result _pattern_read_value(char* read_into, const char* string, int* index){
liblex_result result = LIBLEX_SUCCESS;
if(string[*index] == '\\'){
(*index)++;
@ -195,7 +195,7 @@ liblex_result _pattern_read_value(char* read_into, char* string, int* index){
return result;
}
liblex_result _pattern_build_or(pattern_chain** into, int* ids, int pattern_id, char* string, int* index) {
liblex_result _pattern_build_or(pattern_chain** into, int* ids, int pattern_id, const char* string, int* index) {
pattern_node *tail_node;
liblex_result result = LIBLEX_SUCCESS;
result = _pattern_node_create_connect(&tail_node, (*ids)++, pattern_id, NULL);
@ -265,7 +265,7 @@ void _pattern_chain_append_chain_discard(pattern_chain* append_to, pattern_chain
*to_append = NULL;
}
liblex_result _pattern_build_chain(pattern_chain** into, int* ids, int pattern_id, char* string, int* index){
liblex_result _pattern_build_chain(pattern_chain** into, int* ids, int pattern_id, const char* string, int* index){
liblex_result result = LIBLEX_SUCCESS;
ll or_stack;
pattern_chain* current_chain = NULL;
@ -421,7 +421,7 @@ liblex_result _pattern_build_chain(pattern_chain** into, int* ids, int pattern_i
return result;
}
liblex_result pattern_compile(pattern* ptrn, char* expression, int id){
liblex_result pattern_compile(pattern* ptrn, const char* expression, int id){
liblex_result result;
pattern_node* end_node = NULL;
pattern_chain* full_chain = NULL;