Add underscores to local functions.

This commit is contained in:
Danila Fedorin 2017-02-05 15:49:06 -08:00
parent a0f51d441e
commit 8ff435b7b5

View File

@ -34,12 +34,12 @@ liblex_result eval_config_add(eval_config* config, char* ptrn, int pattern_id){
return result; return result;
} }
int eval_foreach_match_free(void* data, va_list args) { int _eval_foreach_match_free(void *data, va_list args) {
free(data); free(data);
return 0; return 0;
} }
int eval_config_foreach_free(void* data, va_list args){ int _eval_config_foreach_free(void *data, va_list args){
pattern* ptrn = data; pattern* ptrn = data;
int result = pattern_free(ptrn) == LIBLEX_SUCCESS ? 0 : EVAL_FOREACH_MALLOC; int result = pattern_free(ptrn) == LIBLEX_SUCCESS ? 0 : EVAL_FOREACH_MALLOC;
free(ptrn); free(ptrn);
@ -47,12 +47,12 @@ int eval_config_foreach_free(void* data, va_list args){
} }
liblex_result eval_config_free(eval_config* config){ liblex_result eval_config_free(eval_config* config){
liblex_result result = foreach_errors[ll_foreach(&config->states, NULL, compare_always, eval_config_foreach_free)]; liblex_result result = foreach_errors[ll_foreach(&config->states, NULL, compare_always, _eval_config_foreach_free)];
ll_free(&config->states); ll_free(&config->states);
return result; return result;
} }
pattern_node* eval_pattern_node_get_next(pattern_node* node){ pattern_node* _eval_pattern_node_get_next(pattern_node *node){
pattern_node* to_return = NULL; pattern_node* to_return = NULL;
if(node->type == PNODE_VALUE){ if(node->type == PNODE_VALUE){
to_return = node->data_u.value_s.next; to_return = node->data_u.value_s.next;
@ -66,7 +66,7 @@ pattern_node* eval_pattern_node_get_next(pattern_node* node){
return to_return; return to_return;
} }
liblex_result eval_pairmap_add_node(ht* table, pattern_node* node){ liblex_result _eval_pairmap_add_node(ht *table, pattern_node *node){
liblex_result result = LIBLEX_SUCCESS; liblex_result result = LIBLEX_SUCCESS;
if(node->type == PNODE_ANY || node->type == PNODE_VALUE || node->type == PNODE_RANGE || if(node->type == PNODE_ANY || node->type == PNODE_VALUE || node->type == PNODE_RANGE ||
@ -74,24 +74,24 @@ liblex_result eval_pairmap_add_node(ht* table, pattern_node* node){
pairmap_key tmp_key; pairmap_key tmp_key;
result = PAIRMAP_PUT(table, &tmp_key, node->pattern_id, node->id, node) == LIBDS_SUCCESS ? LIBLEX_SUCCESS : LIBLEX_MALLOC; result = PAIRMAP_PUT(table, &tmp_key, node->pattern_id, node->id, node) == LIBDS_SUCCESS ? LIBLEX_SUCCESS : LIBLEX_MALLOC;
} else if(node->type == PNODE_CONNECT){ } else if(node->type == PNODE_CONNECT){
result = eval_pairmap_add_node(table, eval_pattern_node_get_next(node)); result = _eval_pairmap_add_node(table, _eval_pattern_node_get_next(node));
} else if(node->type == PNODE_FORK){ } else if(node->type == PNODE_FORK){
result = eval_pairmap_add_node(table, node->data_u.fork_s.left); result = _eval_pairmap_add_node(table, node->data_u.fork_s.left);
if(result == LIBDS_SUCCESS){ if(result == LIBDS_SUCCESS){
result = eval_pairmap_add_node(table, node->data_u.fork_s.right); result = _eval_pairmap_add_node(table, node->data_u.fork_s.right);
} }
} }
return result; return result;
} }
int eval_foreach_add_node(void* data, va_list args){ int _eval_foreach_add_node(void *data, va_list args){
pattern* new_pattern = data; pattern* new_pattern = data;
ht* pairmap = va_arg(args, ht*); ht* pairmap = va_arg(args, ht*);
pattern_node* pattern_head = new_pattern->head; pattern_node* pattern_head = new_pattern->head;
return eval_pairmap_add_node(pairmap, pattern_head) == LIBLEX_SUCCESS? 0 : EVAL_FOREACH_MALLOC; return _eval_pairmap_add_node(pairmap, pattern_head) == LIBLEX_SUCCESS? 0 : EVAL_FOREACH_MALLOC;
} }
int eval_node_matches(pattern_node* node, eval* eval){ int _eval_node_matches(pattern_node *node, eval *eval){
int matches = 0; int matches = 0;
char value = eval->string[eval->index]; char value = eval->string[eval->index];
if(node->type == PNODE_ANY){ if(node->type == PNODE_ANY){
@ -104,12 +104,12 @@ int eval_node_matches(pattern_node* node, eval* eval){
return matches; return matches;
} }
int eval_foreach_check_state(void* data, va_list args){ int _eval_foreach_check_node(void *data, va_list args){
int return_code = 0; int return_code = 0;
pattern_node* node = data; pattern_node* node = data;
eval* evl = va_arg(args, eval*); eval* evl = va_arg(args, eval*);
if(eval_node_matches(node, evl)){ if(_eval_node_matches(node, evl)){
return_code = eval_pairmap_add_node(evl->set_next, eval_pattern_node_get_next(node)) == LIBLEX_SUCCESS ? 0 : EVAL_FOREACH_MALLOC; return_code = _eval_pairmap_add_node(evl->set_next, _eval_pattern_node_get_next(node)) == LIBLEX_SUCCESS ? 0 : EVAL_FOREACH_MALLOC;
if(return_code == 0){ if(return_code == 0){
evl->matched++; evl->matched++;
} }
@ -131,10 +131,11 @@ int eval_foreach_check_state(void* data, va_list args){
return return_code; return return_code;
} }
liblex_result eval_step(eval* eval){ liblex_result _eval_step(eval *eval){
ht* tmp; ht* tmp;
eval->matched = 0; eval->matched = 0;
liblex_result result = foreach_errors[ht_foreach(eval->set_current, NULL, compare_always, eval_foreach_check_state, eval)]; liblex_result result = foreach_errors[ht_foreach(eval->set_current, NULL, compare_always, _eval_foreach_check_node,
eval)];
tmp = eval->set_current; tmp = eval->set_current;
eval->set_current = eval->set_next; eval->set_current = eval->set_next;
@ -146,7 +147,7 @@ liblex_result eval_step(eval* eval){
return result; return result;
} }
int eval_foreach_find_match(void* data, va_list args){ int _eval_foreach_find_match(void *data, va_list args){
match* current_match = data; match* current_match = data;
int* max_match_id = va_arg(args, int*); int* max_match_id = va_arg(args, int*);
match* fill_match = va_arg(args, match*); match* fill_match = va_arg(args, match*);
@ -169,21 +170,21 @@ liblex_result eval_word(char* string, int index, eval_config* config, match* mtc
evl.set_current = &evl.set_a; evl.set_current = &evl.set_a;
evl.set_next = &evl.set_b; evl.set_next = &evl.set_b;
ll_foreach(&config->states, NULL, compare_always, eval_foreach_add_node, evl.set_current); ll_foreach(&config->states, NULL, compare_always, _eval_foreach_add_node, evl.set_current);
do { do {
eval_step(&evl); _eval_step(&evl);
} while(evl.matched); } while(evl.matched);
if(evl.matches.tail){ if(evl.matches.tail){
int largest_id = -1; int largest_id = -1;
ll_foreach(&evl.matches, NULL, compare_always, eval_foreach_find_match, &largest_id, mtch); ll_foreach(&evl.matches, NULL, compare_always, _eval_foreach_find_match, &largest_id, mtch);
} else { } else {
mtch->from = -1; mtch->from = -1;
mtch->to = -1; mtch->to = -1;
mtch->pattern = -1; mtch->pattern = -1;
} }
ll_foreach(&evl.matches, NULL, compare_always, eval_foreach_match_free); ll_foreach(&evl.matches, NULL, compare_always, _eval_foreach_match_free);
ll_free(&evl.matches); ll_free(&evl.matches);
ht_free(&evl.set_a); ht_free(&evl.set_a);
ht_free(&evl.set_b); ht_free(&evl.set_b);