minishell
check_no_opt_str.c
Go to the documentation of this file.
1
/* ************************************************************************** */
2
/* */
3
/* ::: :::::::: */
4
/* check_no_opt_str.c :+: :+: :+: */
5
/* +:+ +:+ +:+ */
6
/* By: kfujita <kfujita@student.42tokyo.jp> +#+ +:+ +#+ */
7
/* +#+#+#+#+#+ +#+ */
8
/* Created: 2022/04/24 03:07:49 by kfujita #+# #+# */
9
/* Updated: 2022/04/26 00:21:26 by kfujita ### ########.fr */
10
/* */
11
/* ************************************************************************** */
12
13
#include <limits.h>
14
#include <stddef.h>
15
#include <stdlib.h>
16
#include "
ft_printf_local.h
"
17
#include "../ft_mem/ft_mem.h"
18
#include "../ft_math/ft_math.h"
19
20
t_fmt
*
check_no_opt_str
(
size_t
*len,
char
**fmt,
t_fmt
*p_ret)
21
{
22
size_t
str_len;
23
24
str_len = 0;
25
if
(p_ret == NULL)
26
p_ret =
ft_calloc
(1,
sizeof
(
t_fmt
));
27
if
(p_ret == NULL)
28
return
(p_ret);
29
p_ret->
type
=
STR
;
30
p_ret->
data
.
str
= *fmt;
31
while
(*len <= INT_MAX && **fmt !=
'\0'
&& **fmt !=
'%'
)
32
{
33
str_len++;
34
*len += 1;
35
*fmt += 1;
36
}
37
if
(*len > INT_MAX)
38
{
39
free(p_ret);
40
return
(NULL);
41
}
42
p_ret->
str_len
= (int)str_len;
43
*len +=
ft_max
(p_ret->
min_len
, p_ret->
str_len
);
44
return
(p_ret);
45
}
check_no_opt_str
t_fmt * check_no_opt_str(size_t *len, char **fmt, t_fmt *p_ret)
Definition:
check_no_opt_str.c:20
ft_calloc
void * ft_calloc(size_t count, size_t size)
Definition:
ft_calloc.c:29
ft_max
int ft_max(int a, int b)
Definition:
ft_max.c:16
ft_printf_local.h
STR
@ STR
Definition:
ft_printf_local.h:28
t_fmt
Definition:
ft_printf_local.h:48
t_fmt::type
t_dtype type
Definition:
ft_printf_local.h:49
t_fmt::data
t_data data
Definition:
ft_printf_local.h:50
t_fmt::str_len
int str_len
Definition:
ft_printf_local.h:53
t_fmt::min_len
int min_len
Definition:
ft_printf_local.h:54
t_data::str
char * str
Definition:
ft_printf_local.h:39
libft
ft_printf
check_no_opt_str.c
Generated by
1.9.1