summaryrefslogtreecommitdiff
path: root/source/csv_decoder.h
diff options
context:
space:
mode:
Diffstat (limited to 'source/csv_decoder.h')
-rw-r--r--source/csv_decoder.h17
1 files changed, 11 insertions, 6 deletions
diff --git a/source/csv_decoder.h b/source/csv_decoder.h
index b754ef5..446f1da 100644
--- a/source/csv_decoder.h
+++ b/source/csv_decoder.h
@@ -157,7 +157,7 @@ tokenize_csv(string8 buffer, mem_arena *arena, csv_table *table, csv_token_list
157 unused(token_list); 157 unused(token_list);
158 b32 finding_headers = TRUE; 158 b32 finding_headers = TRUE;
159 159
160 if(buffer.size < 0) return NULL; 160 if(buffer.size == 0) return NULL;
161 161
162 csv_token *tok = PushStruct(arena, csv_token); 162 csv_token *tok = PushStruct(arena, csv_token);
163 163
@@ -238,11 +238,10 @@ tokenize_csv(string8 buffer, mem_arena *arena, csv_table *table, csv_token_list
238} 238}
239 239
240//- NOTE(nasr): I don't know why we are still using that dumb table but we'll remove it in the future 240//- NOTE(nasr): I don't know why we are still using that dumb table but we'll remove it in the future
241internal b_tree * 241internal btree *
242parse_csv(mem_arena *arena, csv_token_list *ctl, csv_table *table) 242parse_csv(mem_arena *arena, csv_token_list *ctl, csv_table *table)
243{ 243{
244 b_tree *tree = PushStructZero(arena, b_tree); 244 btree *tree = PushStructZero(arena, btree);
245 b_tree_create(arena, tree);
246 245
247 // iterate over the token list while the token is not nil 246 // iterate over the token list while the token is not nil
248 for (csv_token *ct = ctl->start_token; !is_nil_csv_token(ct); ct = ct->next_token) 247 for (csv_token *ct = ctl->start_token; !is_nil_csv_token(ct); ct = ct->next_token)
@@ -266,7 +265,6 @@ parse_csv(mem_arena *arena, csv_token_list *ctl, csv_table *table)
266 { 265 {
267 266
268 } 267 }
269
270 } 268 }
271 } 269 }
272 270
@@ -281,7 +279,14 @@ parse_csv(mem_arena *arena, csv_token_list *ctl, csv_table *table)
281 // NOTE(nasr): payload is the cten itself so the caller can reach 279 // NOTE(nasr): payload is the cten itself so the caller can reach
282 // row/col metadata without us having to copy it 280 // row/col metadata without us having to copy it
283 // NOTE(nasr): heh why do we void cast again? 281 // NOTE(nasr): heh why do we void cast again?
284 b_tree_insert(tree, ct->lexeme, (void *)ct); 282
283 key k = {
284 .header_index = 1,
285 .row_index = 1,
286 };
287
288 // btree_insert(arena, tree, (key)ct->lexeme, (void *)ct);
289 btree_insert(arena, tree, k, (void *)ct);
285 } 290 }
286 291
287 return tree; 292 return tree;