-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_is.c
41 lines (36 loc) · 1.59 KB
/
ft_is.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_is.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jkoupy <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/09/21 13:38:33 by jkoupy #+# #+# */
/* Updated: 2023/09/24 16:03:11 by jkoupy ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int isspec(char c)
{
return (c == 'c' || c == 's' || c == 'p'
|| c == 'd' || c == 'i' || c == 'u'
|| c == 'x' || c == 'X' || c == '%');
}
int isflag(char c)
{
return (c == ' ' || c == '#' || c == '+');
}
int is_correct_flag(const char *format, int *i)
{
return (((format[*i + 1] == '+' || format[*i + 1] == ' ')
&& (format[*i + 2] == 'd' || format[*i + 2] == 'i'))
|| (format[*i + 1] == '#'
&& (format[*i + 2] == 'x' || format[*i + 2] == 'X'))
|| (format[*i + 1] == ' ' && format[*i + 2] == 's')
|| (format[*i + 1] == ' ' && ft_isdigit(format[*i + 2])
&& format[*i + 3] == 's'));
}
int is_skip_flag(const char *format, int *i)
{
return (isflag(format[*i + 1]) && isspec(format[*i + 2]));
}