clean: norm

This commit is contained in:
Camille Chauvet 2023-02-21 14:35:08 +01:00
parent e8deb0be19
commit 73d1f11269
5 changed files with 64 additions and 14 deletions

View File

@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_is_in_quote.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/21 12:59:34 by cchauvet #+# #+# */
/* Updated: 2023/02/21 12:59:43 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "utils.h" #include "utils.h"
int ft_is_in_quote(const char *str, size_t n) int ft_is_in_quote(const char *str, size_t n)
@ -15,13 +27,11 @@ int ft_is_in_quote(const char *str, size_t n)
{ {
if (simple_quoted == 0) if (simple_quoted == 0)
double_quoted = !double_quoted; double_quoted = !double_quoted;
} }
if (str[i] == '\'') if (str[i] == '\'')
{ {
if (double_quoted == 0) if (double_quoted == 0)
simple_quoted = !simple_quoted; simple_quoted = !simple_quoted;
} }
i++; i++;
} }

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/15 14:12:00 by cchauvet #+# #+# */ /* Created: 2023/02/15 14:12:00 by cchauvet #+# #+# */
/* Updated: 2023/02/17 18:27:28 by cchauvet ### ########.fr */ /* Updated: 2023/02/21 14:33:28 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -19,6 +19,7 @@ char *ft_quote_remover(char *str)
ssize_t stop; ssize_t stop;
start = -1; start = -1;
stop = -1;
i = 0; i = 0;
while (str[i] != '\0') while (str[i] != '\0')
{ {
@ -27,17 +28,18 @@ char *ft_quote_remover(char *str)
if (start == -1) if (start == -1)
start = i; start = i;
else if (str[i] == str[start]) else if (str[i] == str[start])
{
stop = i; stop = i;
break ;
}
} }
i++; if (stop != -1)
} {
if (start != -1) ft_strshift(str + start, -1);
{ ft_strshift(str + stop - 1, -1);
ft_strshift(str + start, -1); start = -1;
ft_strshift(str + stop - 1, -1); stop = -1;
i = i - 2;
}
else
i++;
} }
return (str); return (str);
} }

View File

@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strnchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/21 12:59:06 by cchauvet #+# #+# */
/* Updated: 2023/02/21 12:59:07 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "utils.h" #include "utils.h"
ssize_t ft_strnchr(const char *str, char c) ssize_t ft_strnchr(const char *str, char c)

View File

@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/21 12:59:16 by cchauvet #+# #+# */
/* Updated: 2023/02/21 12:59:19 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "utils.h" #include "utils.h"
size_t ft_strncpy(char *dst, const char *src, size_t n) size_t ft_strncpy(char *dst, const char *src, size_t n)

View File

@ -1,11 +1,25 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strreplace.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/21 12:46:20 by cchauvet #+# #+# */
/* Updated: 2023/02/21 12:58:44 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "utils.h" #include "utils.h"
char *ft_strreplace(const char *str, const char *fill, size_t start, size_t stop) char *ft_strreplace(const char *str, const char *fill,
size_t start, size_t stop)
{ {
char *out; char *out;
size_t sum; size_t sum;
out = malloc((ft_strlen(str) + ft_strlen(fill) - (stop - start) + 1 * sizeof(char))); out = malloc((ft_strlen(str) + ft_strlen(fill) -\
(stop - start) + 1 * sizeof(char)));
if (out == NULL) if (out == NULL)
return (NULL); return (NULL);
ft_strncpy(out, str, start); ft_strncpy(out, str, start);