Example #1
0
int			ft_printf(const char *format, ...)
{
	int			count;
	int			i;
	va_list		ap;

	count = 0;
	i = 1;
	va_start(ap, format);
	while (format[i - 1])
	{
		if ((format[i - 1] != '%'
			|| (format[i - 1] == '%' && format[i] == '%')) && format[i - 1])
		{
			count += ft_putchar(format[i - 1]);
			i++;
		}
		else if (ft_strchr("csndifxXpoEebulLztT#", format[i]))
			ft_flags1(format, &ap, &i, &count);
		else if (ft_strchr("*.+$^123456789", format[i]))
			ft_flags2(format, &ap, &i, &count);
		else
			i++;
	}
	va_end(ap);
	return (count);
}
Example #2
0
void				ft_init_flags(char **str, struct s_flags *flags, int *x)
{
	if (str[*x][2] != '\0')
		ft_usage();
	if (ft_flags2(str, flags, x) && ft_flags(str, flags, x))
	{
		ft_usage();
		exit(EXIT_FAILURE);
	}
	(*x)++;
	if (str[*x] && str[*x][0] == '-')
		ft_init_flags(str, flags, x);
}
Example #3
0
static void		ft_opt2(const char *form, va_list *ap, int *i, int *count)
{
	int			j;
	va_list		apcpy;

	j = 0;
	va_copy(apcpy, *ap);
	(*i)++;
	while (ft_strchr(".* 0123456789", form[*i]))
	{
		j++;
		(*i)++;
	}
	ft_opt2_b(form, apcpy, i, count);
	*i -= j;
	if (ft_strchr(".*+", form[*i]))
		ft_flags2(form, ap, i, count);
	else
		ft_flags1(form, ap, i, count);
}