From 1399934a24fb418f7f753e7578ac65f3fd5f3654 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Thu, 20 Jul 2017 21:46:39 -0700 Subject: [PATCH] Switch indices in strings to size_t. --- include/eval.h | 13 +++++++------ src/eval.c | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/include/eval.h b/include/eval.h index 2a4d6b6..31d9bc9 100644 --- a/include/eval.h +++ b/include/eval.h @@ -1,6 +1,7 @@ #ifndef LIBLEX_EVAL_H #define LIBLEX_EVAL_H +#include #include "pattern.h" #include "pairmap.h" #include "ll.h" @@ -11,8 +12,8 @@ * are used to represent "matched" hypohteses. */ struct match_s { - int from; - int to; + size_t from; + size_t to; int pattern; }; @@ -28,11 +29,11 @@ struct eval_s { /** * The current index in the input. */ - int index; + size_t index; /** * The index where the valuation began. */ - int begin; + size_t begin; /** * The number of nodes / states matched in * the last iteration. @@ -104,7 +105,7 @@ liblex_result eval_config_add(eval_config* config, char* pattern, int pattern_id * @param match pointer to where to store the newly created match. * @return LIBLEX_SUCCESS if all goes well, or LIBLEX_MALLOC if there was an allocation failure. */ -liblex_result eval_word(char* string, int index, eval_config* config, match* match); +liblex_result eval_word(char* string, size_t index, eval_config* config, match* match); /** * Evaluates input starting at the index until it reaches the null terminator, * adding the best matches to the linked list. @@ -114,7 +115,7 @@ liblex_result eval_word(char* string, int index, eval_config* config, match* mat * @param matches the linked list to populate with matches * @return LIBLEX_SUCCESS if all goes well, or LIBLEX_MALLOC if there was an allocation failure. */ -liblex_result eval_all(char* string, int index, eval_config* config, ll* matches); +liblex_result eval_all(char* string, size_t index, eval_config* config, ll* matches); /** * Function intended to be passed to "foreach" calls in libds. * Since eval_all creates a lot of matches and puts them all in a linked list, diff --git a/src/eval.c b/src/eval.c index f80f1d0..abdebc0 100644 --- a/src/eval.c +++ b/src/eval.c @@ -154,7 +154,7 @@ int _eval_foreach_find_match(void *data, va_list args){ return 0; } -liblex_result eval_word(char* string, int index, eval_config* config, match* mtch){ +liblex_result eval_word(char* string, size_t index, eval_config* config, match* mtch){ liblex_result result = LIBLEX_SUCCESS; eval evl; evl.index = evl.begin = index; @@ -189,7 +189,7 @@ liblex_result eval_word(char* string, int index, eval_config* config, match* mtc return result; } -liblex_result eval_all(char* string, int index, eval_config* config, ll* matches){ +liblex_result eval_all(char* string, size_t index, eval_config* config, ll* matches){ liblex_result result = LIBLEX_SUCCESS; match* new_match = NULL; int done = 0;