Esempio n. 1
0
void		get_flag(char *str, t_data *data)
{
	int		i;
	char	*flag;

	flag = "#0-+ ";
	i = -1;
	data->len_for = ft_strlen(str) + 1;
	while (ft_strpos(flag, str[++i]) > -1 && str[i])
		data->flag = data->flag | ft_pow(2, ft_strpos(flag, str[i]));
	if (ft_isdigit(str[i]))
		data->field = ft_atoi(str + i);
	while (ft_isdigit(str[i]))
		i++;
	if (str[i] == '.')
	{
		i++;
		data->prec = ft_atoi(str + i);
	}
	while (ft_isdigit(str[i]))
		i++;
	data->len_mod = get_len_mod(str + i);
	if ((data->flag & 2) > 0 && (data->flag & 4) > 0)
		data->flag = data->flag - 2;
	if ((data->flag & 8) > 0 && (data->flag & 16) > 0)
		data->flag = data->flag - 16;
}
Esempio n. 2
0
static unsigned int	ft_atoui_base(char *s, char *base)
{
	unsigned int	abs;
	unsigned int	total;

	while (ft_isspace(*s))
		s++;
	abs = 1;
	if (*s == '-')
		abs = -1 * (*s++ == '-');
	else if (*s == '+')
		s++;
	total = 0;
	while (ft_strpos(base, *s) != ~(!abs))
		total = total * ft_strlen(base) + ft_strpos(base, *s++);
	return (total * abs);
}
Esempio n. 3
0
static int	ft_atoi_base_rec(const char *str, int sign, \
		const char *base, int basen)
{
	int ret;
	int i;
	int j;

	j = 0;
	ret = 0;
	while (str[j] && (i = ft_strpos(base, str[j])) < basen)
	{
		if (sign == -1)
			ret = ret * basen - i;
		else
			ret = ret * basen + i;
		j++;
	}
	return (ret);
}