This commit is contained in:
whaffman 2024-10-29 11:49:54 +01:00
parent a203ec9581
commit c9e0ff7559
7 changed files with 9 additions and 18 deletions

View File

@ -19,7 +19,6 @@ int parse_conversion(const char **format, va_list args)
{
int wrote;
wrote = 0;
if (**format == 'c')
wrote = print_char(args);
else if (**format == 's')
@ -34,5 +33,7 @@ int parse_conversion(const char **format, va_list args)
wrote = print_hex(args, 0);
else if (ft_strchr("X", **format))
wrote = print_hex(args, 1);
else
wrote = -1;
return (wrote);
}

View File

@ -21,7 +21,6 @@ int parse_placeholder(const char **format, va_list args)
int wrote;
(*format)++;
wrote = 0;
while (**format && !ft_strchr(conversions, **format))
(*format)++;
if (**format == '%')

View File

@ -23,10 +23,9 @@ int print_hex(va_list args, int uppercase)
char *str;
int wrote;
wrote = 0;
str = ft_calloc(sizeof(char), 20);
if (!str)
return (wrote);
return (-1);
n = va_arg(args, unsigned int);
if (uppercase)
ft_putnbr_base(n, "0123456789ABCDEF", str);

View File

@ -23,10 +23,9 @@ int print_number(va_list args)
char *str;
int wrote;
wrote = 0;
str = ft_calloc(sizeof(char), 12);
if (!str)
return (wrote);
return (-1);
n = va_arg(args, int);
ft_putnbr_signed(n, "0123456789", str);
len = ft_strlen(str);

View File

@ -22,17 +22,13 @@ int print_pointer(va_list args)
size_t len;
char *str;
int wrote;
wrote = 0;
n = va_arg(args, unsigned long);
if (!n)
{
write(1, "(nil)", 5);
return (5);
}
return (write(1, "(nil)", 5));
str = ft_calloc(sizeof(char), 20);
if (!str)
return (wrote);
return (-1);
ft_strlcpy(str, "0x", 3);
ft_putnbr_base(n, "0123456789abcdef", str);
len = ft_strlen(str);

View File

@ -22,10 +22,7 @@ int print_string(va_list args)
str = va_arg(args, char *);
if (!str)
{
write(1, "(null)", 6);
return (6);
}
return (write(1, "(null)", 6));
len = ft_strlen(str);
return (write(1, str, len));
}

View File

@ -26,7 +26,7 @@ int print_unumber(va_list args)
wrote = 0;
str = ft_calloc(sizeof(char), 12);
if (!str)
return (wrote);
return (-1);
n = va_arg(args, unsigned int);
ft_putnbr_base(n, "0123456789", str);
len = ft_strlen(str);