all flags setup, some fixes is needed

This commit is contained in:
David Gailleton
2025-11-20 16:54:00 +01:00
parent bd1c66d86f
commit 24887c810c
12 changed files with 181 additions and 63 deletions

View File

@@ -6,7 +6,7 @@
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/17 12:02:03 by dgaillet #+# #+# */
/* Updated: 2025/11/19 20:16:48 by dgaillet ### ########lyon.fr */
/* Updated: 2025/11/20 15:34:58 by dgaillet ### ########lyon.fr */
/* */
/* ************************************************************************** */
@@ -15,13 +15,22 @@
int print_str(t_arg *arg, char *str)
{
int count;
count = 0;
if (!str)
{
ft_putstr_fd("(null)", 1);
return (6);
if (arg->dot < 6 && arg->dot >= 0)
return (print_chars(arg->padding, ' '));
if (arg->padding > 6)
count += print_chars(arg->padding - 6, ' ');
return (count + write(1, "(null)", 6));
}
if (arg->arg)
ft_putstr_fd("", 1);
ft_putstr_fd(str, 1);
return (ft_strlen(str));
if (arg->dot > (int) ft_strlen(str) || arg->dot < 0)
arg->dot = ft_strlen(str);
if (arg->padding > 0)
count += print_chars(arg->padding - arg->dot, ' ');
else if (!str[0] && arg->space > 0)
return (write(1, " ", 1));
return (count + write(1, str, arg->dot));
}