norm for ft_printf
This commit is contained in:
parent
6caf5060ec
commit
64bde00bb8
8 changed files with 18 additions and 36 deletions
|
|
@ -15,8 +15,6 @@ t_fmt *ft_printf_parse(char **format, va_list ap)
|
|||
ft_fmt_validate_flags(fmt);
|
||||
ft_fmt_simplify(fmt);
|
||||
fmt->valid = ft_fmt_validate_conversion(fmt) ? 0 : 1;
|
||||
|
||||
/* ft_fmt_print(fmt); */
|
||||
return (fmt);
|
||||
}
|
||||
|
||||
|
|
@ -25,7 +23,6 @@ void ft_printf_parse_flags(t_fmt *fmt, char **format)
|
|||
int i;
|
||||
char *str;
|
||||
|
||||
|
||||
i = 0;
|
||||
str = *format;
|
||||
while (str[i])
|
||||
|
|
@ -40,8 +37,6 @@ void ft_printf_parse_flags(t_fmt *fmt, char **format)
|
|||
i++;
|
||||
}
|
||||
*format += i;
|
||||
/* printf("\nparse_flags: %s\n", *format); */
|
||||
/* fflush(stdout); */
|
||||
}
|
||||
|
||||
void ft_printf_parse_width(t_fmt *fmt, char **format, va_list ap)
|
||||
|
|
@ -65,9 +60,6 @@ void ft_printf_parse_width(t_fmt *fmt, char **format, va_list ap)
|
|||
fmt->width = ft_atoi(buf);
|
||||
}
|
||||
*format += i;
|
||||
/* printf("found width: %i\n", fmt->width); */
|
||||
/* printf("\nparse_nums: %s\n", *format); */
|
||||
/* fflush(stdout); */
|
||||
}
|
||||
|
||||
void ft_printf_parse_precision(t_fmt *fmt, char **format, va_list ap)
|
||||
|
|
@ -93,7 +85,6 @@ void ft_printf_parse_precision(t_fmt *fmt, char **format, va_list ap)
|
|||
fmt->precision = ft_atoi(buf);
|
||||
}
|
||||
}
|
||||
/* printf("found preci: %i\n", fmt->precision); */
|
||||
*format += i;
|
||||
}
|
||||
|
||||
|
|
@ -118,6 +109,4 @@ void ft_printf_parse_modifiers(t_fmt *fmt, char **format)
|
|||
else
|
||||
ft_strcpy(fmt->modifier, "");
|
||||
*format += ft_strlen(fmt->modifier);
|
||||
/* printf("\nparse_mods: %s\n", *format); */
|
||||
/* fflush(stdout); */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@ char *ft_transform(t_fmt *fmt, va_list ap)
|
|||
ret = (char *)malloc(sizeof(char) * (fmt->width + 5));
|
||||
ft_strcpy(ret, buf);
|
||||
}
|
||||
/* printf("before padding: '%s'\n", ret); */
|
||||
/* fflush(stdout); */
|
||||
if (ft_strchr(fmt->flags, '-'))
|
||||
ft_pad_right(ret, fmt);
|
||||
else
|
||||
|
|
@ -6,11 +6,6 @@ t_fmt *ft_fmt_init(void)
|
|||
|
||||
fmt = (t_fmt *)malloc(sizeof(t_fmt) + 1);
|
||||
ft_bzero(fmt->flags, 6);
|
||||
/* fmt->flags.hash = 0; */
|
||||
/* fmt->flags.zero = 0; */
|
||||
/* fmt->flags.minus = 0; */
|
||||
/* fmt->flags.space = 0; */
|
||||
/* fmt->flags.plus = 0; */
|
||||
ft_bzero(fmt->modifier, 3);
|
||||
fmt->conversion = '\0';
|
||||
fmt->width = 0;
|
||||
|
|
@ -21,13 +16,19 @@ t_fmt *ft_fmt_init(void)
|
|||
|
||||
void ft_fmt_print(t_fmt *fmt)
|
||||
{
|
||||
printf("\n---\n");
|
||||
printf("valid: %i\n", fmt->valid);
|
||||
printf("flags: %s\n", fmt->flags);
|
||||
printf("width: %i\n", fmt->width);
|
||||
printf("prec.: %i\n", fmt->precision);
|
||||
printf("modif: %s\n", fmt->modifier);
|
||||
printf("conv.: %c\n", fmt->conversion);
|
||||
printf("---\n");
|
||||
fflush(stdout);
|
||||
ft_putendl("\n---");
|
||||
ft_putstr("valid: ");
|
||||
ft_putnbr(fmt->valid);
|
||||
ft_putendl("");
|
||||
ft_putstr("flags: ");
|
||||
ft_putendl(fmt->flags);
|
||||
ft_putstr("width: ");
|
||||
ft_putnbr(fmt->width);
|
||||
ft_putendl("");
|
||||
ft_putstr("prec.: ");
|
||||
ft_putnbr(fmt->precision);
|
||||
ft_putendl("");
|
||||
ft_putstr("modifier: ");
|
||||
ft_putendl(fmt->modifier);
|
||||
ft_putendl("---");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
void ft_pad_right(char *str, t_fmt *fmt)
|
||||
{
|
||||
if (strchr(fmt->flags, '#'))
|
||||
if (ft_strchr(fmt->flags, '#'))
|
||||
(fmt->conv.sharp_func)(str, fmt);
|
||||
while ((int)ft_strlen(str) < fmt->width)
|
||||
ft_strcat(str, " ");
|
||||
|
|
@ -31,7 +31,7 @@ void ft_pad_left(char *str, t_fmt *fmt)
|
|||
}
|
||||
if (sign)
|
||||
str--;
|
||||
if (strchr(fmt->flags, '#'))
|
||||
if (ft_strchr(fmt->flags, '#'))
|
||||
(fmt->conv.sharp_func)(str, fmt);
|
||||
while ((int)ft_strlen(str) < fmt->width)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@ char *ft_uitoa_base(unsigned int nbr, char *base)
|
|||
int base_size;
|
||||
char *str;
|
||||
|
||||
/* printf("converting %llu to base %s\n", nbr, base); */
|
||||
/* fflush(stdout); */
|
||||
i = 0;
|
||||
base_size = ft_strlen(base);
|
||||
str = ft_strnew(ft_size(nbr, base_size) + 1);
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@ char *ft_ulltoa_base(unsigned long long nbr, char *base)
|
|||
int base_size;
|
||||
char *str;
|
||||
|
||||
/* printf("converting %llu to base %s\n", nbr, base); */
|
||||
/* fflush(stdout); */
|
||||
i = 0;
|
||||
base_size = ft_strlen(base);
|
||||
str = ft_strnew(ft_size(nbr, base_size) + 1);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@
|
|||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
#include <stdio.h>
|
||||
|
||||
void ft_debug(void)
|
||||
{
|
||||
|
|
@ -19,5 +18,4 @@ void ft_debug(void)
|
|||
|
||||
n++;
|
||||
ft_printf("----------\n check %02i\n----------\n", n);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ int ft_xattr_print(char *path)
|
|||
if (valuelen == -1)
|
||||
ft_printf("couldn't get value\n");
|
||||
else
|
||||
printf("%s:\n%s\n", list + i, value);
|
||||
ft_printf("%s:\n%s\n", list + i, value);
|
||||
i += ft_strlen(list) + 1;
|
||||
}
|
||||
return (0);
|
||||
|
|
|
|||
Loading…
Reference in a new issue