Switch indices in strings to size_t.

This commit is contained in:
Danila Fedorin 2017-07-20 21:46:39 -07:00
parent 8e29bdf52a
commit 1399934a24
2 changed files with 9 additions and 8 deletions

View File

@ -1,6 +1,7 @@
#ifndef LIBLEX_EVAL_H #ifndef LIBLEX_EVAL_H
#define LIBLEX_EVAL_H #define LIBLEX_EVAL_H
#include <stddef.h>
#include "pattern.h" #include "pattern.h"
#include "pairmap.h" #include "pairmap.h"
#include "ll.h" #include "ll.h"
@ -11,8 +12,8 @@
* are used to represent "matched" hypohteses. * are used to represent "matched" hypohteses.
*/ */
struct match_s { struct match_s {
int from; size_t from;
int to; size_t to;
int pattern; int pattern;
}; };
@ -28,11 +29,11 @@ struct eval_s {
/** /**
* The current index in the input. * The current index in the input.
*/ */
int index; size_t index;
/** /**
* The index where the valuation began. * The index where the valuation began.
*/ */
int begin; size_t begin;
/** /**
* The number of nodes / states matched in * The number of nodes / states matched in
* the last iteration. * 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. * @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. * @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, * Evaluates input starting at the index until it reaches the null terminator,
* adding the best matches to the linked list. * 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 * @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. * @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. * 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, * Since eval_all creates a lot of matches and puts them all in a linked list,

View File

@ -154,7 +154,7 @@ int _eval_foreach_find_match(void *data, va_list args){
return 0; 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; liblex_result result = LIBLEX_SUCCESS;
eval evl; eval evl;
evl.index = evl.begin = index; evl.index = evl.begin = index;
@ -189,7 +189,7 @@ liblex_result eval_word(char* string, int index, eval_config* config, match* mtc
return result; 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; liblex_result result = LIBLEX_SUCCESS;
match* new_match = NULL; match* new_match = NULL;
int done = 0; int done = 0;