hidden norm cleanup

This commit is contained in:
Tanguy MAZE 2019-03-16 17:50:27 +01:00
parent d49f964045
commit acf5431d14
12 changed files with 104 additions and 106 deletions

View File

@ -6,12 +6,12 @@
# By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ # # By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ # # +#+#+#+#+#+ +#+ #
# Created: 2018/04/07 12:47:06 by tmaze #+# #+# # # Created: 2018/04/07 12:47:06 by tmaze #+# #+# #
# Updated: 2019/03/07 22:26:45 by tmaze ### ########.fr # # Updated: 2019/03/16 16:26:40 by tmaze ### ########.fr #
# # # #
#******************************************************************************# #******************************************************************************#
CC = gcc CC = gcc
CCFLAGS = -Wall -Werror -Wextra -g CCFLAGS = -Wall -Werror -Wextra
CCSTD = CCSTD =
NAME = libft.a NAME = libft.a

View File

@ -6,7 +6,7 @@
/* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */ /* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/05 13:50:22 by tmaze #+# #+# */ /* Created: 2018/04/05 13:50:22 by tmaze #+# #+# */
/* Updated: 2018/04/09 10:04:51 by tmaze ### ########.fr */ /* Updated: 2019/03/16 15:37:42 by tmaze ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -19,7 +19,7 @@ int ft_atoi(const char *str)
int ret; int ret;
nbnum = 0; nbnum = 0;
while (str[nbnum] == ' ' || str[nbnum] == '\t' || str[nbnum] == '\n'\ while (str[nbnum] == ' ' || str[nbnum] == '\t' || str[nbnum] == '\n'
|| str[nbnum] == '\v' || str[nbnum] == '\f' || str[nbnum] == '\r') || str[nbnum] == '\v' || str[nbnum] == '\f' || str[nbnum] == '\r')
nbnum++; nbnum++;
if (str[nbnum] == '+' || str[nbnum] == '-') if (str[nbnum] == '+' || str[nbnum] == '-')

View File

@ -6,7 +6,7 @@
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */ /* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2019/02/27 11:58:44 by tmaze #+# #+# */ /* Created: 2019/02/27 11:58:44 by tmaze #+# #+# */
/* Updated: 2019/02/28 16:12:07 by tmaze ### ########.fr */ /* Updated: 2019/03/16 15:47:50 by tmaze ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -29,8 +29,8 @@ int ft_atois(const char *str, int *nb)
num--; num--;
*nb = 0; *nb = 0;
mult = 1; mult = 1;
while (num >= 0 && ft_isdigit(str[num]) && while (num >= 0 && ft_isdigit(str[num])
(ft_abs(max - *nb) >= 2000000000)) && (ft_abs(max - *nb) >= 2000000000))
{ {
*nb += (str[num--] - '0') * mult; *nb += (str[num--] - '0') * mult;
mult *= 10; mult *= 10;

View File

@ -6,9 +6,8 @@
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */ /* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2019/03/08 13:44:31 by tmaze #+# #+# */ /* Created: 2019/03/08 13:44:31 by tmaze #+# #+# */
/* Updated: 2019/03/08 14:11:38 by tmaze ### ########.fr */ /* Updated: 2019/03/16 15:33:26 by tmaze ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "libft.h" #include "libft.h"

View File

@ -6,16 +6,12 @@
/* By: klebon <klebon@student.42.fr> +#+ +:+ +#+ */ /* By: klebon <klebon@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2018/05/18 18:10:11 by klebon #+# #+# */ /* Created: 2018/05/18 18:10:11 by klebon #+# #+# */
/* Updated: 2019/03/07 22:25:11 by tmaze ### ########.fr */ /* Updated: 2019/03/16 15:53:50 by tmaze ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "libft.h" #include "libft.h"
/*
** I have to handle minus, width
*/
void ft_align_wchar(char *str, t_conv *field) void ft_align_wchar(char *str, t_conv *field)
{ {
int i; int i;

View File

@ -6,7 +6,7 @@
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */ /* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/07 16:30:47 by tmaze #+# #+# */ /* Created: 2018/04/07 16:30:47 by tmaze #+# #+# */
/* Updated: 2019/03/07 19:05:27 by tmaze ### ########.fr */ /* Updated: 2019/03/16 15:39:59 by tmaze ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -17,8 +17,8 @@ char *ft_strjoin(char const *s1, char const *s2)
char *ret; char *ret;
ret = NULL; ret = NULL;
if (s1 != NULL && s2 != NULL &&\ if (s1 != NULL && s2 != NULL
(ret = ft_strnew(ft_strlen(s1) + ft_strlen(s2))) != NULL) && (ret = ft_strnew(ft_strlen(s1) + ft_strlen(s2))) != NULL)
{ {
ft_strcpy(ret, s1); ft_strcpy(ret, s1);
ft_strcat(ret, s2); ft_strcat(ret, s2);

View File

@ -6,7 +6,7 @@
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */ /* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/08 14:32:30 by tmaze #+# #+# */ /* Created: 2018/04/08 14:32:30 by tmaze #+# #+# */
/* Updated: 2018/04/08 15:15:34 by tmaze ### ########.fr */ /* Updated: 2019/03/16 15:45:42 by tmaze ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -22,6 +22,6 @@ size_t ft_strlcat(char *dest, const char *src, size_t size)
ft_strncpy(&dest[dest_len], src, size - dest_len); ft_strncpy(&dest[dest_len], src, size - dest_len);
dest[size - 1] = '\0'; dest[size - 1] = '\0';
} }
return (((size_t)dest_len < size) ? (size_t)(dest_len + ft_strlen(src)) :\ return (((size_t)dest_len < size) ? (size_t)(dest_len + ft_strlen(src))
size + (size_t)ft_strlen(src)); : size + (size_t)ft_strlen(src));
} }

View File

@ -6,7 +6,7 @@
/* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */ /* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/05 13:04:21 by tmaze #+# #+# */ /* Created: 2018/04/05 13:04:21 by tmaze #+# #+# */
/* Updated: 2018/04/08 14:05:37 by tmaze ### ########.fr */ /* Updated: 2019/03/16 15:50:07 by tmaze ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -21,8 +21,8 @@ int ft_strncmp(const char *s1, const char *s2, size_t n)
diff = 0; diff = 0;
if (n > 0) if (n > 0)
diff = (unsigned char)s1[0] - (unsigned char)s2[0]; diff = (unsigned char)s1[0] - (unsigned char)s2[0];
while ((unsigned int)i < n && diff == 0 && (unsigned char)s1[i - 1] &&\ while ((unsigned int)i < n && diff == 0 && (unsigned char)s1[i - 1]
(unsigned char)s2[i - 1]) && (unsigned char)s2[i - 1])
{ {
diff = (unsigned char)s1[i] - (unsigned char)s2[i]; diff = (unsigned char)s1[i] - (unsigned char)s2[i];
i++; i++;

View File

@ -6,7 +6,7 @@
/* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */ /* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/05 11:35:03 by tmaze #+# #+# */ /* Created: 2018/04/05 11:35:03 by tmaze #+# #+# */
/* Updated: 2018/04/08 15:28:28 by tmaze ### ########.fr */ /* Updated: 2019/03/16 15:52:25 by tmaze ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -25,7 +25,7 @@ char *ft_strnstr(const char *haystack, const char *needle, size_t len)
while ((++i == 0 || tmp[i - 1]) && i < (int)len) while ((++i == 0 || tmp[i - 1]) && i < (int)len)
if (tmp[i] == needle[0] && (j = 1)) if (tmp[i] == needle[0] && (j = 1))
{ {
while (tmp[i + j] == needle[j] && needle[j] && tmp[i + j]\ while (tmp[i + j] == needle[j] && needle[j] && tmp[i + j]
&& (i + j) < (int)len) && (i + j) < (int)len)
j++; j++;
if (needle[j] == '\0') if (needle[j] == '\0')

View File

@ -6,7 +6,7 @@
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */ /* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2019/02/25 16:25:18 by tmaze #+# #+# */ /* Created: 2019/02/25 16:25:18 by tmaze #+# #+# */
/* Updated: 2019/02/28 16:22:02 by tmaze ### ########.fr */ /* Updated: 2019/03/09 15:13:49 by tmaze ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -70,7 +70,7 @@ char **ft_strsplitwhitespace(char *s)
if (s != NULL) if (s != NULL)
{ {
nb_words = count_words_ws(s); nb_words = count_words_ws(s);
if ((tab = (char**)malloc(sizeof(char**) * (nb_words + 1))) == NULL) if ((tab = (char**)malloc(sizeof(char*) * (nb_words + 1))) == NULL)
return (NULL); return (NULL);
tab[nb_words] = NULL; tab[nb_words] = NULL;
return (get_table_ws(s, tab)); return (get_table_ws(s, tab));

View File

@ -6,7 +6,7 @@
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */ /* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/24 18:08:15 by tmaze #+# #+# */ /* Created: 2018/04/24 18:08:15 by tmaze #+# #+# */
/* Updated: 2018/06/07 16:55:21 by tmaze ### ########.fr */ /* Updated: 2019/03/16 15:53:27 by tmaze ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -61,16 +61,16 @@ static int read_gnl(const int fd, char **buff, char **line)
if ((tmp = ft_strnew(BUFF_SIZE)) == NULL) if ((tmp = ft_strnew(BUFF_SIZE)) == NULL)
return (-1); return (-1);
while (ft_strrnchr(*buff, '\n', BUFF_SIZE) == NULL &&\ while (ft_strrnchr(*buff, '\n', BUFF_SIZE) == NULL
(ret = read(fd, tmp, BUFF_SIZE)) > 0) && (ret = read(fd, tmp, BUFF_SIZE)) > 0)
if (supercat(buff, &tmp) == NULL) if (supercat(buff, &tmp) == NULL)
{ {
ft_strdel(&tmp); ft_strdel(&tmp);
return (-1); return (-1);
} }
ft_strdel(&tmp); ft_strdel(&tmp);
if (buff != NULL && *buff != NULL &&\ if (buff != NULL && *buff != NULL
ft_strrnchr(*buff, '\n', BUFF_SIZE) != NULL) && ft_strrnchr(*buff, '\n', BUFF_SIZE) != NULL)
return (get_next_line(fd, line)); return (get_next_line(fd, line));
else else
return (check_buff(buff, line)); return (check_buff(buff, line));

View File

@ -6,7 +6,7 @@
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */ /* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/08 00:12:36 by tmaze #+# #+# */ /* Created: 2018/04/08 00:12:36 by tmaze #+# #+# */
/* Updated: 2019/03/08 13:27:16 by tmaze ### ########.fr */ /* Updated: 2019/03/15 14:48:19 by tmaze ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -23,6 +23,7 @@
# define FT_RESET "\x1b[0m" # define FT_RESET "\x1b[0m"
# define FT_BOLD "\x1b[1m" # define FT_BOLD "\x1b[1m"
# define FT_CLEAR "\x1b[2J"
# define FT_COLOR_BLACK "\x1b[30m" # define FT_COLOR_BLACK "\x1b[30m"
# define FT_COLOR_RED "\x1b[31m" # define FT_COLOR_RED "\x1b[31m"
@ -138,7 +139,8 @@ void set_malloc_sizes(uintmax_t nb, t_conv *field);
void set_malloc_sizeu(uintmax_t nb, t_conv *field); void set_malloc_sizeu(uintmax_t nb, t_conv *field);
void set_malloc_sizeo(uintmax_t nb, t_conv *field); void set_malloc_sizeo(uintmax_t nb, t_conv *field);
void set_malloc_sizeu(uintmax_t nb, t_conv *field); void set_malloc_sizeu(uintmax_t nb, t_conv *field);
int set_malloc_sizef(long double nb, char *nbrstr, t_conv *field); int set_malloc_sizef(long double nb, char *nbrstr
, t_conv *field);
void init_handler_tab(char *(*f[14])(t_conv *, va_list)); void init_handler_tab(char *(*f[14])(t_conv *, va_list));
int ft_wstrlen(const wint_t *str); int ft_wstrlen(const wint_t *str);
uint64_t dmod(long double nb, long double mod); uint64_t dmod(long double nb, long double mod);
@ -149,7 +151,8 @@ uint64_t dmod(long double nb, long double mod);
void check_flags(const char **str, t_conv *field); void check_flags(const char **str, t_conv *field);
void check_width(const char **str, t_conv *field, va_list ap); void check_width(const char **str, t_conv *field, va_list ap);
ssize_t check_precision(const char **str, t_conv *field, va_list ap); ssize_t check_precision(const char **str, t_conv *field
, va_list ap);
void check_size(const char **str, t_conv *field); void check_size(const char **str, t_conv *field);
ssize_t check_type_one(const char **str, t_conv *field); ssize_t check_type_one(const char **str, t_conv *field);
ssize_t check_type_two(const char **str, t_conv *field); ssize_t check_type_two(const char **str, t_conv *field);