From 3780f207f924f14734cb839fd015bd883fe52ff1 Mon Sep 17 00:00:00 2001 From: Preston Pan Date: Thu, 30 Jan 2025 21:02:42 -0800 Subject: restructure project --- src/common/tsv.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'src/common/tsv.c') diff --git a/src/common/tsv.c b/src/common/tsv.c index c06163b..290dc43 100644 --- a/src/common/tsv.c +++ b/src/common/tsv.c @@ -1,32 +1,33 @@ #include #include -#include "../include/tsv.h" +#include "../include/bsv.h" #include "../include/helpers.h" #include "../include/better_string.h" -tsv_t *init_tsv(char *source) { - tsv_t *tsv = safe_calloc(1, sizeof(tsv_t *)); - tsv->source = source; - tsv->i = 0; - tsv->c = tsv->source[tsv->i]; - return tsv; +bsv_t *init_bsv(char *source, char delim) { + bsv_t *bsv = safe_calloc(1, sizeof(bsv_t *)); + bsv->source = source; + bsv->i = 0; + bsv->c = bsv->source[bsv->i]; + bsv->delim = delim; + return bsv; } -void tsv_move(tsv_t *tsv) { - if (tsv->c != '\0') { - tsv->i++; - tsv->c = tsv->source[tsv->i]; +void bsv_move(bsv_t *bsv) { + if (bsv->c != '\0') { + bsv->i++; + bsv->c = bsv->source[bsv->i]; } } -string_t *tsv_next(tsv_t *tsv) { +string_t *bsv_next(bsv_t *bsv) { string_t *s = init_string(NULL); bool escape = false; - while (tsv->c != '\t' && !escape) { - if (tsv->c == '\0') break; - string_push(s, tsv->c); - tsv_move(tsv); + while (bsv->c != bsv->delim && !escape) { + if (bsv->c == '\0') break; + string_push(s, bsv->c); + bsv_move(bsv); } return s; } -- cgit