52 lines
1.8 KiB
C
Executable file
52 lines
1.8 KiB
C
Executable file
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_cases_easy_bonus.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: thrieg <thrieg@student.42mulhouse.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2024/10/23 13:03:05 by thrieg #+# #+# */
|
|
/* Updated: 2025/02/16 19:07:51 by thrieg ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "../libft.h"
|
|
#include "ft_printf.h"
|
|
#include "ft_printf_bonus.h"
|
|
|
|
int padding_if_needed_before(
|
|
t_arglist *arglist,
|
|
char caller,
|
|
size_t len,
|
|
t_vector *vec);
|
|
int padding_if_needed_after(
|
|
t_arglist *arglist,
|
|
char caller,
|
|
size_t len,
|
|
t_vector *vec);
|
|
|
|
//flag 0 has undefined behavior with c so the minimum width has to be spaces
|
|
int ft_case_c_bonus(t_vector *vec, va_list *args, t_arglist *arglist)
|
|
{
|
|
if (padding_if_needed_before(arglist, 'c', 1, vec) < 0)
|
|
return (0);
|
|
if (!ft_vector_pushback(vec, (char)va_arg(*args, int)))
|
|
return (0);
|
|
if (padding_if_needed_after(arglist, 'c', 1, vec) < 0)
|
|
return (0);
|
|
return (1);
|
|
}
|
|
|
|
int ft_case_percent_bonus(t_vector *vec)
|
|
{
|
|
if (!ft_vector_pushback(vec, '%'))
|
|
return (0);
|
|
return (1);
|
|
}
|
|
|
|
int ft_case_d_bonus(t_vector *vec, va_list *args, t_arglist *arglist);
|
|
|
|
int ft_case_i_bonus(t_vector *vec, va_list *args, t_arglist *arglist)
|
|
{
|
|
return (ft_case_d_bonus(vec, args, arglist));
|
|
}
|