Skip to content

Commit

Permalink
Merge pull request #20 from Savapitech/s_fix_des_trucs
Browse files Browse the repository at this point in the history
fix: faudrait que je réfléchisse parfois :)
  • Loading branch information
savalet authored Oct 29, 2024
2 parents 02ffe38 + 25bbeba commit c176814
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
13 changes: 5 additions & 8 deletions src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void check_spec(flags_t *flags)
if (*(flags->fmt) == HANDLERS[i].flag) {
flags->spec = *(flags->fmt);
HANDLERS[i].ptr(flags);
flags->count = flags->spec_buff.count;
flags->count += flags->spec_buff.count;
flags->count += flags->prefix_buff.count;
}
}
Expand All @@ -70,12 +70,9 @@ void check_spec(flags_t *flags)
static
void handle_spec(flags_t *flags)
{
for (; !flags->spec; flags->fmt++) {
if (isalpha(*flags->fmt) || *flags->fmt == '%')
check_spec(flags);
else
break;
}
for (; baby_stridx("hjltzL", *flags->fmt) != -1; flags->fmt++);
if (isalpha(*flags->fmt) || *flags->fmt == '%')
check_spec(flags);
}

static
Expand Down Expand Up @@ -128,7 +125,7 @@ int parser(char *fmt, va_list args)
if (!handle_flags(&flags))
return (-1);
count = 0;
fmt = flags.fmt;
fmt = flags.fmt + 1;
}
if (count != 0) {
write(STDOUT_FILENO, fmt, sizeof(char) * count);
Expand Down
2 changes: 1 addition & 1 deletion tests/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ int main(void)
{
int a = 42;

my_printf("%o", NULL);
my_printf("%s pad 3: %.3s %d", "youpii", "youpii", 42);
}

0 comments on commit c176814

Please sign in to comment.