Ejemplo n.º 1
0
int		ft_printxo(t_list *lst, int base, unsigned long long nb, int spaces)
{
	if (lst->minus)
	{
		if (lst->diese)
		{
			lst->result += diese_flag(lst);
			lst->result += ft_print_zeros(lst->precision,
					ft_baselen(nb, 0, base));
			ft_put_base(nb, base, lst);
			lst->result += (lst->precision > ft_baselen(nb, 0, base) ?
					ft_print_space(lst->size - lst->precision - base) :
					ft_print_space(lst->size - ft_baselen(nb, 0, base) -
						spaces));
			return (0);
		}
		lst->result += ft_print_zeros(lst->precision, ft_baselen(nb, 0, base));
		ft_put_base(nb, base, lst);
		lst->result += (lst->precision > ft_baselen(nb, 0, base) ?
				ft_print_space(lst->size - lst->precision) :
				ft_print_space(lst->size - ft_baselen(nb, 0, base)));
		return (0);
	}
	else
		ft_printxo2(lst, base, nb, spaces);
	return (0);
}
Ejemplo n.º 2
0
int		ft_printxo2(t_list *lst, int base, unsigned long long nb, int spaces)
{
	if (lst->diese && nb)
	{
		lst->result += (lst->precision > ft_baselen(nb, 0, base) ?
				ft_print_space(lst->size - lst->precision - base) :
				ft_print_space(lst->size - ft_baselen(nb, 0, base) -
					spaces));
		lst->result += diese_flag(lst);
		lst->result += ft_print_zeros(lst->precision -
				((base == 8) ? 1 : 0),
				ft_baselen(nb, 0, base));
		ft_put_base(nb, base, lst);
		return (0);
	}
	lst->result += ((lst->precision > ft_baselen(nb, 0, base)) ?
			ft_print_space(lst->size - lst->precision) :
			ft_print_space(lst->size - ft_baselen(nb, 0, base)));
	lst->result += ft_print_zeros(lst->precision, ft_baselen(nb, 0, base));
	if (lst->precision == 0 && lst->modified_precision && !lst->diese)
	{
		if ((lst->type != 'o' && lst->type != 'O') || lst->size != 0)
			lst->result += ft_print_char(' ');
		return (0);
	}
	ft_put_base(nb, base, lst);
	return (0);
}
Ejemplo n.º 3
0
void		ft_put_base(int nb, char *base)
{
	int		len;

	len = 0;
	while (base[len])
		len += 1;
	if (nb >= len)
	{
		ft_put_base(nb / len, base);
		ft_put_base(nb % len, base);
	}
	else
		ft_putchar(base[nb]);
}
Ejemplo n.º 4
0
int		ft_printxo_flag0(t_list *lst, int base, unsigned long long nb)
{
	if (lst->diese)
	{
		lst->result += diese_flag(lst);
		lst->result += ft_print_zeros(lst->size - (base == 8 ? 1 : 2),
				ft_baselen(nb, 0, base));
		ft_put_base(nb, base, lst);
	}
	else
	{
		lst->result += ft_print_zeros(lst->size, ft_baselen(nb, 0, base));
		ft_put_base(nb, base, lst);
	}
	return (0);
}
Ejemplo n.º 5
0
void	ft_put_base(unsigned int n, char *base)
{
	if (n < ft_strlenn(base))
		ft_putchar(base[n]);
	else
	{
		ft_put_base(n / ft_strlenn(base), base);
		ft_putchar(base[n % ft_strlenn(base)]);
	}
}