static int precision_handling_minus_ls(t_env *env, wchar_t *s, int precision) { int size; size = 0; if (precision >= 0 && precision < (int)ft_strwlen(s)) { size += ft_putwstr_part(s, precision); size += print_width_s(env->width->value - precision, env); } else { size += ft_putwstr(s); size += print_width_s(env->width->value - ft_strwlen(s), env); } return (size); }
static int string_prec_l(t_struct data, wchar_t *str, size_t k) { size_t i; size_t j; i = 0; j = str == NULL ? 0 : (int)ft_strwlen(str); while (k < (data.min - j > 0 ? 0 : data.min - j)) k += pf_putchar(data.flag & 2 ? '0' : ' '); if (data.prec != -1) while (i < ((size_t)data.prec > j ? j : data.prec) && str[i]) k += pf_putcharuni(str[i++]); return (k); }
int print_wstring(t_tag *tag, wchar_t *str) { int str_len; str_len = tag->has_precision ? ft_strnwlen(str, tag->precision) : ft_strwlen(str); if (tag->has_width && !tag->flag_minus) print_width_pad(str_len, tag->width, tag->flag_zero ? '0' : ' '); ft_putnwstr(str, str_len); if (tag->has_width && tag->flag_minus) print_width_pad(str_len, tag->width, ' '); return (tag->has_width ? ft_max(tag->width, str_len) : str_len); }
void ft_putwstr(t_add *flag, wchar_t const *s) { int i; wchar_t *str; if (!s) str = ft_strwdup(L"(null)"); else str = ft_strwdup(s); i = 0; if (flag->max < 0 && flag->prflag != -1) while ((int)ft_strwlen(str) < flag->min--) ft_putwchar(L' ', flag); else if (flag->prflag != -1) while (flag->max < flag->min--) ft_putwchar(L' ', flag); if (flag->max < 0) flag->max = ft_strwlen(str); while (str[i] != L'\0' && i < flag->max) ft_putwchar(str[i++], flag); if (flag->prflag == -1 || i < ++flag->min) while (i++ < flag->min) ft_putwchar(L' ', flag); }
static int string_min_l(t_struct data, wchar_t *str, size_t k) { int i; size_t j; size_t l; j = str == NULL ? 0 : (int)ft_strwlen(str); i = 0; l = (size_t)data.prec; if (data.prec != -1) while (k < j && (data.prec == 0 ? k < j : k < l) && str[i]) k += pf_putcharuni(str[i++]); while (k < (size_t)data.min) k += pf_putchar(data.flag & 2 ? '0' : ' '); return (k); }
void call_putwstr(t_data *data) { int *str; t_specify *spec; spec = &data->spec; str = va_arg(*data->ap, int *); if (!str) str = L"(null)"; data->spec.nb_len = ft_strwlen(str); if (spec->dot == true && spec->dot_value < spec->nb_len) spec->nb_len = ft_strnwlen(str, spec->dot_value); before_printing_s(data, &data->spec); data->ret += ft_putnwstr(str, spec->nb_len); after_printing_s(data, &data->spec); }
static int string_size_l(t_struct data, wchar_t *str, size_t k) { size_t i; size_t j; size_t l; size_t m; j = str == NULL ? 0 : (int)ft_strwlen(str); i = 0; m = (size_t)data.min; l = (size_t)data.prec; if (data.prec == 0) while (k < data.min - j) k += pf_putchar(data.flag & 2 ? '0' : ' '); else while (k < (size_t)data.min - (l > j ? j : data.prec) && k < m) k += pf_putchar(data.flag & 2 ? '0' : ' '); if (j > 0 && data.prec != -1) while (i < j && (data.prec == 0 ? i < j : i < l) && str[i]) k += pf_putcharuni(str[i++]); return (k); }