int ft_printf(const char *format, ...) { va_list pa; int i; int r_val; i = -1; r_val = 0; va_start(pa, format); if (format == NULL) return (-1); while (format[++i]) { (format[i] == '{') ? ft_color(format, &i) : 0; if (!format[i] || (format[i] == '%' && ft_undef(format, i + 1) == 0)) return (r_val); format[i] == '%' && format[i + 1] == '\0' ? r_val-- : 0; format[i] == '%' ? 0 : ft_putchar(format[i]); if (format[i] == '%' && format[i + 1] && ft_undef(format, i + 1) && (i = ft_printf_conv((char *)format, &pa, &r_val, i + 1)) == -1) return (-1); r_val++; } va_end(pa); return (r_val); }
static inline const char *ft_printf_exec(const char *str, t_printf *pf) { size_t seek; if (*str == '%') { ft_pf_conv_percent(pf); return (str + 1); } seek = 0; while ((*str) && (!ft_strany(*str, FT_PF_CONVERTS))) { if (!(seek = ft_printf_loadall(pf, str))) break ; str += seek; } if (*str) { ft_printf_conv(pf, *str); return (str + 1); } return (str); }