Beispiel #1
0
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);
}
Beispiel #2
0
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);
}
Beispiel #3
0
int	printf_ls(int fd, t_print_param *pp, wchar_t *s)
{
	int total;
	int arg_size;

	total = 0;
	arg_size = ft_wstrlen(s);
	if (pp->precision != -1)
		arg_size = pp->precision < arg_size ? pp->precision : arg_size;
	if ((pp->flags & PRINT_FLAG_LESS) == 0)
		while (total < pp->field_width - arg_size)
			total += ft_putchar(fd, pp->flags & PRINT_FLAG_ZERO ? '0' : ' ');
	total += ft_putnwstr(fd, s, pp->precision);
	while (total < pp->field_width)
		total += ft_putchar(fd, ' ');
	return (total);
}
Beispiel #4
0
ssize_t	handle_wstr(char **format, va_list *args, t_arg *arg)
{
	wchar_t	*str;
	size_t	strlen;

	(void)format;
	(void)arg;
	str = va_arg(*args, wchar_t*);
	if (str == NULL)
		str = L"(null)";
	strlen = arg->got_precision ? calc_wstrlen(str, arg->precision, 0) :
			ft_wstrlen(str);
	if (arg->got_width && !arg->right_pad)
		width_pad(strlen, arg->width, arg->pad_zeroes ? '0' : ' ');
	ft_putnwstr(str, strlen);
	if (arg->got_width && arg->right_pad)
		width_pad(strlen, arg->width, ' ');
	return (arg->got_width ? FT_MAX(strlen, arg->width) : strlen);
}
Beispiel #5
0
static int			ft_ret_wstr(t_args *arg, wchar_t *wstr)
{
	int		ret;

	ret = ft_ret_nwstr(wstr, arg->precis);
	if (arg->field > arg->precis)
	{
		if (arg->val_field && !arg->val_minus && arg->val_z)
			ft_printnchar(arg->field - ret, '0');
		if (arg->val_field && !arg->val_minus && !arg->val_z)
		{
			if (arg->precis == 0)
				ft_printnchar(arg->field, ' ');
			else
				ft_printnchar(arg->field - ret, ' ');
		}
	}
	ret = ft_putnwstr(wstr, arg->precis);
	if (arg->val_field == 1 && arg->val_minus == 1)
		ft_printnchar(arg->field - arg->precis, ' ');
	(arg->val_field == 0) ? ret = ft_ret_nwstr(wstr, arg->precis) : 0;
	return (ret);
}