From c664fcba196669b329e3e8f63c76120b5cd50df2 Mon Sep 17 00:00:00 2001 From: Ákos Kőrösi Date: Sun, 17 May 2026 01:00:28 +0200 Subject: cleanups - put some definitions in `typeutils.h` - remove superfluous code sections --- exec.c | 59 ----------------------------------------------------------- 1 file changed, 59 deletions(-) (limited to 'exec.c') diff --git a/exec.c b/exec.c index 288aac4..3a88901 100644 --- a/exec.c +++ b/exec.c @@ -10,49 +10,6 @@ #include - -void set_map_pair(KeyValMap* map, char* key, char* val) { -for (int i = 0; i < map->count; i++) { - char* key_i = get_from_KeyValMap(map, i)->key; - if (key_i == NULL) continue; - if (strcmp(key_i, key) == 0) { - // TODO: maybe copy instead - strcpy( - map->blocks[i / map->block_size][i % map->block_size].val, - val - ); - break; - } - } -} - -MaybeStr get_map_value(KeyValMap* map, char* key) { - for (int i = 0; i < map->count; i++) { - char* key_i = get_from_KeyValMap(map, i)->key; - if (key_i == NULL) continue; - if (strcmp(key_i, key) == 0) { - return (MaybeStr){ - .some = true, - .value = get_from_KeyValMap(map, i)->val - }; - } - } - return (MaybeStr){.some = false}; -} - -void unset_map_key(KeyValMap* map, char* key) { - for (int i = 0; i < map->count; i++) { - char* key_i = get_from_KeyValMap(map, i)->key; - if (key_i == NULL) continue; - if (strcmp(key_i, key) == 0) { - map->blocks[i / map->block_size][i % map->block_size].key = NULL; - break; - } - } -} - - - char* get_var(char* varname, ShellState* shstate) { MaybeStr maybe_varval = get_map_value(&shstate->shell_vars, varname); if (maybe_varval.some == true) return maybe_varval.value; @@ -78,8 +35,6 @@ ExpandedChunk expand_chunk(Chunk chunk, ShellState* shstate) { return (ExpandedChunk){.qmode = chunk.qmode, .content = content}; } -DECLARE_VEC(char*, StrVec) - typedef struct { StrVec complete_strs; @@ -119,14 +74,6 @@ StrVec expand_word(Word word, ShellState* state) { } return curr_res.complete_strs; - - /* - char** res_ptr = malloc(sizeof(char*) * curr_res.complete_strs.count); - for (int j = 0; j < curr_res.complete_strs.count; j++) { - res_ptr[j] = curr_res.complete_strs.blocks[j / curr_res.complete_strs.block_size][j % curr_res.complete_strs.block_size]; - } - return res_ptr; - */ } @@ -137,8 +84,6 @@ void merge_strvecs(StrVec* target, StrVec* source) { } - - char** make_cmd_args(Command command, ShellState* shstate) { StrVec arg_str_vec = make_StrVec(256); for (int i = 0; i < command.args.count; i++) { @@ -163,10 +108,6 @@ char** make_cmd_args(Command command, ShellState* shstate) { } - - -DECLARE_VEC(int, IntVec) - typedef struct { char** args; int stdin_fd; -- cgit v1.2.3