skeletton untested project

This commit is contained in:
thrieg 2025-12-11 06:18:16 +01:00
commit 6fc620e8f4
187 changed files with 6584 additions and 0 deletions

View file

@ -0,0 +1,66 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_padding_bonus.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: thrieg <thrieg@student.42mulhouse.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/27 16:54:14 by thrieg #+# #+# */
/* Updated: 2025/02/16 19:07:59 by thrieg ### ########.fr */
/* */
/* ************************************************************************** */
#include "../libft.h"
#include "ft_printf.h"
#include "ft_printf_bonus.h"
//len is the len of what's already printed
//returns the number of characters writen or -1 if an error occurs.
int padding_if_needed_before(t_arglist *arglist,
char caller,
size_t len,
t_vector *vec)
{
char padding_char;
int i;
int padding_len;
padding_len = arglist->width_mini - (int)len;
if (padding_len <= 0)
return (0);
if (arglist->flag_justified_left)
return (0);
if ((arglist->flag_zero == 1) && caller != 'c' && caller != 's'
&& caller != 'p' && (arglist->precision < 0))
padding_char = '0';
else
padding_char = ' ';
i = 0;
while (i++ < padding_len)
if (!ft_vector_pushback(vec, padding_char))
return (-1);
return (padding_len);
}
//len is the len of what's already printed
//returns the number of characters writen or -1 if an error occurs.
int padding_if_needed_after(t_arglist *arglist,
char caller,
size_t len,
t_vector *vec)
{
int i;
int padding_len;
(void)caller;
padding_len = arglist->width_mini - (int)len;
if (padding_len <= 0)
return (0);
if (!(arglist->flag_justified_left))
return (0);
i = 0;
while (i++ < padding_len)
if (!ft_vector_pushback(vec, ' '))
return (-1);
return (padding_len);
}