Skip to content

Commit

Permalink
wip: printf: zero flags
Browse files Browse the repository at this point in the history
  • Loading branch information
Pixailz committed Dec 5, 2023
1 parent aeb0229 commit 6554eba
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
3 changes: 1 addition & 2 deletions src/print/ft_printf/ft_printf_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: brda-sil <brda-sil@students.42angouleme +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/28 16:46:32 by brda-sil #+# #+# */
/* Updated: 2023/12/04 00:51:51 by brda-sil ### ########.fr */
/* Updated: 2023/12/04 02:58:09 by brda-sil ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -51,7 +51,6 @@ t_size ft_printf_parse(va_list args, const char *format)
char *ptr_buffer;
int i_fmt;
int i_buff;
t_size size;

i_fmt = 0;
i_buff = 0;
Expand Down
6 changes: 3 additions & 3 deletions src/print/ft_printf/padding/integer.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: brda-sil <brda-sil@students.42angouleme +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/03 15:28:37 by brda-sil #+# #+# */
/* Updated: 2023/12/04 02:20:04 by brda-sil ### ########.fr */
/* Updated: 2023/12/04 22:34:44 by brda-sil ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -37,7 +37,7 @@ void ft_printf_type_padding_integer_post(t_fmt_conf *conf, char sign)
ft_strncpy(buff + *conf->i_buff, \
conf->cur_type + (sign != 0), str_len);
}
if (str_len > conf->width)
if (str_len >= conf->width)
(*conf->i_buff) += str_len + (sign != 0);
else
(*conf->i_buff) += conf->width;
Expand All @@ -55,7 +55,7 @@ void ft_printf_type_padding_integer_pad(t_fmt_conf *conf, t_size begin, \
pad_str = '0';
else
pad_str = ' ';
while (to_pad > 0)
while (to_pad >= 0)
{
buff[begin++] = pad_str;
to_pad--;
Expand Down
12 changes: 7 additions & 5 deletions test/src/print.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: brda-sil <brda-sil@students.42angouleme +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/07 03:09:08 by brda-sil #+# #+# */
/* Updated: 2023/12/03 16:08:08 by brda-sil ### ########.fr */
/* Updated: 2023/12/04 22:22:30 by brda-sil ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -208,10 +208,12 @@ int ci_test(void)
int retv;

retv = 0;
retv |= ci_base();
retv |= ci_flags_padding();
ft_dprintf(2, "test\n");
ft_perr("test [%#06x]\n", 0x10);
// retv |= ci_base();
// retv |= ci_flags_padding();
// ft_dprintf(2, "test\n");
// ft_perr("test [%#06x]\n", 0x10);
printf(" {%01d} \n", -9);
ft_printf(" {%01d} \n", -9);
return (retv);
}

Expand Down

0 comments on commit 6554eba

Please sign in to comment.