Start str8 renaming

This commit is contained in:
2026-06-26 16:02:12 +01:00
parent cd797683d2
commit acbfc9088c
34 changed files with 729 additions and 729 deletions
+8 -8
View File
@@ -17,17 +17,17 @@
#define CMD_BUF_LEN 8192
#define OUT_BUF_LEN 4096
wp_intern CMDResult execute_command(Str8RO *cmd, CMDOutHandling out_handling, Str8 *out_buf);
wp_intern CMDError get_command_output(FILE *fp, CMDOutHandling out_handling, Str8 *out_buf);
wp_intern CMDResult execute_command(WpStr8RO *cmd, CMDOutHandling out_handling, WpStr8 *out_buf);
wp_intern CMDError get_command_output(FILE *fp, CMDOutHandling out_handling, WpStr8 *out_buf);
CMDResult wapp_shell_commander_execute(CMDOutHandling out_handling, Str8 *out_buf, const Str8List *cmd) {
CMDResult wapp_shell_commander_execute(CMDOutHandling out_handling, WpStr8 *out_buf, const WpStr8List *cmd) {
if (!cmd) {
return CMD_NO_EXIT(SHELL_ERR_INVALID_ARGS);
}
Allocator arena = wapp_mem_arena_allocator_init(KiB(500));
Str8 *cmd_str = wapp_str8_join(&arena, cmd, &wapp_str8_lit_ro(" "));
WpStr8 *cmd_str = wapp_str8_join(&arena, cmd, &wapp_str8_lit_ro(" "));
if (!cmd_str) {
wapp_mem_arena_allocator_destroy(&arena);
return CMD_NO_EXIT(SHELL_ERR_ALLOCATION_FAIL);
@@ -43,7 +43,7 @@ CMDResult wapp_shell_commander_execute(CMDOutHandling out_handling, Str8 *out_bu
return output;
}
wp_intern CMDResult execute_command(Str8RO *cmd, CMDOutHandling out_handling, Str8 *out_buf) {
wp_intern CMDResult execute_command(WpStr8RO *cmd, CMDOutHandling out_handling, WpStr8 *out_buf) {
char cmd_buf[CMD_BUF_LEN] = {0};
wapp_str8_copy_to_cstr(cmd_buf, cmd, CMD_BUF_LEN);
@@ -83,8 +83,8 @@ EXECUTE_COMMAND_CLOSE:
return output;
}
wp_intern CMDError get_command_output(FILE *fp, CMDOutHandling out_handling, Str8 *out_buf) {
Str8 out = wapp_str8_buf(OUT_BUF_LEN);
wp_intern CMDError get_command_output(FILE *fp, CMDOutHandling out_handling, WpStr8 *out_buf) {
WpStr8 out = wapp_str8_buf(OUT_BUF_LEN);
out.size = fread((void *)out.buf, sizeof(c8), out.capacity, fp);
if (out_handling == SHELL_OUTPUT_CAPTURE && out_buf != NULL) {
@@ -94,7 +94,7 @@ wp_intern CMDError get_command_output(FILE *fp, CMDOutHandling out_handling, Str
wapp_str8_concat_capped(out_buf, &out);
} else if (out_handling == SHELL_OUTPUT_PRINT) {
printf(WAPP_STR8_SPEC, wapp_str8_varg(out));
printf(WP_STR8_SPEC, wpStr8Varg(out));
}
return SHELL_ERR_NO_ERROR;
+1 -1
View File
@@ -18,7 +18,7 @@ BEGIN_C_LINKAGE
#define CMD_NO_EXIT(ERR) ((CMDResult){.exited = false, .exit_code = EXIT_FAILURE, .error = ERR})
CMDResult wapp_shell_commander_execute(CMDOutHandling out_handling, Str8 *out_buf, const Str8List *cmd);
CMDResult wapp_shell_commander_execute(CMDOutHandling out_handling, WpStr8 *out_buf, const WpStr8List *cmd);
wp_extern CMDError get_output_status(FILE *fp, i32 *status_out);
@@ -9,7 +9,7 @@
#include "../terminal_colours.h"
#include <stdio.h>
wp_intern Str8RO colours[COUNT_TERM_COLOUR] = {
wp_intern WpStr8RO colours[COUNT_TERM_COLOUR] = {
[WAPP_TERM_COLOUR_FG_BLACK] = wapp_str8_lit_ro_initialiser_list("\033[30m"),
[WAPP_TERM_COLOUR_FG_RED] = wapp_str8_lit_ro_initialiser_list("\033[31m"),
[WAPP_TERM_COLOUR_FG_GREEN] = wapp_str8_lit_ro_initialiser_list("\033[32m"),
@@ -29,8 +29,8 @@ wp_intern Str8RO colours[COUNT_TERM_COLOUR] = {
[WAPP_TERM_COLOUR_CLEAR] = wapp_str8_lit_ro_initialiser_list("\033[0m"),
};
void print_coloured_text(Str8RO *text, TerminalColour colour) {
printf(WAPP_STR8_SPEC WAPP_STR8_SPEC, wapp_str8_varg(colours[colour]), wapp_str8_varg((*text)));
void print_coloured_text(WpStr8RO *text, TerminalColour colour) {
printf(WP_STR8_SPEC WP_STR8_SPEC, wpStr8Varg(colours[colour]), wpStr8Varg((*text)));
}
#endif // !WP_PLATFORM_POSIX
+2 -2
View File
@@ -4,7 +4,7 @@
#include "terminal_colours.h"
#include "../../../base/strings/str8/str8.h"
void wapp_shell_termcolour_print_text(Str8RO *text, TerminalColour colour) {
void wapp_shell_termcolour_print_text(WpStr8RO *text, TerminalColour colour) {
if (colour < WAPP_TERM_COLOUR_FG_BLACK || colour > WAPP_TERM_COLOUR_FG_BR_WHITE) {
return;
}
@@ -13,6 +13,6 @@ void wapp_shell_termcolour_print_text(Str8RO *text, TerminalColour colour) {
}
void wapp_shell_termcolour_clear_colour(void) {
Str8RO empty = wapp_str8_lit_ro("");
WpStr8RO empty = wapp_str8_lit_ro("");
print_coloured_text(&empty, WAPP_TERM_COLOUR_CLEAR);
}
+2 -2
View File
@@ -14,10 +14,10 @@ BEGIN_C_LINKAGE
// TODO (Abdelrahman): Look into moving away from stdio in the implementation
void wapp_shell_termcolour_print_text(Str8RO *text, TerminalColour colour);
void wapp_shell_termcolour_print_text(WpStr8RO *text, TerminalColour colour);
void wapp_shell_termcolour_clear_colour(void);
wp_extern void print_coloured_text(Str8RO *text, TerminalColour colour);
wp_extern void print_coloured_text(WpStr8RO *text, TerminalColour colour);
#ifdef WP_PLATFORM_CPP
END_C_LINKAGE
+2 -2
View File
@@ -43,7 +43,7 @@ wp_intern WORD colours[COUNT_TERM_COLOUR] = {
[WAPP_TERM_COLOUR_FG_BR_WHITE] = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY,
};
void print_coloured_text(Str8RO *text, TerminalColour colour) {
void print_coloured_text(WpStr8RO *text, TerminalColour colour) {
wp_persist TermcolourData data = {0};
if (data.handle == 0) {
init_data(&data);
@@ -56,7 +56,7 @@ void print_coloured_text(Str8RO *text, TerminalColour colour) {
}
SetConsoleTextAttribute(data.handle, data.current_colour);
printf(WAPP_STR8_SPEC, wapp_str8_varg((*text)));
printf(WP_STR8_SPEC, wpStr8Varg((*text)));
}
wp_intern void init_data(TermcolourData *data) {