-
Notifications
You must be signed in to change notification settings - Fork 0
/
pf_format_precision_char.c
43 lines (40 loc) · 1.64 KB
/
pf_format_precision_char.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
37
38
39
40
41
42
43
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* pf_format_precision_char.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gkhodizo <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/07/24 15:14:46 by gkhodizo #+# #+# */
/* Updated: 2020/08/02 10:32:19 by gkhodizo ### ########.fr */
/* */
/* ************************************************************************** */
/*
** The format_precision_char() formats str only for char specifiers
** i.e. "csp%" given precision.
*/
#include "ft_printf.h"
void format_precision_char(t_fmt *fmt)
{
if (fmt->specifier == 'p' && fmt->is_precision
&& fmt->precision == 0 && fmt->negative_prec == 0
&& fmt->is_null)
{
fmt->spec_value = free_n_copy(fmt->spec_value, 0, 2);
fmt->value_len = ft_strlen(fmt->spec_value);
return ;
}
if ((fmt->precision == 0
&& (fmt->specifier == 'c' || fmt->specifier == 'p'))
|| (fmt->precision && fmt->specifier == '%')
|| fmt->negative_prec)
return ;
if (fmt->specifier == 's'
&& fmt->precision < fmt->value_len
&& fmt->is_precision == 1)
{
fmt->spec_value = free_n_copy(fmt->spec_value, 0, fmt->precision);
fmt->value_len = fmt->precision;
}
return ;
}