|
@ -1,12 +1,12 @@ |
|
|
/* ************************************************************************** */ |
|
|
/* ************************************************************************** */ |
|
|
/* */ |
|
|
/* */ |
|
|
/* ::: :::::::: */ |
|
|
/* ::: :::::::: */ |
|
|
/* ft_putchars.c :+: :+: :+: */ |
|
|
/* ft_print_chars.c :+: :+: :+: */ |
|
|
/* +:+ +:+ +:+ */ |
|
|
/* +:+ +:+ +:+ */ |
|
|
/* By: narnaud <narnaud@student.42.fr> +#+ +:+ +#+ */ |
|
|
/* By: narnaud <narnaud@student.42.fr> +#+ +:+ +#+ */ |
|
|
/* +#+#+#+#+#+ +#+ */ |
|
|
/* +#+#+#+#+#+ +#+ */ |
|
|
/* Created: 2021/10/27 09:17:03 by narnaud #+# #+# */ |
|
|
/* Created: 2021/10/27 09:17:03 by narnaud #+# #+# */ |
|
|
/* Updated: 2021/11/17 09:57:53 by narnaud ### ########.fr */ |
|
|
/* Updated: 2023/04/13 12:14:39 by narnaud ### ########.fr */ |
|
|
/* */ |
|
|
/* */ |
|
|
/* ************************************************************************** */ |
|
|
/* ************************************************************************** */ |
|
|
|
|
|
|
|
@ -17,14 +17,13 @@ void ft_print_char(int ch, t_opts *opts) |
|
|
char c; |
|
|
char c; |
|
|
char *ret; |
|
|
char *ret; |
|
|
int len; |
|
|
int len; |
|
|
c = (char)ch; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
c = (char)ch; |
|
|
if (opts->width < 1) |
|
|
if (opts->width < 1) |
|
|
len = 1; |
|
|
len = 1; |
|
|
else |
|
|
else |
|
|
len = opts->width; |
|
|
len = opts->width; |
|
|
ret = ft_calloc(len + 1, sizeof(char)); |
|
|
ret = ft_calloc(len + 1, sizeof(char)); |
|
|
|
|
|
|
|
|
if (opts->minus) |
|
|
if (opts->minus) |
|
|
{ |
|
|
{ |
|
|
ret[0] = c; |
|
|
ret[0] = c; |
|
@ -37,13 +36,13 @@ void ft_print_char(int ch, t_opts *opts) |
|
|
while (opts->width-- > 1) |
|
|
while (opts->width-- > 1) |
|
|
ret[opts->width - 1] = ' '; |
|
|
ret[opts->width - 1] = ' '; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
add_string(ret, len); |
|
|
add_string(ret, len); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void ft_print_str(char *str, t_opts *opts) |
|
|
void ft_print_str(char *str, t_opts *opts) |
|
|
{ |
|
|
{ |
|
|
char *ret; |
|
|
char *ret; |
|
|
|
|
|
|
|
|
if (!str) |
|
|
if (!str) |
|
|
{ |
|
|
{ |
|
|
if (!opts->dot || opts->precision >= 6) |
|
|
if (!opts->dot || opts->precision >= 6) |
|
@ -52,25 +51,21 @@ void ft_print_str(char *str, t_opts *opts) |
|
|
str = ""; |
|
|
str = ""; |
|
|
} |
|
|
} |
|
|
ret = str_opts_transform(str, opts); |
|
|
ret = str_opts_transform(str, opts); |
|
|
|
|
|
|
|
|
add_string(ret, ft_strlen(ret)); |
|
|
add_string(ret, ft_strlen(ret)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void va_print_char(va_list va_ch, const char *str, t_opts *opts) |
|
|
void va_print_char(va_list va_ch, t_opts *opts) |
|
|
{ |
|
|
{ |
|
|
(void)*str; |
|
|
|
|
|
ft_print_char(va_arg(va_ch, int), opts); |
|
|
ft_print_char(va_arg(va_ch, int), opts); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void va_print_str(va_list va_str, const char *str, t_opts *opts) |
|
|
void va_print_str(va_list va_str, t_opts *opts) |
|
|
{ |
|
|
{ |
|
|
(void)*str; |
|
|
|
|
|
ft_print_str(va_arg(va_str, char *), opts); |
|
|
ft_print_str(va_arg(va_str, char *), opts); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void va_print_perc(va_list va, const char *str, t_opts *opts) |
|
|
void va_print_perc(va_list va, t_opts *opts) |
|
|
{ |
|
|
{ |
|
|
(void)*str; |
|
|
|
|
|
(void)va; |
|
|
(void)va; |
|
|
ft_print_char('%', opts); |
|
|
ft_print_char('%', opts); |
|
|
} |
|
|
} |
|
|