void pf_options_setup(t_pf_flag *flags, char **s, va_list ap) { pf_set_flags(flags, s); pf_set_width(flags, s, ap); pf_set_accuracy(flags, s, ap); pf_set_conv_qual(flags, s); }
inline static char *pf_width(char *str, int width, int flags, char **src) { char *tmp; char *tmp2; char *out; char *c; int i; c = ""; tmp = ft_strnew(0); if ((**src == 'x' || **src == 'p') && flags & 256) c = "0x"; else if (**src == 'o' && flags & 256) c = (*str == '0' ? "" : "0"); else if ((*str == '-' || *str == '+') && (str += 1)) c = (*(str - 1) == '-' ? "-" : "+"); if ((i = (ft_strlen(str) + ft_strlen(c))) < width) tmp = pf_set_width(tmp, width, i, flags); tmp2 = tmp; if ((*str == ' ' && (flags & 1) && (c = " ") && str++) || (flags & 1)) tmp = ft_strjoin(c, tmp); else str = ft_strjoin(c, str); out = ((flags & 512) ? ft_strjoin(str, tmp) : ft_strjoin(tmp, str)); (flags & 1 ? ft_strdel(&tmp2) : ft_strdel(&str)); ft_strdel(&tmp); return (out); }