int ft_printf_arg(va_list ap, char *format, char **out) { int ret; char *opts; *out = NULL; opts = ft_strsub(format, 1, ft_flag_return(format)); *out = ft_strcmp(opts, "c") ? *out : ft_pf_c(ap, opts, &ret); *out = ft_strcmp(opts, "%") ? *out : ft_pf_c(ap, opts, &ret); *out = ft_strcmp(opts, "d") ? *out : ft_pf_d(ap, opts, &ret); *out = ft_strcmp(opts, "f") ? *out : ft_pf_f(ap, opts, &ret); *out = ft_strcmp(opts, "s") ? *out : ft_pf_s(ap, opts, &ret); *out = ft_strcmp(opts, "x") ? *out : ft_pf_x(ap, opts, &ret); *out = ft_strcmp(opts, "X") ? *out : ft_pf_x(ap, opts, &ret); *out = (*out == NULL) ? "" : *out; return (ret); }
int ft_printf_arg(va_list ap, char *format, char **out) { int ret; char *opts; *out = NULL; if ((opts = ft_strsub(format, 1, ft_flag_return(format))) == NULL) return (0); *out = (*out || ft_strcmp(opts, "c")) ? *out : ft_pf_c(ap, opts, &ret); *out = (*out || ft_strcmp(opts, "%")) ? *out : ft_pf_c(ap, opts, &ret); *out = (*out || ft_strcmp(opts, "d")) ? *out : ft_pf_d(ap, opts, &ret); *out = (*out || ft_strcmp(opts, "f")) ? *out : ft_pf_f(ap, opts, &ret); *out = (*out || ft_strcmp(opts, "s")) ? *out : ft_pf_s(ap, opts, &ret); *out = (*out || ft_strcmp(opts, "x")) ? *out : ft_pf_x(ap, opts, &ret); *out = (*out || ft_strcmp(opts, "X")) ? *out : ft_pf_x(ap, opts, &ret); *out = (*out == NULL) ? ft_strnew(0) : *out; ft_strdel(&opts); return (ret); }