void		ft_deal_with_uint_conversion_part1(t_op *op, t_arg *lnk)
{
	if (ft_strncmp(op->mod, "hh", 2) == 0)
	{
		ft_putchar((unsigned char)lnk->ull);
		lnk->ps += 1;
	}
	else if (ft_strncmp(op->mod, "h", 1) == 0)
	{
		ft_putunbr((unsigned short)lnk->ull);
		lnk->ps += ft_strlen((char*)ft_uitoa((unsigned short)lnk->ull));
	}
	else if (ft_strncmp(op->mod, "ll", 2) == 0
			|| ft_strncmp(op->mod, "l", 1) == 0
			|| ft_strncmp(op->mod, "q", 1) == 0)
	{
		ft_putunbr((unsigned long)lnk->ull);
		lnk->ps += ft_strlen((char*)ft_uitoa((unsigned long)lnk->ull));
	}
	else
	{
		ft_putunbr((unsigned int)lnk->ull);
		lnk->ps += ft_strlen((char*)ft_uitoa((unsigned int)lnk->ull));
	}
}
Exemple #2
0
void		add_uint(t_string *string, unsigned int s)
{
	char *n;

	n = ft_uitoa(s);
	add_string(string, n, 1);
}
Exemple #3
0
int		convert_unsigned(va_list arg, t_infos *infos)
{
	unsigned long int	u;
	char				*ret;

	u = va_arg(arg, unsigned long int);
	if (infos->modif[0] == 'h' && infos->conv == 'u')
	{
		if (infos->modif[1] == 'h' && infos->conv == 'u')
			u = (unsigned char)u;
		else
			u = (unsigned short)u;
	}
	if (infos->conv == 'u' && is_modif(infos->modif[0]) == 0)
		ret = ft_uitoa((unsigned int)u);
	else
		ret = ft_uitoa_long(u);
	if (u == 0)
		ret = "0";
	if (infos->prec > 0 && (size_t)infos->prec > ft_strlen(ret))
		ret = add_prec(ret, infos->prec);
	if (infos->width > 0 && (size_t)infos->width > ft_strlen(ret))
		ret = add_width(ret, infos->width, infos->flag);
	if (u == 0 && (infos->prec == -2 || infos->prec == -3))
		ret = "";
	ft_putstr(ret);
	return (ft_strlen(ret));
}
Exemple #4
0
int		flag_u(void *donne, const char *format, int i, int count)
{
	if (format[i] == 'u')
	{
		ft_putunbr((unsigned int)donne);
		count += ft_strlen(ft_uitoa((unsigned int)donne));
	}
	return (count);
}
Exemple #5
0
int					ft_print_uint(unsigned int nbr, t_size *len)
{
	int		y;
	char	*str;

	y = 0;
	len->count += ft_strlen(ft_uitoa(nbr));
	while (y < len->precision - ft_strlen(ft_uitoa(nbr)))
	{
		if (len->precision > 9)
			ft_putchar(' ');
		else
			ft_putchar('0');
		y++;
	}
	str = ft_uitoa(nbr);
	ft_putstr(str);
	return (0);
}
Exemple #6
0
char		*flag_ul(t_string *string, short base)
{
	unsigned long int	tmp;

	tmp = get_ulong_int(string);
	string->is_negative = 0;
	if (base == 8)
		return (ft_uitoabase(tmp, "01234567"));
	else if (base == 10)
		return (ft_uitoa(tmp));
	else if (base == 16)
		return (ft_uitoabase(tmp, "0123456789abcdef"));
	else if (base == 32)
		return (ft_uitoabase(tmp, "0123456789ABCDEF"));
	return (NULL);
}
Exemple #7
0
static void	print_histo_item(t_ui i, char const *str)
{
	char					*temp;
	char					*aligned;

	temp = ft_uitoa(i);
	if (temp)
	{
		aligned = ft_format_align(temp, 4, AL_RIGHT);
		if (aligned)
		{
			ft_putstr(aligned);
			ft_putstr(" - ");
			ft_putendl(str);
			free(aligned);
		}
		free(temp);
	}
}
Exemple #8
0
unsigned int	ft_putnbr_hexa(char *str, unsigned int nb, char option,
								t_size *len)
{
	len->count += ft_strlen(str);
	if (len->precision != 0)
		ft_print_precision(len, (ft_strlen(ft_uitoa(nb)) + ft_strlen(str) - 2));
	ft_putstr(str);
	len->precision = 0;
	if (nb >= 16)
		ft_putnbr_hexa("", nb / 16, option, len);
	if (nb % 16 < 10)
	{
		ft_putchar_fd(nb % 16 + 48, 0);
		len->count += 1;
	}
	else
	{
		ft_putchar_fd(nb % 16 + option - 33, 0);
		len->count += 1;
	}
	return (nb);
}