changed stuff

This commit is contained in:
Maieul BOYER 2024-07-17 17:57:19 +02:00
parent 74336f37a3
commit 8d76630152
No known key found for this signature in database
7 changed files with 31 additions and 192 deletions

View file

@ -6,12 +6,12 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/16 17:57:04 by maiboyer #+# #+# */
/* Updated: 2024/07/07 17:40:18 by maiboyer ### ########.fr */
/* Updated: 2024/07/17 15:38:55 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#include "me/convert/str_to_numbers.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/str/str.h"
@ -23,27 +23,28 @@
bool handle_atoi_stuff(t_const_str fmt, t_usize *c_idx, t_usize *nxt,
t_printf_arg *c_arg)
{
t_i32 atoi_res;
atoi_res = me_atoi(&fmt[*c_idx]);
if (atoi_res < 0)
t_str str;
t_usize i;
i = 0;
while (fmt[*c_idx + i] != '\0' && fmt[*c_idx + i] >= '0' && \
fmt[*c_idx + i] <= '9')
i++;
str = str_substring(fmt, *c_idx, i);
if (str == NULL)
{
*c_idx = *nxt;
*nxt = (t_usize)(str_find_chr(fmt + *nxt + 1, '%') - fmt);
return (false);
}
advance_atoi(fmt, c_idx);
c_arg->extra.align = (t_u64)atoi_res;
handle_prec_and_align(fmt, c_idx, c_arg);
atoi_res = atoi(&fmt[*c_idx]);
if (atoi_res < 0)
if (str_to_u64(str, 10, &c_arg->extra.precision))
{
*c_idx = *nxt;
*nxt = (t_usize)(str_find_chr(fmt + *nxt + 1, '%') - fmt);
return (false);
return (mem_free(str), false);
}
mem_free(str);
advance_atoi(fmt, c_idx);
c_arg->extra.precision = (t_u64)atoi_res;
return (true);
}