From 166b788d61a443a1576f8b56abdf06fea5a2178e Mon Sep 17 00:00:00 2001 From: dacctal Date: Wed, 1 Jul 2026 07:50:01 +0000 Subject: ezntek: checkpoint! --- src/files.c | 1 + src/globs.c | 89 ++++++++++++++++---------------------------------- src/help.c | 50 ++++++++++++++++------------- src/lua_globs.c | 66 ++++++++++++++++---------------------- src/lua_vars.c | 51 ++++++++++++----------------- src/main.c | 11 +++---- src/pkg_create.c | 98 ++++++++++++++++++++++---------------------------------- src/str.c | 60 +++++++++++++++++++++++----------- 8 files changed, 190 insertions(+), 236 deletions(-) (limited to 'src') diff --git a/src/files.c b/src/files.c index 8903557..7bfc507 100644 --- a/src/files.c +++ b/src/files.c @@ -19,6 +19,7 @@ */ #include "files.h" +#include bool file_exists(const char *path) { struct stat buffer; diff --git a/src/globs.c b/src/globs.c index 61d3ea6..519e5f9 100644 --- a/src/globs.c +++ b/src/globs.c @@ -19,79 +19,46 @@ */ #include -#include #include "globs.h" #include "files.h" +#include "log.h" #include "lua_vars.h" #include "str.h" -int is_verbose = 1; -int is_forced = 0; +install_dirs_t inst_dirs = {0}; +cli_flags_t flags = {0}; +config_t cfg = {0}; -int is_root_config = 0; -str home_config_dir; -str home_config_file; -str home_repos_file; -str root_config_dir; -str root_config_file; -str root_repos_file; -str config_dir; -str config_file; -str repos_file; - -str prefix_dir; +void init_vars(void) { + if (file_exists("/etc/pkgit/repos.lua")) { + cfg.dir = mstr("/etc/pkgit"); + cfg.name = mstr("/etc/pkgit/repos.lua"); -str bin; -str lib; -str include; -str src; + } else { + const char *tmp = getenv("XDG_CONFIG_HOME"); + if (tmp) { + cfg.dir = str_format("%s/pkgit", tmp); + } else { + cfg.dir = str_format("%s/.config/pkgit", getenv("HOME")); + } + cfg.name = str_concat_cstr(&cfg.dir, "/init.lua"); + } + // TODO: read into cfg.content -void init_vars(void) { - home_config_dir = str_format("%s/.config/pkgit", getenv("HOME")); - home_config_file = str_format("%s/init.lua", home_config_dir.data); - home_repos_file = str_format("%s/repos.lua", home_config_dir.data); - root_config_dir = str_from_cstr("/etc/pkgit"); - root_config_file = str_format("%s/init.lua", root_config_dir.data); - root_repos_file = str_format("%s/repos.lua", root_config_dir.data); - str_copy_into(&config_dir, &home_config_dir); - if (file_exists(root_config_file.data)) str_copy_into(&config_dir, &root_config_dir); - config_file = str_format("%s/init.lua", config_dir.data); - repos_file = str_format("%s/repos.lua", config_dir.data); + cfg.repos = str_format("%.*s/repos.lua", str_fmt(&cfg.dir)); init_install_directories(); } void free_vars(void) { - str_free(&home_config_dir); - str_free(&home_config_file); - str_free(&home_repos_file); - str_free(&root_config_dir); - str_free(&root_config_file); - str_free(&root_repos_file); - str_free(&config_dir); - str_free(&config_file); - str_free(&repos_file); + str_free(&cfg.dir); + str_free(&cfg.name); + str_free(&cfg.content); + str_free(&cfg.repos); + str_free(&inst_dirs.prefix); + str_free(&inst_dirs.bin); + str_free(&inst_dirs.lib); + str_free(&inst_dirs.include); + str_free(&inst_dirs.src); } - -// old init_vars() -// -// is_root_config = file_exists(root_config); -// if (is_root_config) snprintf(config_dir, MAX_PATH_LEN, "/etc/pkgit"); -// else snprintf(config_dir, MAX_PATH_LEN, "%s/.config/pkgit", home_dir); -// -// snprintf(config_file, MAX_PATH_LEN, "%s/init.lua", config_dir); -// snprintf(repo_file, MAX_PATH_LEN, "%s/repos.lua", config_dir); -// -// config_exists = file_exists(root_config) || file_exists(home_config()); -// -// snprintf(bin, MAX_PATH_LEN, "%s/.local/bin", home_dir); -// snprintf(lib, MAX_PATH_LEN, "%s/.local/lib", home_dir); -// snprintf(inc, MAX_PATH_LEN, "%s/.local/include", home_dir); -// snprintf(src, MAX_PATH_LEN, "%s/.local/share/pkgit", home_dir); -// -// install_directories[0] = config_dir; -// install_directories[1] = strdup(get_install_dir("bin")); -// install_directories[2] = strdup(get_install_dir("lib")); -// install_directories[3] = strdup(get_install_dir("inc")); -// install_directories[4] = strdup(get_install_dir("src")); diff --git a/src/help.c b/src/help.c index 9bd05a2..8580844 100644 --- a/src/help.c +++ b/src/help.c @@ -33,30 +33,32 @@ void help(void) { } flag_t; static const flag_t cmd_flags[] = { - {"-a", "--add", "[url]", "add a repo"}, - {"-b", "--build", "[path]", "build a package"}, - {"-d", "--declare", "", "install all packages"}, - {"-s", "--search", "[pkgs]", "find a package from your repos"}, - {"-i", "--install", "[pkgs, urls]", "install a package/repo"}, - {"-r", "--remove", "[pkgs]", "remove an installed package"}, - {"-l", "--list", "", "list all installed packages"}, - {"-u", "--update", "", "update all installed packages"}, - {"-h", "--help", "", "display this help message"}, - {"-v", "--version", "", "display version number"}, - {"-c", "--check", "", "run package checks"}, + {"-a", "--add", "[url]", "add a repo"}, + {"-b", "--build", "[path]", "build a package"}, + {"-d", "--declare", "", "install all packages"}, + {"-s", "--search", "[pkgs]", "find a package from your repos"}, + {"-i", "--install", "[pkgs, urls]", "install a package/repo"}, + {"-r", "--remove", "[pkgs]", "remove an installed package"}, + {"-l", "--list", "", "list all installed packages"}, + {"-u", "--update", "", "update all installed packages"}, + {"-h", "--help", "", "display this help message"}, + {"-v", "--version", "", "display version number"}, + {"-c", "--check", "", "run package checks"}, }; static const flag_t mod_flags[] = { - {"-q", "--quiet", "", "add a repo"}, - {"-f", "--force", "", "build a package"}, + {"-q", "--quiet", "", "add a repo"}, + {"-f", "--force", "", "build a package"}, }; - if (is_verbose) { + if (flags.verbose) { printf(BOLD_MAGENTA " , \n"); printf(BOLD_MAGENTA " / \\ \n"); printf(BOLD_MAGENTA "_.--' '--._ \n"); - printf(BOLD_MAGENTA "`'--, ,--'` " COLOR_RESET "pkgit " ITALIC GRAY "- package it!"COLOR_RESET"\n"); - printf(BOLD_YELLOW " _- " BOLD_MAGENTA "\\ /" BOLD_YELLOW " -_ " MAGENTA VERSION COLOR_RESET "\n"); + printf(BOLD_MAGENTA "`'--, ,--'` " COLOR_RESET "pkgit " ITALIC GRAY + "- package it!" COLOR_RESET "\n"); + printf(BOLD_YELLOW " _- " BOLD_MAGENTA "\\ /" BOLD_YELLOW + " -_ " MAGENTA VERSION COLOR_RESET "\n"); printf(BOLD_YELLOW "'-_ " BOLD_MAGENTA "'" BOLD_YELLOW " _-' \n"); printf(BOLD_YELLOW " `'-.-'` " COLOR_RESET "\n"); } else { @@ -66,14 +68,18 @@ void help(void) { printf("\n"); printf(RED "subcommand flags" COLOR_RESET ":\n"); - for (size_t i = 0; i < sizeof(cmd_flags)/sizeof(cmd_flags[0]); i++) { - printf(COLOR_RESET "\t" GREEN "%-2s" COLOR_RESET ", " YELLOW "%-12s" BLUE "%-16s" GRAY "# %s\n" COLOR_RESET, - cmd_flags[i].short_flag, cmd_flags[i].long_flag, cmd_flags[i].arg, cmd_flags[i].desc); + for (size_t i = 0; i < sizeof(cmd_flags) / sizeof(cmd_flags[0]); i++) { + printf(COLOR_RESET "\t" GREEN "%-2s" COLOR_RESET ", " YELLOW + "%-12s" BLUE "%-16s" GRAY "# %s\n" COLOR_RESET, + cmd_flags[i].short_flag, cmd_flags[i].long_flag, + cmd_flags[i].arg, cmd_flags[i].desc); } printf("\n" RED "modifier flags" COLOR_RESET ":\n"); - for (size_t i = 0; i < sizeof(mod_flags)/sizeof(mod_flags[0]); i++) { - printf(COLOR_RESET "\t" GREEN "%-2s" COLOR_RESET ", " YELLOW "%-12s" BLUE "%-16s" GRAY "# %s\n" COLOR_RESET, - mod_flags[i].short_flag, mod_flags[i].long_flag, mod_flags[i].arg, mod_flags[i].desc); + for (size_t i = 0; i < sizeof(mod_flags) / sizeof(mod_flags[0]); i++) { + printf(COLOR_RESET "\t" GREEN "%-2s" COLOR_RESET ", " YELLOW + "%-12s" BLUE "%-16s" GRAY "# %s\n" COLOR_RESET, + mod_flags[i].short_flag, mod_flags[i].long_flag, + mod_flags[i].arg, mod_flags[i].desc); } } diff --git a/src/lua_globs.c b/src/lua_globs.c index f030acb..5a8e51c 100644 --- a/src/lua_globs.c +++ b/src/lua_globs.c @@ -18,12 +18,11 @@ */ -#include - #include "lua_globs.h" - -#include "globs.h" #include "files.h" +#include "globs.h" +#include "log.h" +#include "str.h" lua_State *L = NULL; lua_State *B = NULL; @@ -34,7 +33,8 @@ void push_lua_path(lua_State *L, const char *new_path) { lua_getglobal(L, "package"); lua_getfield(L, -1, "path"); const char *current_path = lua_tostring(L, -1); - if (!current_path) current_path = ""; + if (!current_path) + current_path = ""; lua_pop(L, 1); lua_pushfstring(L, "%s;%s", current_path, new_path); lua_setfield(L, -2, "path"); @@ -42,47 +42,37 @@ void push_lua_path(lua_State *L, const char *new_path) { } void init_lua_state(void) { - if (L != NULL) return; + if (L != NULL) + return; L = luaL_newstate(); luaL_openlibs(L); - char lua_path[MAX_PATH_LEN + 20]; - snprintf(lua_path, sizeof(lua_path), "%s/?.lua", config_dir.data); - push_lua_path(L, lua_path); - if (luaL_loadfile(L, config_file.data) || lua_pcall(L, 0, 0, 0)) { - printf( - "%s cannot run configuration script: %s\n", - PRINT_ERROR, lua_tostring(L, -1) - ); - printf( - "%s to generate a configuration file, head into the", - PRINT_PKGIT - ); - printf( - " root directory of the pkgit source and run `make defconfig`\n" - ); + str lua_path = str_format("%.*s/?.lua", str_fmt(&cfg.dir)); + push_lua_path(L, lua_path.data); + if (luaL_loadfile(L, cfg.name.data) || lua_pcall(L, 0, 0, 0)) { + log_error("cannot run configuration script: %s", lua_tostring(L, -1)); + log_pkgit("to generate a configuration file, head into the"); + log_pkgit( + "root directory of the pkgit source and run `make defconfig`"); exit(EXIT_FAILURE); } - if (file_exists(repos_file.data)) { - if (luaL_loadfile(L, repos_file.data) || lua_pcall(L, 0, 0, 0)) { - printf( - "%s cannot load repository file: %s\n", - PRINT_ERROR, lua_tostring(L, -1) - ); + if (file_exists(cfg.repos.data)) { + if (luaL_loadfile(L, cfg.repos.data) || lua_pcall(L, 0, 0, 0)) { + log_warn("cannot load repository file: %s", lua_tostring(L, -1)); lua_pop(L, 1); } } + str_free(&lua_path); config_loaded = true; } void init_bldit(void) { - if (B != NULL) return; + if (B != NULL) + return; B = luaL_newstate(); luaL_openlibs(B); if (luaL_loadfile(B, "bldit.lua") || lua_pcall(B, 0, 0, 0)) { - if (is_verbose) printf( - "%s cannot run bldit script: %s\n", - PRINT_WARNING, lua_tostring(B, -1) - ); + if (flags.verbose) + log_warn("cannot run bldit: %s", lua_tostring(B, -1)); return; } bldit_loaded = true; @@ -96,11 +86,11 @@ void free_lua_state(void) { config_loaded = false; } -lua_State *get_lua_state(void) { return L; } +lua_State *get_lua_state(void) { + return L; +} -void lua_isnt_type(char* variable, char* type) { - if (is_verbose) printf( - "%s init.lua: '%s' is not a %s.\n", - PRINT_ERROR, variable, type - ); +void lua_isnt_type(char *variable, char *type) { + if (flags.verbose) + log_error("init.lua: '%s' is not a %s.", variable, type); } diff --git a/src/lua_vars.c b/src/lua_vars.c index 3519d7a..3fd2ddb 100644 --- a/src/lua_vars.c +++ b/src/lua_vars.c @@ -20,8 +20,8 @@ #include "lua_vars.h" -#include "lua_globs.h" #include "globs.h" +#include "lua_globs.h" void init_install_directories(void) { init_lua_state(); @@ -32,37 +32,26 @@ void init_install_directories(void) { lua_isnt_type("install_directories", "table"); return; } - //lua_pop(L, 1); - lua_getfield(L, -1, "bin"); - if (!lua_isstring(L, -1)) { - lua_isnt_type("install_directories.bin", "string"); - } else { - str_copy_cstr_into(&bin, lua_tostring(L, -1)); - } - lua_pop(L, 1); +#define SETUP_INST_DIRS \ + X(bin) \ + X(lib) \ + X(include) \ + X(src) + +#define X(dir) \ + do { \ + lua_getfield(L, -1, #dir); \ + if (!lua_isstring(L, -1)) { \ + lua_isnt_type("install_directories." #dir, "string"); \ + } else { \ + str_copy_cstr_into(&inst_dirs.dir, lua_tostring(L, -1)); \ + } \ + lua_pop(L, 1); \ + } while (0); + + SETUP_INST_DIRS +#undef X - lua_getfield(L, -1, "lib"); - if (!lua_isstring(L, -1)) { - lua_isnt_type("install_directories.lib", "string"); - } else { - str_copy_cstr_into(&lib, lua_tostring(L, -1)); - } - lua_pop(L, 1); - - lua_getfield(L, -1, "include"); - if (!lua_isstring(L, -1)) { - lua_isnt_type("install_directories.include", "string"); - } else { - str_copy_cstr_into(&include, lua_tostring(L, -1)); - } - lua_pop(L, 1); - - lua_getfield(L, -1, "src"); - if (!lua_isstring(L, -1)) { - lua_isnt_type("install_directories.src", "string"); - } else { - str_copy_cstr_into(&src, lua_tostring(L, -1)); - } lua_pop(L, 1); } diff --git a/src/main.c b/src/main.c index 893e944..b8b9735 100644 --- a/src/main.c +++ b/src/main.c @@ -18,17 +18,16 @@ */ -//#include "cla_parse.h" +// #include "cla_parse.h" +#include "globs.h" #include "pkg_create.h" #include "str.h" -#include "globs.h" -int main(int argc, char** argv) { +int main(int argc, char **argv) { (void)argc; init_vars(); - str_slc arg = str_slc_from_cstr(argv[1]); - pkg_create(&arg); - //cla_parse(argc, argv); + pkg_create(mstrslc(argv[1])); + // cla_parse(argc, argv); free_vars(); return 0; } diff --git a/src/pkg_create.c b/src/pkg_create.c index 79b4a78..9e3e765 100644 --- a/src/pkg_create.c +++ b/src/pkg_create.c @@ -1,6 +1,6 @@ /* - pkgit - package it! + pkgit - package_t it! Copyright (C) 2026 dacctal This program is free software: you can redistribute it and/or modify @@ -18,101 +18,79 @@ */ -#include #include - -#include "pkg_create.h" +#include #include "files.h" #include "globs.h" +#include "log.h" +#include "pkg_create.h" #include "str.h" static str get_destdir(str_slc cwd, str_slc arg) { - str destdir; - if (str_slc_first(arg) == '.') { - str_format_into( - &destdir, "%s/%s", - src, str_slc_from_after_delim(cwd, '/') - ); - } else { - str_format_into( - &destdir, "%s/%s", - src, arg - ); - } - return destdir; + str_slc name = str_slc_from_after_delim(arg, '/'); + if (str_slc_first(arg) == '.') + return str_format("%.*s/%.*s", str_fmt(&inst_dirs.src), str_fmt(&cwd)); + else + return str_format("%.*s/%.*s", str_fmt(&inst_dirs.src), str_fmt(&name)); } -static str get_pkgsrc(package pkg) { - str src_dir; - if (pkg.is_local == 1) { - str_format_into( - &src_dir, "%s/%s", - src, pkg.name - ); - } else { - str_format_into( - &src_dir, "%s/%s/%s", - src, pkg.name, pkg.version - ); - } - return src_dir; +static str get_pkgsrc(package_t pkg) { + if (pkg.is_local == 1) + return str_format("%.*s/%.*s", str_fmt(&inst_dirs.src), pkg.name); + else + return str_format("%.*s/%.*s/%.*s", str_fmt(&inst_dirs.src), + str_fmt(&pkg.name), str_fmt(&pkg.version)); } -package pkg_create(str_slc *arg) { - package pkg; - pkg.version = (str) { - .data = "HEAD", - .len = 4, - .cap = 4, +package_t pkg_create(str_slc arg) { + package_t pkg = { + .version = mstr("HEAD"), + .is_local = false, }; - pkg.is_local = false; + char cwd[MAX_PATH_LEN]; getcwd(cwd, MAX_PATH_LEN); + str_slc cwd_slc = mstrslc(cwd); str cwd_str = mstr(cwd); - str_slc new_arg; - new_arg.data = arg->data; - new_arg.len = arg->len; - if (!new_arg.data) exit(EXIT_FAILURE); - str dest_dir = get_destdir(cwd_slc, new_arg); + str dest_dir = get_destdir(cwd_slc, arg); + str new_arg_str = str_from_str_slc(arg); + bool is_installed_locally = is_directory(dest_dir.data); - str new_arg_str = str_from_str_slc(new_arg); pkg.version = str_from_after_delim(&new_arg_str, '@'); - str_println(&pkg.version); pkg.target = str_from_after_delim(&new_arg_str, ','); - str_println(&pkg.target); bool is_in_repos = false; - //for (size_t i = 0; i < cached_repos_count; i++) { + // for (size_t i = 0; i < cached_repos_count; i++) { // if (strcmp(new_arg, cached_repos[i].source_key) == 0) { // is_in_repos = true; // break; // } - //} + // } - if (strncmp(new_arg.data, "http", 4) == 0 || strncmp(new_arg.data, "ssh", 3) == 0) { + if (strncmp(arg.data, "http", 4) == 0 || strncmp(arg.data, "ssh", 3) == 0) { pkg.url = new_arg_str; pkg.name = str_from_after_delim(&new_arg_str, '/'); - } else if (strcmp(new_arg.data, ".") == 0) { - pkg.url = str_from_cstr(""); + } else if (str_slc_equal_cstr(arg, ".")) { + pkg.url = mstr(""); pkg.name = str_from_after_delim(&cwd_str, '/'); pkg.is_local = true; } else if (is_in_repos) { - //for (size_t i = 0; i < cached_repos_count; i++) { - // if (strcmp(new_arg, cached_repos[i].source_key) == 0) { - // pkg.url = strdup(cached_repos[i].source_value); - // break; - // } - //} - pkg.name = new_arg_str; + // for (size_t i = 0; i < cached_repos_count; i++) { + // if (strcmp(new_arg, cached_repos[i].source_key) == 0) { + // pkg.url = strdup(cached_repos[i].source_value); + // break; + // } + // } + pkg.name = new_arg_str; } else if (is_installed_locally) { - pkg.url = str_from_cstr(""); + pkg.url = mstr(""); pkg.name = str_from_after_delim(&dest_dir, '/'); pkg.is_local = true; } else { - printf("%s '%.*s' is not a valid package\n", PRINT_ERROR, str_fmt(&new_arg)); + log_error("'%.*s' is not a valid package", str_fmt(&arg)); exit(EXIT_FAILURE); } pkg.src = get_pkgsrc(pkg); diff --git a/src/str.c b/src/str.c index 9e67b4a..c845ed5 100644 --- a/src/str.c +++ b/src/str.c @@ -44,15 +44,21 @@ along with this program.If not, see . // XXX: INTERNAL USE ONLY #define _strslc(str) \ - (str_slc) { str->data, str->len } + (str_slc) { \ + str->data, str->len \ + } #define _cstrslc(str) \ - (str_slc) { str, strlen(str) } + (str_slc) { \ + str, strlen(str) \ + } // XXX: since msvc/tcc and I presume cproc aren't smart enough to inline calls // where a str calls a str_slc function and vice versa, we optimize things // ourselves+reduce boilerplate #define _STRINGS_EQUAL -str str_new(void) { return str_new_with_capacity(16); } +str str_new(void) { + return str_new_with_capacity(16); +} str str_new_with_capacity(size_t cap) { str res = {0}; @@ -62,9 +68,13 @@ str str_new_with_capacity(size_t cap) { return res; } -str str_from_cstr(const char *s) { return str_from_str_slc(_cstrslc(s)); } +str str_from_cstr(const char *s) { + return str_from_str_slc(_cstrslc(s)); +} -str mstr(const char *s) { return str_from_str_slc(_cstrslc(s)); } +str mstr(const char *s) { + return str_from_str_slc(_cstrslc(s)); +} str str_from_str_slc(const str_slc s) { str res = str_new_with_capacity(s.len + 1); @@ -429,13 +439,21 @@ size_t str_find_char_right(const str *s, char c) { return str_slc_find_char_right(_strslc(s), c); } -void str_print(const str *s) { printf("%.*s", str_fmt(s)); } +void str_print(const str *s) { + printf("%.*s", str_fmt(s)); +} -void str_println(const str *s) { printf("%.*s\n", str_fmt(s)); } +void str_println(const str *s) { + printf("%.*s\n", str_fmt(s)); +} -void str_fprint(const str *s, FILE *f) { fprintf(f, "%.*s", str_fmt(s)); } +void str_fprint(const str *s, FILE *f) { + fprintf(f, "%.*s", str_fmt(s)); +} -void str_fprintln(const str *s, FILE *f) { fprintf(f, "%.*s\n", str_fmt(s)); } +void str_fprintln(const str *s, FILE *f) { + fprintf(f, "%.*s\n", str_fmt(s)); +} str str_read_line_from_file(FILE *f) { size_t len = 0; @@ -475,11 +493,17 @@ bool str_write_to_file(const str *s, FILE *f) { // === str_slc implementation === -str_slc str_slc_from_str(const str *s) { return _strslc(s); } +str_slc str_slc_from_str(const str *s) { + return _strslc(s); +} -str_slc str_slc_from_cstr(const char *s) { return _cstrslc(s); } +str_slc str_slc_from_cstr(const char *s) { + return _cstrslc(s); +} -str_slc mstrslc(const char *s) { return (str_slc){s, strlen(s)}; } +str_slc mstrslc(const char *s) { + return (str_slc){s, strlen(s)}; +} str str_slc_concat(const str_slc lhs, const str_slc rhs) { str res = str_new(); @@ -684,9 +708,13 @@ char str_slc_at(const str_slc s, size_t i) { return s.data[i]; } -void str_slc_print(const str_slc s) { printf("%.*s", str_fmt(&s)); } +void str_slc_print(const str_slc s) { + printf("%.*s", str_fmt(&s)); +} -void str_slc_println(const str_slc s) { printf("%.*s\n", str_fmt(&s)); } +void str_slc_println(const str_slc s) { + printf("%.*s\n", str_fmt(&s)); +} void str_slc_fprint(const str_slc s, FILE *f) { fprintf(f, "%.*s", str_fmt(&s)); @@ -717,27 +745,23 @@ ptrdiff_t str_slc_find_char_right(const str_slc s, char c) { str str_from_after_delim(str *arg, char delimiter) { size_t i = str_find_char_right(arg, delimiter); str res = str_slice_to_str(arg, i + 1, arg->len); - str_println(&res); return res; } str str_from_before_delim(str *arg, char delimiter) { size_t i = str_find_char(arg, delimiter); str res = str_slice_to_str(arg, i + 1, arg->len); - str_println(&res); return res; } str_slc str_slc_from_after_delim(str_slc arg, char delimiter) { size_t i = str_slc_find_char_right(arg, delimiter); str_slc res = str_slc_slice(arg, i + 1, arg.len); - str_slc_println(res); return res; } str_slc str_slc_from_before_delim(str_slc arg, char delimiter) { size_t i = str_slc_find_char(arg, delimiter); str_slc res = str_slc_slice(arg, i + 1, arg.len); - str_slc_println(res); return res; } -- cgit v1.2.3