Skip to content

Commit

Permalink
Merge pull request #32 from Savapitech/add-star
Browse files Browse the repository at this point in the history
add: star
  • Loading branch information
savalet authored Dec 2, 2024
2 parents 850e969 + 6744e45 commit 8b2a802
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ void parse_precision(flags_t *flags)
{
if (*flags->fmt == '.') {
flags->fmt++;
if (*flags->fmt == '*') {
flags->fmt++;
flags->precision = va_arg(flags->args, int);
return;
}
flags->precision = baby_strpnum(&flags->fmt);
}
}
Expand Down Expand Up @@ -93,6 +98,17 @@ void print_buffers(flags_t *flags)
flags->prefix_buff.count);
}

static
void parse_width(flags_t *flags)
{
if (*flags->fmt == '*') {
flags->fmt++;
flags->width = va_arg(flags->args, int);
return;
}
flags->width = baby_strpnum(&flags->fmt);
}

static
bool handle_flags(flags_t *flags)
{
Expand All @@ -106,7 +122,7 @@ bool handle_flags(flags_t *flags)
if (*flags->fmt == '\0')
return true;
parse_char_settings(flags);
flags->width = baby_strpnum(&flags->fmt);
parse_width(flags);
parse_precision(flags);
if (flags->width == ERROR_OVERFLOW || flags->precision == ERROR_OVERFLOW)
return false;
Expand Down

0 comments on commit 8b2a802

Please sign in to comment.