refactor: only the usefull header
- Removing all 'libft.h' mention - Using the include only on the files needed by
This commit is contained in:
parent
afb804195a
commit
905ffd4b72
48 changed files with 142 additions and 120 deletions
|
|
@ -6,18 +6,13 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/16 12:13:14 by rparodi #+# #+# */
|
||||
/* Updated: 2024/10/31 16:16:45 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/09/01 17:57:36 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
void _print_char(int fd, char c, int *ret_value);
|
||||
void _print_nbr(int fd, int nb, int *ret_value);
|
||||
void _print_base(\
|
||||
int fd, unsigned long long nbr, int *ret_value, char c);
|
||||
void _print_unsigned(int fd, unsigned int nb, int *ret_value);
|
||||
void _print_str(int fd, char *str, int *ret_value);
|
||||
#include "str.h"
|
||||
#include <limits.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void _print_char(int fd, char c, int *ret_value)
|
||||
{
|
||||
|
|
@ -25,6 +20,25 @@ void _print_char(int fd, char c, int *ret_value)
|
|||
(*ret_value)++;
|
||||
}
|
||||
|
||||
void _print_unsigned(int fd, unsigned int nb, int *ret_value)
|
||||
{
|
||||
if (nb >= 10)
|
||||
{
|
||||
_print_unsigned(fd, nb / 10, ret_value);
|
||||
nb = nb % 10;
|
||||
}
|
||||
if (nb < 10)
|
||||
_print_char(fd, nb + 48, ret_value);
|
||||
}
|
||||
|
||||
void _print_str(int fd, char *str, int *ret_value)
|
||||
{
|
||||
if (!str)
|
||||
*ret_value += write(fd, "(null)", 6);
|
||||
else
|
||||
*ret_value += write(fd, str, ft_strlen(str));
|
||||
}
|
||||
|
||||
void _print_nbr(int fd, int nb, int *ret_value)
|
||||
{
|
||||
if (nb < 0)
|
||||
|
|
@ -36,8 +50,7 @@ void _print_nbr(int fd, int nb, int *ret_value)
|
|||
return ;
|
||||
}
|
||||
nb = -nb;
|
||||
_print_char(fd, '-', ret_value);
|
||||
}
|
||||
_print_char(fd, '-', ret_value); }
|
||||
if (nb >= 10)
|
||||
{
|
||||
_print_nbr(fd, nb / 10, ret_value);
|
||||
|
|
@ -76,22 +89,3 @@ void _print_base(\
|
|||
_print_char(fd, base[nbr % 16], ret_value);
|
||||
}
|
||||
}
|
||||
|
||||
void _print_unsigned(int fd, unsigned int nb, int *ret_value)
|
||||
{
|
||||
if (nb >= 10)
|
||||
{
|
||||
_print_unsigned(fd, nb / 10, ret_value);
|
||||
nb = nb % 10;
|
||||
}
|
||||
if (nb < 10)
|
||||
_print_char(fd, nb + 48, ret_value);
|
||||
}
|
||||
|
||||
void _print_str(int fd, char *str, int *ret_value)
|
||||
{
|
||||
if (!str)
|
||||
*ret_value += write(fd, "(null)", 6);
|
||||
else
|
||||
*ret_value += write(fd, str, ft_strlen(str));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue