diff --git a/inc/libft_print.h b/inc/libft_print.h index 9d450b0..99dfed8 100644 --- a/inc/libft_print.h +++ b/inc/libft_print.h @@ -6,7 +6,7 @@ /* By: brda-sil i_fmt = i_fmt; + (*conf->i_fmt)++; + conf->flags = ft_printf_fmt_get_flags(i_fmt, format); + conf->width = ft_printf_fmt_get_width(i_fmt, format); + conf->precision = ft_printf_fmt_get_precision(i_fmt, format); + conf->fmt = format; +} + void ft_printf_fmt_parse(int *i_fmt, int *i_buff, \ const char *format, va_list args) { @@ -19,13 +30,8 @@ void ft_printf_fmt_parse(int *i_fmt, int *i_buff, \ char *buff; t_size str_len; - conf.i_fmt = i_fmt; - (*conf.i_fmt)++; - conf.flags = ft_printf_fmt_get_flags(i_fmt, format); - conf.width = ft_printf_fmt_get_width(i_fmt, format); - conf.precision = ft_printf_fmt_get_precision(i_fmt, format); + ft_printf_fmt_setup(&conf, i_fmt, format); conf.i_buff = i_buff; - conf.fmt = format; ft_printf_fmt_get_type(&conf, args); buff = ft_printf_buff_get(); if (conf.width) diff --git a/src/print/ft_printf/padding/addr.c b/src/print/ft_printf/padding/addr.c index 0b5ae00..68da55c 100644 --- a/src/print/ft_printf/padding/addr.c +++ b/src/print/ft_printf/padding/addr.c @@ -6,12 +6,23 @@ /* By: brda-sil flags & FT_PRINTF_FLAG_MINUS) + ft_strncpy(buff + *conf->i_buff, conf->cur_type, str_len); + else + ft_strncpy(buff + *conf->i_buff + conf->width - str_len, \ + conf->cur_type, str_len); + (*conf->i_buff) += conf->width; +} + void ft_printf_type_padding_addr(t_fmt_conf *conf) { t_size begin; @@ -25,11 +36,8 @@ void ft_printf_type_padding_addr(t_fmt_conf *conf) begin = *conf->i_buff; if (conf->flags & FT_PRINTF_FLAG_MINUS) begin += str_len; - while (to_pad > 0) - { + while (to_pad-- > 0) buff[begin++] = ' '; - to_pad--; - } if (str_len > conf->width) { if (conf->flags & FT_PRINTF_FLAG_MINUS) @@ -39,12 +47,5 @@ void ft_printf_type_padding_addr(t_fmt_conf *conf) (*conf->i_buff) += str_len; } else - { - if (conf->flags & FT_PRINTF_FLAG_MINUS) - ft_strncpy(buff + *conf->i_buff, conf->cur_type, str_len); - else - ft_strncpy(buff + *conf->i_buff + conf->width - str_len, \ - conf->cur_type, str_len); - (*conf->i_buff) += conf->width; - } + ft_printf_type_padding_addr_short(conf, buff, str_len); } diff --git a/src/print/ft_printf/padding/integer.c b/src/print/ft_printf/padding/integer.c index b12b33b..b079280 100644 --- a/src/print/ft_printf/padding/integer.c +++ b/src/print/ft_printf/padding/integer.c @@ -6,18 +6,17 @@ /* By: brda-sil cur_type) - (sign != 0); if (sign && !(conf->flags & FT_PRINTF_FLAG_MINUS)) { @@ -68,6 +67,7 @@ void ft_printf_type_padding_integer(t_fmt_conf *conf) int to_pad; char sign; t_size str_len; + char *buff; sign = ft_printf_type_padding_remove_sign(conf->cur_type); str_len = ft_strlen(conf->cur_type) - (sign != 0); @@ -76,5 +76,6 @@ void ft_printf_type_padding_integer(t_fmt_conf *conf) if (conf->flags & FT_PRINTF_FLAG_MINUS) begin += str_len; ft_printf_type_padding_integer_pad(conf, begin, to_pad); - ft_printf_type_padding_integer_post(conf, sign); + buff = ft_printf_buff_get(); + ft_printf_type_padding_integer_post(conf, sign, buff); } diff --git a/test/src/print.c b/test/src/print.c index ad09244..67108d4 100644 --- a/test/src/print.c +++ b/test/src/print.c @@ -6,7 +6,7 @@ /* By: brda-sil