int ishexaoctacasdemerde(t_opts *opts) { if ((ishexa(opts) && opts->flags['#'] && !opts->flags['0']) || (isocta(opts) && opts->flags['#'] && !opts->flags['0'])) return (1); return (0); }
char *render_opts_numeric_unsigned(t_opts *opts, va_list *pa) { uintmax_t n; char *s; n = render_opts_numeric_unsigned_get(opts, pa); s = render_opts_numeric_uitoa(opts, n); if (isocta(opts) && opts->precision && opts->precisionn) { s = applyflag(opts, s); s = applyprecision(opts, s); s = applywidth(opts, s); } else if (ishexaoctacasdemerde(opts)) { s = applyprecision(opts, s); s = applyflag(opts, s); s = applywidth(opts, s); } else { s = applyprecision(opts, s); s = applywidth(opts, s); s = applyflag(opts, s); } return (s); }
char *applywidth(t_opts *opts, char *str) { int length; int way; char c; c = ' '; way = 0; if (isptrand0orishexaandsharpand0(opts)) opts->width = opts->width - 2; if (isocta(opts) && opts->flags['#'] && opts->flags['0']) opts->width = opts->width - 1; if (opts->flags['-']) way = 1; else if (opts->flags['0']) c = '0'; length = ft_strlen(str); if (str[0] == '\0' && opts->type == 'c') length = 1; if (opts->width > length) { if (issigned(opts) && opts->flags['0'] && !opts->flags['-']) str = straddncharsigned(str, opts->width - length, c); else str = straddnchar(str, way, opts->width - length, c); } return (str); }