-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpf_format_precision_num.c
36 lines (33 loc) · 1.45 KB
/
pf_format_precision_num.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
32
33
34
35
36
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* pf_format_precision_num.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gkhodizo <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/07/24 15:14:55 by gkhodizo #+# #+# */
/* Updated: 2020/08/01 18:47:47 by gkhodizo ### ########.fr */
/* */
/* ************************************************************************** */
/*
** The format_precision_num() formats str only for numeric specifiers
** i.e. "diuxX" given precision.
*/
#include "ft_printf.h"
void format_precision_num(t_fmt *fmt)
{
if (fmt->is_precision && fmt->precision == 0 && (!fmt->negative_prec)
&& (ft_strcmp(fmt->spec_value, "0") == 0))
{
ft_strdel(&fmt->spec_value);
fmt->spec_value = ft_strnew(0);
fmt->value_len = 0;
}
if (fmt->precision >= fmt->value_len)
{
fmt->spec_value = format_padding(fmt, '0', fmt->precision, 0);
fmt->value_len = fmt->is_value_negative == 1 ?
++fmt->precision : fmt->precision;
}
return ;
}