Skip to content

Commit

Permalink
fix: put_nbr INT_MAX precision after putstr
Browse files Browse the repository at this point in the history
  • Loading branch information
savalet committed Oct 30, 2024
1 parent 4b08708 commit 11d1df1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/handler/put_nbr.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@
** display the number given as parameter
*/

#include <stdio.h>

#include "my.h"

void printf_put_nbr(flags_t *flags)
{
int nb = va_arg(flags->args, int);

if (flags->flags & FLAGS_SET_SPACE) {
flags->prefix_buff.str = " ";
flags->prefix_buff.count = 1;
}
if (flags->flags & FLAGS_PUT_SIGN) {
flags->prefix_buff.str = "+";
flags->prefix_buff.count = 1;
Expand Down
2 changes: 2 additions & 0 deletions src/handler/putstr.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ void printf_putstr(flags_t *flags)
for (; str[count] && count < flags->precision; count++);
flags->spec_buff.str = str;
flags->spec_buff.count = count;
if (flags->precision == INT_MAX)
flags->precision = -1;
}

0 comments on commit 11d1df1

Please sign in to comment.