minishell
parse_format.c File Reference
#include <stdlib.h>
#include <limits.h>
#include <stdint.h>
#include "ft_printf_local.h"
Include dependency graph for parse_format.c:

Go to the source code of this file.

Functions

t_listparse_format (const char *fmt, va_list *args)
 

Function Documentation

◆ parse_format()

t_list* parse_format ( const char *  fmt,
va_list *  args 
)

Definition at line 18 of file parse_format.c.

19 {
20  t_list *p_ret;
21  size_t ret_len;
22 
23  p_ret = NULL;
24  ret_len = 0;
25  while (*fmt != '\0' && ret_len < INT_MAX)
26  {
27  if (*fmt == '%')
28  ft_lstadd_back(&p_ret,
29  ft_lstnew(parse_opt(&ret_len, (char **)&fmt, args)));
30  else
31  ft_lstadd_back(&p_ret,
32  ft_lstnew(check_no_opt_str(&ret_len, (char **)&fmt, NULL)));
33  if (p_ret == NULL || ft_lstlast(p_ret)->content == NULL)
34  ret_len = UINTPTR_MAX;
35  }
36  if (ret_len >= INT_MAX)
37  ft_lstclear(&p_ret, free);
38  return (p_ret);
39 }
t_fmt * check_no_opt_str(size_t *len, char **fmt, t_fmt *p_ret)
void ft_lstadd_back(t_list **lst, t_list *new)
void ft_lstclear(t_list **lst, void(*del)(void *))
Definition: ft_lstclear.c:16
t_list * ft_lstnew(void *content)
Definition: ft_lstnew.c:16
t_list * ft_lstlast(t_list *lst)
Definition: ft_lstlast.c:16
t_fmt * parse_opt(size_t *len, char **fmt, va_list *args)
Definition: parse_opt.c:17
Definition: ft_lst.h:18
Here is the call graph for this function:
Here is the caller graph for this function: