-
Notifications
You must be signed in to change notification settings - Fork 0
/
parse_width.c
31 lines (29 loc) · 1.22 KB
/
parse_width.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parse_width.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: alischyn <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/22 17:07:59 by alischyn #+# #+# */
/* Updated: 2017/03/23 18:03:58 by alischyn ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
const char *parse_width(t_fmt *fmt, const char *f, va_list ap)
{
if (*f == '*')
{
f++;
fmt->has_width = true;
fmt->width = va_arg(ap, int);
}
else if ('1' <= *f && *f <= '9')
{
fmt->has_width = true;
fmt->width = 0;
while ('0' <= *f && *f <= '9')
fmt->width = fmt->width * 10 + *(f++) - '0';
}
return (f);
}