update stuff

This commit is contained in:
Maix0 2024-05-20 00:35:39 +02:00
parent 5973022688
commit 544ed8b045
194 changed files with 2060 additions and 1464 deletions

View file

@ -1,13 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* push_char.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/30 14:17:47 by maiboyer #+# #+# */
/* Updated: 2024/04/30 14:17:47 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -10,9 +10,9 @@
/* */
/* ************************************************************************** */
#include "me/char/isalnum.h"
#include "me/char/isalpha.h"
#include "me/char/isdigit.h"
#include "me/char/char.h"
#include "me/char/char.h"
#include "me/char/char.h"
bool me_isalnum(char chr)
{

View file

@ -10,7 +10,7 @@
/* */
/* ************************************************************************** */
#include "me/char/isalpha.h"
#include "me/char/char.h"
bool me_isalpha(char chr)
{

View file

@ -10,7 +10,7 @@
/* */
/* ************************************************************************** */
#include "me/char/isascii.h"
#include "me/char/char.h"
bool me_isascii(char chr)
{

View file

@ -10,7 +10,7 @@
/* */
/* ************************************************************************** */
#include "me/char/isdigit.h"
#include "me/char/char.h"
bool me_isdigit(char chr)
{

View file

@ -10,7 +10,7 @@
/* */
/* ************************************************************************** */
#include "me/char/islower.h"
#include "me/char/char.h"
bool me_islower(char chr)
{

View file

@ -10,7 +10,7 @@
/* */
/* ************************************************************************** */
#include "me/char/isprint.h"
#include "me/char/char.h"
bool me_isprint(char chr)
{

View file

@ -10,7 +10,7 @@
/* */
/* ************************************************************************** */
#include "me/char/isspace.h"
#include "me/char/char.h"
bool me_isspace(char chr)
{

View file

@ -10,7 +10,7 @@
/* */
/* ************************************************************************** */
#include "me/char/isupper.h"
#include "me/char/char.h"
bool me_isupper(char chr)
{

View file

@ -10,10 +10,10 @@
/* */
/* ************************************************************************** */
#include "me/char/isupper.h"
#include "me/char/tolower.h"
#include "me/char/char.h"
#include "me/char/char.h"
bool me_tolower(char chr)
char me_tolower(char chr)
{
if (me_isupper(chr))
return (chr + ('a' - 'A'));

View file

@ -10,10 +10,10 @@
/* */
/* ************************************************************************** */
#include "me/char/islower.h"
#include "me/char/toupper.h"
#include "me/char/char.h"
#include "me/char/char.h"
bool me_toupper(char chr)
char me_toupper(char chr)
{
if (me_islower(chr))
return (chr - ('a' - 'A'));

View file

@ -10,8 +10,8 @@
/* */
/* ************************************************************************** */
#include "me/char/isdigit.h"
#include "me/char/isspace.h"
#include "me/char/char.h"
#include "me/char/char.h"
#include "me/convert/atoi.h"
t_i32 me_atoi(t_const_str str)

View file

@ -11,8 +11,8 @@
/* ************************************************************************** */
#include "me/convert/itoa.h"
#include "me/mem/mem_set.h"
#include "me/string/str_clone.h"
#include "me/mem/mem.h"
#include "me/str/str.h"
#include <stdlib.h>
static void me_itoa_inner(t_u64 nb, t_str out)

View file

@ -0,0 +1,65 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* fd_array_buffer.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/19 15:53:50 by maiboyer #+# #+# */
/* Updated: 2024/05/19 17:05:40 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#include "me/fs/fs.h"
#include "me/mem/mem.h"
#include "me/types.h"
#include <stdio.h>
t_fd_array *get_fd_arrays(void)
{
static t_fd_array val = {};
return (&val);
}
struct s_file_slot *get_unused_fd_slot(void)
{
t_usize i;
t_fd_array *arr;
arr = get_fd_arrays();
i = 0;
while (i < FILE_SLOT_LEN)
{
if (arr->storage[i].ty == SLOT_UNUSED)
return (&arr->storage[i]);
i++;
}
me_abort(
"Unable to find slot for a file descriptor, increate FILE_SLOT_LEN");
return (NULL);
}
void close_all_fds(void)
{
t_usize i;
t_fd_array *arr;
arr = get_fd_arrays();
i = 0;
while (i < FILE_SLOT_LEN)
{
if (arr->storage[i].ty == SLOT_UNUSED)
;
else if (arr->storage[i].ty == SLOT_FD)
close(arr->storage[i].slot.fd.fd);
else if (arr->storage[i].ty == SLOT_DIR)
closedir(arr->storage[i].slot.dir.ptr);
else if (arr->storage[i].ty == SLOT_FILE)
fclose(arr->storage[i].slot.file.ptr);
else
write(2, "Unknown SLOT type", 17);
mem_set_zero(&arr->storage[i], sizeof(arr->storage[i]));
i++;
}
}

View file

@ -12,7 +12,7 @@
#include "me/fs/putchar_fd.h"
#include "me/fs/write.h"
#include "me/string/str_len.h"
#include "me/str/str.h"
void me_putchar_fd(char chr, t_file file)
{

View file

@ -12,7 +12,7 @@
#include "me/fs/putstr_fd.h"
#include "me/fs/write.h"
#include "me/string/str_len.h"
#include "me/str/str.h"
void me_putendl_fd(t_str str, t_file file)
{

View file

@ -12,7 +12,7 @@
#include "me/fs/putstr_fd.h"
#include "me/fs/write.h"
#include "me/string/str_len.h"
#include "me/str/str.h"
void me_putstr_fd(t_str str, t_file file)
{

View file

@ -12,7 +12,7 @@
#include "me/fs/open.h"
#include "me/fs/read.h"
#include "me/mem/mem_copy.h"
#include "me/mem/mem.h"
#include "me/vec/vec_u8.h"
#define READ_BUFFER_SIZE 4096

View file

@ -10,11 +10,11 @@
/* */
/* ************************************************************************** */
#include "me/buffered_str/buf_str.h"
#include "me/string/string.h"
#include "me/gnl/gnl.h"
#include "me/mem/mem.h"
#include "me/mem/mem_move.h"
#include "me/string/str_len.h"
#include "me/mem/mem.h"
#include "me/str/str.h"
#include "me/types.h"
#include <stdio.h>
#include <stdlib.h>
@ -35,7 +35,7 @@ static t_static_buffer *get_next_line_buffer(t_file fd)
return (&bufs[index]);
}
static bool copy_next_line_into_buffer(t_file fd, t_buffer_str *out,
static bool copy_next_line_into_buffer(t_file fd, t_string *out,
char *temp_buffer, t_usize amount)
{
char *buf;
@ -55,12 +55,12 @@ static bool copy_next_line_into_buffer(t_file fd, t_buffer_str *out,
buf[(t_usize)(newline - buf)] = 0;
temp_buffer[(t_usize)(newline - buf + got_newline)] = 0;
mem_move(buf, newline + 1, other_part_len);
push_str_buffer(out, temp_buffer);
string_push(out, temp_buffer);
buf[amount - (t_usize)(newline - buf + got_newline)] = 0;
return (got_newline);
}
static bool read_and_copy(t_file fd, t_buffer_str *out, char *tmp,
static bool read_and_copy(t_file fd, t_string *out, char *tmp,
t_copy_flags *flags)
{
t_isize amount;
@ -82,7 +82,7 @@ static bool read_and_copy(t_file fd, t_buffer_str *out, char *tmp,
return (copy_next_line_into_buffer(fd, out, tmp, (t_usize)amount));
}
static bool handle_leftovers(t_file fd, char *temp_buffer, t_buffer_str *buf)
static bool handle_leftovers(t_file fd, char *temp_buffer, t_string *buf)
{
t_static_buffer *static_buffer;
@ -99,21 +99,21 @@ static bool handle_leftovers(t_file fd, char *temp_buffer, t_buffer_str *buf)
return (false);
}
t_buffer_str get_next_line(t_file fd, bool *error)
t_string get_next_line(t_file fd, bool *error)
{
t_buffer_str buf;
t_string buf;
char *temp_buffer;
t_copy_flags flags;
*error = false;
if (fd < 0 || BUFFER_SIZE <= 0)
return (*error = true, (t_buffer_str){0});
return (*error = true, (t_string){0});
flags = (t_copy_flags){
.error = false,
.empty_read = false,
};
temp_buffer = mem_alloc(sizeof(char) * (BUFFER_SIZE + 2));
buf = alloc_new_buffer(32);
buf = string_new(32);
if (handle_leftovers(fd, temp_buffer, &buf))
return (buf);
while (!read_and_copy(fd, &buf, temp_buffer, &flags) && !flags.empty_read)
@ -122,7 +122,7 @@ t_buffer_str get_next_line(t_file fd, bool *error)
if (flags.error || flags.empty_read)
{
mem_free(buf.buf);
return (*error = true, (t_buffer_str){0});
return (*error = true, (t_string){0});
}
return (buf);
}

View file

@ -11,7 +11,7 @@
/* ************************************************************************** */
#include "me/hash/hasher.h"
#include "me/string/str_len.h"
#include "me/str/str.h"
#include "me/types.h"
void hasher_write_str(t_hasher *hasher, t_str s)

View file

@ -12,7 +12,7 @@
#include "me/hash/sip.h"
#include "me/hash/sip/sip_utils.h"
#include "me/mem/mem_alloc.h"
#include "me/mem/mem.h"
t_hasher hasher_sip13_new(void)
{

View file

@ -10,7 +10,7 @@
/* */
/* ************************************************************************** */
#include "me/mem/mem_alloc.h"
#include "me/mem/mem.h"
#include "me/mem/_allocator.h"
void *mem_alloc(t_usize size)

View file

@ -10,7 +10,7 @@
/* */
/* ************************************************************************** */
#include "me/mem/mem_alloc_array.h"
#include "me/mem/mem.h"
#include "me/mem/_allocator.h"
void *mem_alloc_array(t_usize size, t_usize count)

View file

@ -10,9 +10,9 @@
/* */
/* ************************************************************************** */
#include "me/mem/mem_compare.h"
#include "me/mem/mem.h"
t_i32 mem_compare(const void *lhs, const void *rhs, t_usize count)
bool mem_compare(const void *lhs, const void *rhs, t_usize count)
{
t_usize i;
t_u8 *lhs_;
@ -24,8 +24,8 @@ t_i32 mem_compare(const void *lhs, const void *rhs, t_usize count)
while (i < count)
{
if (lhs_[i] - rhs_[i])
return ((t_i32)(lhs_[i] - rhs_[i]));
return (false);
i++;
}
return (0);
return (true);
}

View file

@ -10,7 +10,7 @@
/* */
/* ************************************************************************** */
#include "me/mem/mem_copy.h"
#include "me/mem/mem.h"
void *mem_copy(void *destination, const void *source, t_usize count)
{

View file

@ -10,7 +10,7 @@
/* */
/* ************************************************************************** */
#include "me/mem/mem_find.h"
#include "me/mem/mem.h"
void *mem_find(void *buf, t_u8 find, t_usize count)
{

View file

@ -10,7 +10,7 @@
/* */
/* ************************************************************************** */
#include "me/mem/mem_find_bytes.h"
#include "me/mem/mem.h"
#include "stdio.h"
void *mem_find_bytes(void *buf, t_u8 *find, t_usize find_len, t_usize count)

View file

@ -10,7 +10,7 @@
/* */
/* ************************************************************************** */
#include "me/mem/mem_move.h"
#include "me/mem/mem.h"
void *mem_move(void *destination, const void *source, t_usize count)
{

View file

@ -10,7 +10,7 @@
/* */
/* ************************************************************************** */
#include "me/mem/mem_set.h"
#include "me/mem/mem.h"
void mem_set(void *buf, t_u8 fill_by, t_usize count)
{

View file

@ -10,7 +10,7 @@
/* */
/* ************************************************************************** */
#include "me/mem/mem_set_zero.h"
#include "me/mem/mem.h"
void mem_set_zero(void *buf, t_usize count)
{

View file

@ -6,16 +6,18 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/07 13:08:52 by maiboyer #+# #+# */
/* Updated: 2024/05/16 17:12:46 by maiboyer ### ########.fr */
/* Updated: 2024/05/19 17:08:45 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#include "me/fs/fs.h"
#include "me/mem/_allocator.h"
#include "me/types.h"
#include <stdlib.h>
void me_exit(t_i32 exit_code)
{
close_all_fds();
uninit_global_allocator();
exit(exit_code);
}

View file

@ -6,17 +6,17 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/03 16:22:41 by maiboyer #+# #+# */
/* Updated: 2024/05/18 18:33:53 by maiboyer ### ########.fr */
/* Updated: 2024/05/19 14:57:20 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#include "me/os/process.h"
#include "me/buffered_str/buf_str.h"
#include "me/string/string.h"
#include "me/mem/mem.h"
#include "me/os/pipe.h"
#include "me/string/str_find_chr.h"
#include "me/string/str_n_compare.h"
#include "me/string/str_split.h"
#include "me/str/str.h"
#include "me/str/str.h"
#include "me/str/str.h"
#include "me/types.h"
#include "me/vec/vec_str.h"
#include <stdio.h>
@ -53,21 +53,21 @@ t_error spawn_process_exec(t_spawn_info info, t_process *process)
}
t_error in_path(t_spawn_info *info, t_process *process, t_const_str path,
t_buffer_str *s)
t_string *s)
{
t_str *splitted_path;
t_usize sp_index;
splitted_path = str_split(path + 5, ':');
if (splitted_path == NULL)
return (str_free(*s), ERROR);
return (string_free(*s), ERROR);
sp_index = 0;
while (splitted_path[sp_index])
{
((void)(process), str_clear(s));
push_str_buffer(s, splitted_path[sp_index]);
push_str_buffer(s, "/");
push_str_buffer(s, info->binary_path);
((void)(process), string_clear(s));
string_push(s, splitted_path[sp_index]);
string_push(s, "/");
string_push(s, info->binary_path);
sp_index++;
if (access(s->buf, X_OK | R_OK) == 0)
break;
@ -82,20 +82,19 @@ t_error in_path(t_spawn_info *info, t_process *process, t_const_str path,
t_error find_binary(t_spawn_info *info, t_process *process)
{
t_usize p_idx;
t_buffer_str s;
t_string s;
(void)(process);
if (info->binary_path == NULL)
return (ERROR);
s = alloc_new_buffer(256);
s = string_new(256);
if (str_start_with(info->binary_path, "/") ||
str_find_chr(info->binary_path, '/') != NULL)
push_str_buffer(&s, info->binary_path);
string_push(&s, info->binary_path);
else
{
if (vec_str_find(&info->environement, find_path, &p_idx))
return (str_free(s), ERROR);
printf("finding in path\n");
return (string_free(s), ERROR);
if (in_path(info, process, info->environement.buffer[p_idx], &s))
return (ERROR);
}
@ -105,7 +104,7 @@ t_error find_binary(t_spawn_info *info, t_process *process)
info->binary_path = s.buf;
return (NO_ERROR);
}
return (str_free(s), ERROR);
return (string_free(s), ERROR);
}
static void cleanup(t_spawn_info info, t_process *process, bool cleanup_process)

View file

@ -6,7 +6,7 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/04 22:25:44 by maiboyer #+# #+# */
/* Updated: 2024/05/18 18:38:01 by maiboyer ### ########.fr */
/* Updated: 2024/05/19 14:51:07 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
@ -36,7 +36,6 @@ bool find_path(const t_str *s)
if (*s == NULL)
return (false);
ss = *s;
printf("%s\n", ss);
return (ss[0] == 'P' && ss[1] == 'A' && ss[2] == 'T' && ss[3] == 'H' &&
ss[4] == '=');
}

View file

@ -13,8 +13,8 @@
#include "me/mem/mem.h"
#include "me/printf/formatter/utils.h"
#include "me/printf/printf.h"
#include "me/string/str_len.h"
#include "me/string/str_substring.h"
#include "me/str/str.h"
#include "me/str/str.h"
#include <stdlib.h>
void printf_c(t_printf_arg data, t_printf_func f)

View file

@ -11,11 +11,11 @@
/* ************************************************************************** */
#include "me/mem/mem.h"
#include "me/mem/mem_set.h"
#include "me/mem/mem.h"
#include "me/printf/formatter/utils.h"
#include "me/printf/printf.h"
#include "me/string/str_clone.h"
#include "me/string/str_len.h"
#include "me/str/str.h"
#include "me/str/str.h"
#include <stdio.h>
#include <stdlib.h>
#define INT_INLINE_BUF 21

View file

@ -10,10 +10,10 @@
/* */
/* ************************************************************************** */
#include "me/mem/mem_set.h"
#include "me/mem/mem.h"
#include "me/printf/formatter/utils.h"
#include "me/printf/printf.h"
#include "me/string/str_len.h"
#include "me/str/str.h"
#define HEX_INLINE_BUF 17
static void fill_hex(t_str out_buf, t_u64 num, t_const_str base)

View file

@ -10,10 +10,10 @@
/* */
/* ************************************************************************** */
#include "me/mem/mem_set.h"
#include "me/mem/mem.h"
#include "me/printf/formatter/utils.h"
#include "me/printf/printf.h"
#include "me/string/str_len.h"
#include "me/str/str.h"
#include <stdio.h>
#define OCT_INLINE_BUF 23

View file

@ -10,10 +10,10 @@
/* */
/* ************************************************************************** */
#include "me/mem/mem_set.h"
#include "me/mem/mem.h"
#include "me/printf/formatter/utils.h"
#include "me/printf/printf.h"
#include "me/string/str_len.h"
#include "me/str/str.h"
#define PTR_INLINE_BUF 17
static void fill_hex(t_str out_buf, t_u64 num, t_str base)

View file

@ -11,11 +11,11 @@
/* ************************************************************************** */
#include "me/mem/mem.h"
#include "me/mem/mem_set.h"
#include "me/mem/mem.h"
#include "me/printf/formatter/utils.h"
#include "me/printf/printf.h"
#include "me/string/str_clone.h"
#include "me/string/str_len.h"
#include "me/str/str.h"
#include "me/str/str.h"
#include <stdio.h>
#include <stdlib.h>
#define UINT_INLINE_BUF 21

View file

@ -10,14 +10,14 @@
/* */
/* ************************************************************************** */
#include "me/buffered_str/buf_str.h"
#include "me/string/string.h"
#include "me/mem/mem.h"
#include "me/convert/atoi.h"
#include "me/printf/formatter/utils.h"
#include "me/printf/matchers/matchers.h"
#include "me/printf/printf.h"
#include "me/string/str_find_chr.h"
#include "me/string/str_substring.h"
#include "me/str/str.h"
#include "me/str/str.h"
#include "me/types.h"
#include <stdio.h>
#include <stdlib.h>

View file

@ -10,8 +10,8 @@
/* */
/* ************************************************************************** */
#include "me/buffered_str/buf_str.h"
#include "me/char/isdigit.h"
#include "me/string/string.h"
#include "me/char/char.h"
#include "me/printf/formatter/utils.h"
#include "me/printf/printf.h"
#include "me/types.h"

View file

@ -12,8 +12,8 @@
#include "me/printf/formatter/utils.h"
#include "me/printf/matchers/matchers.h"
#include "me/string/str_find_chr.h"
#include "me/string/str_len.h"
#include "me/str/str.h"
#include "me/str/str.h"
#include "me/types.h"
#include <stdio.h>

View file

@ -10,7 +10,7 @@
/* */
/* ************************************************************************** */
#include "me/mem/mem_compare.h"
#include "me/mem/mem.h"
#include "me/printf/formatter/formatter.h"
#include "me/printf/matchers/matchers.h"
#include "me/printf/printf.h"

View file

@ -10,35 +10,35 @@
/* */
/* ************************************************************************** */
#include "me/buffered_str/buf_str.h"
#include "me/string/string.h"
#include "me/fs/write.h"
#include "me/printf/formatter/formatter.h"
#include "me/printf/formatter/utils.h"
#include "me/printf/matchers/matchers.h"
#include "me/printf/printf.h"
#include "me/string/str_len.h"
#include "me/str/str.h"
#include "me/types.h"
#include <limits.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdlib.h>
// p_args is an t_buffer_str;
// p_args is an t_string;
static void me_printf_add_to_string(t_const_str to_write, t_usize to_write_len,
void *p_args)
{
t_buffer_str *out_buf;
t_string *out_buf;
out_buf = (t_buffer_str *)p_args;
out_buf = (t_string *)p_args;
(void)(to_write_len);
push_str_buffer(out_buf, to_write);
string_push(out_buf, to_write);
}
t_str me_printf_str(t_const_str fmt, va_list *arguments)
{
t_buffer_str out;
t_string out;
out = alloc_new_buffer(str_len(fmt));
out = string_new(str_len(fmt));
if (out.buf == NULL)
{
return (NULL);

View file

@ -10,13 +10,13 @@
/* */
/* ************************************************************************** */
#include "me/buffered_str/buf_str.h"
#include "me/string/string.h"
#include "me/fs/write.h"
#include "me/printf/formatter/formatter.h"
#include "me/printf/formatter/utils.h"
#include "me/printf/matchers/matchers.h"
#include "me/printf/printf.h"
#include "me/string/str_len.h"
#include "me/str/str.h"
#include "me/types.h"
#include <limits.h>
#include <stdarg.h>

View file

@ -10,10 +10,10 @@
/* */
/* ************************************************************************** */
#include "me/string/str_clone.h"
#include "me/str/str.h"
#include "me/mem/mem.h"
#include "me/string/str_l_copy.h"
#include "me/string/str_len.h"
#include "me/str/str.h"
#include "me/str/str.h"
#include <stdlib.h>
t_str str_clone(t_const_str source)

View file

@ -10,7 +10,7 @@
/* */
/* ************************************************************************** */
#include "me/string/str_compare.h"
#include "me/str/str.h"
// PLEASE FIX THIS FUNCTION IF NEEDED !
bool str_compare(t_const_str lhs, t_const_str rhs)
@ -22,5 +22,5 @@ bool str_compare(t_const_str lhs, t_const_str rhs)
index = 0;
while (lhs[index] && rhs[index] && lhs[index] == rhs[index])
index++;
return ((t_i32)(t_u8)lhs[index] - (t_i32)(t_u8)rhs[index]);
return ((t_i32)(t_u8)lhs[index] == (t_i32)(t_u8)rhs[index]);
}

View file

@ -10,7 +10,7 @@
/* */
/* ************************************************************************** */
#include "me/string/str_find_chr.h"
#include "me/str/str.h"
char *str_find_chr(t_const_str str, char chr)
{

View file

@ -10,8 +10,8 @@
/* */
/* ************************************************************************** */
#include "me/string/str_find_rev_chr.h"
#include "me/string/str_len.h"
#include "me/str/str.h"
#include "me/str/str.h"
char *str_find_rev_chr(t_const_str str, char chr)
{

View file

@ -10,7 +10,7 @@
/* */
/* ************************************************************************** */
#include "me/string/str_n_find_str.h"
#include "me/str/str.h"
const char *str_find_str(t_const_str str, t_const_str to_find)
{

View file

@ -10,7 +10,7 @@
/* */
/* ************************************************************************** */
#include "me/string/str_iter.h"
#include "me/str/str.h"
void str_iter(t_str s, void (*f)(t_usize, char *))
{

View file

@ -10,11 +10,11 @@
/* */
/* ************************************************************************** */
#include "me/mem/mem_alloc.h"
#include "me/string/str_join.h"
#include "me/string/str_l_cat.h"
#include "me/string/str_l_copy.h"
#include "me/string/str_len.h"
#include "me/mem/mem.h"
#include "me/str/str.h"
#include "me/str/str.h"
#include "me/str/str.h"
#include "me/str/str.h"
#include <stdlib.h>
t_str str_join(t_const_str s1, t_const_str s2)

View file

@ -20,8 +20,8 @@
R*/
#include "me/string/str_l_cat.h"
#include "me/string/str_len.h"
#include "me/str/str.h"
#include "me/str/str.h"
t_usize str_l_cat(t_str dest, t_const_str src, t_usize buffer_size)
{

View file

@ -20,8 +20,8 @@
R*/
#include "me/string/str_l_copy.h"
#include "me/string/str_len.h"
#include "me/str/str.h"
#include "me/str/str.h"
t_usize str_l_copy(t_str dest, t_const_str src, t_usize buffer_size)
{

View file

@ -10,7 +10,7 @@
/* */
/* ************************************************************************** */
#include "me/string/str_len.h"
#include "me/str/str.h"
t_usize str_len(t_const_str str)
{

View file

@ -10,8 +10,8 @@
/* */
/* ************************************************************************** */
#include "me/string/str_clone.h"
#include "me/string/str_map.h"
#include "me/str/str.h"
#include "me/str/str.h"
t_str str_map(t_const_str s, char (*f)(t_usize, char))
{

View file

@ -10,18 +10,18 @@
/* */
/* ************************************************************************** */
#include "me/string/str_n_compare.h"
#include "me/str/str.h"
// PLEASE FIX THIS FUNCTION IF NEEDED !
t_i32 str_n_compare(t_const_str lhs, t_const_str rhs, t_usize n)
bool str_n_compare(t_const_str lhs, t_const_str rhs, t_usize n)
{
t_usize index;
index = 0;
if (n == 0)
return (0);
return (true);
while (lhs[index] && rhs[index] && lhs[index] == rhs[index] && index < n
- 1)
index++;
return ((t_i32)(t_u8)lhs[index] - (t_i32)(t_u8)rhs[index]);
return ((t_i32)(t_u8)lhs[index] == (t_i32)(t_u8)rhs[index]);
}

View file

@ -10,8 +10,8 @@
/* */
/* ************************************************************************** */
#include "me/string/str_len.h"
#include "me/string/str_n_find_str.h"
#include "me/str/str.h"
#include "me/str/str.h"
static t_str local_get_end_of_search(t_usize len, t_str str)
{

View file

@ -11,8 +11,8 @@
/* ************************************************************************** */
#include "me/mem/mem.h"
#include "me/string/str_l_copy.h"
#include "me/string/str_split.h"
#include "me/str/str.h"
#include "me/str/str.h"
#include <stdlib.h>
static t_usize local_count_words(t_const_str str, char chr);

View file

@ -10,10 +10,10 @@
/* */
/* ************************************************************************** */
#include "me/mem/mem_alloc.h"
#include "me/string/str_l_copy.h"
#include "me/string/str_len.h"
#include "me/string/str_substring.h"
#include "me/mem/mem.h"
#include "me/str/str.h"
#include "me/str/str.h"
#include "me/str/str.h"
#include <stdlib.h>
t_str str_substring(t_const_str str, t_usize start, t_usize len)

View file

@ -10,11 +10,11 @@
/* */
/* ************************************************************************** */
#include "me/mem/mem_alloc.h"
#include "me/string/str_find_chr.h"
#include "me/string/str_l_copy.h"
#include "me/string/str_len.h"
#include "me/string/str_trim.h"
#include "me/mem/mem.h"
#include "me/str/str.h"
#include "me/str/str.h"
#include "me/str/str.h"
#include "me/str/str.h"
#include <stdlib.h>
t_str str_trim(t_const_str str, t_const_str charset)

View file

@ -10,16 +10,16 @@
/* */
/* ************************************************************************** */
#include "me/buffered_str/buf_str.h"
#include "me/string/string.h"
#include "me/mem/mem.h"
#include "me/mem/mem_copy.h"
#include "me/mem/mem_set_zero.h"
#include "me/string/str_l_cat.h"
#include "me/string/str_len.h"
#include "me/mem/mem.h"
#include "me/mem/mem.h"
#include "me/str/str.h"
#include "me/str/str.h"
#include "me/types.h"
#include <stdlib.h>
t_error str_reserve(t_buffer_str *buf, t_usize size)
t_error str_reserve(t_string *buf, t_usize size)
{
t_str temp_buffer;
t_usize new_capacity;
@ -42,7 +42,7 @@ t_error str_reserve(t_buffer_str *buf, t_usize size)
return (NO_ERROR);
}
t_error push_str_buffer(t_buffer_str *buf, t_const_str to_push)
t_error string_push(t_string *buf, t_const_str to_push)
{
t_usize to_push_len;
@ -56,25 +56,25 @@ t_error push_str_buffer(t_buffer_str *buf, t_const_str to_push)
return (NO_ERROR);
}
bool push_str_char(t_buffer_str *buf, char to_push)
bool string_push_char(t_string *buf, char to_push)
{
char push_str[2];
push_str[0] = to_push;
push_str[1] = 0;
return (push_str_buffer(buf, push_str));
return (string_push(buf, push_str));
}
void str_clear(t_buffer_str *buf)
void string_clear(t_string *buf)
{
mem_set_zero(buf->buf, buf->capacity);
buf->len = 0;
return;
}
t_buffer_str alloc_new_buffer(t_usize capacity)
t_string string_new(t_usize capacity)
{
t_buffer_str out;
t_string out;
t_str buf;
if (capacity == 0)