fix: empty line, leaks, pipe
This commit is contained in:
parent
f20038e37b
commit
e48ee8b693
BIN
.fill_env.c.swp
Normal file
BIN
.fill_env.c.swp
Normal file
Binary file not shown.
2
Makefile
2
Makefile
@ -1,4 +1,4 @@
|
|||||||
UTILS_SRC = utils/ft_is_in_quote.c utils/ft_strncpy.c utils/ft_strreplace.c utils/ft_strnchr.c utils/ft_split_quoted.c utils/ft_strshift.c utils/ft_quote_remover.c
|
UTILS_SRC = utils/ft_is_in_quote.c utils/ft_strncpy.c utils/ft_strreplace.c utils/ft_strnchr.c utils/ft_split_quoted.c utils/ft_strshift.c utils/ft_quote_remover.c utils/ft_str_is_empty.c
|
||||||
SRCS = ${UTILS_SRC} main.c file.c infile.c outfile.c heredoc.c syntatics.c cmd.c cmds.c env.c execution.c spacer.c
|
SRCS = ${UTILS_SRC} main.c file.c infile.c outfile.c heredoc.c syntatics.c cmd.c cmds.c env.c execution.c spacer.c
|
||||||
|
|
||||||
OBJS = ${SRCS:.c=.o}
|
OBJS = ${SRCS:.c=.o}
|
||||||
|
3
env.c
3
env.c
@ -6,7 +6,7 @@
|
|||||||
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/02/02 14:39:56 by erey-bet #+# #+# */
|
/* Created: 2023/02/02 14:39:56 by erey-bet #+# #+# */
|
||||||
/* Updated: 2023/02/16 15:18:48 by cchauvet ### ########.fr */
|
/* Updated: 2023/02/16 16:24:21 by cchauvet ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -113,6 +113,7 @@ void env_del(void *ptr)
|
|||||||
content = ptr;
|
content = ptr;
|
||||||
free(content->key);
|
free(content->key);
|
||||||
free(content->value);
|
free(content->value);
|
||||||
|
free(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *get_key(char *str)
|
char *get_key(char *str)
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/02/14 13:45:30 by cchauvet #+# #+# */
|
/* Created: 2023/02/14 13:45:30 by cchauvet #+# #+# */
|
||||||
/* Updated: 2023/02/16 15:17:07 by cchauvet ### ########.fr */
|
/* Updated: 2023/02/16 16:12:26 by cchauvet ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
7
spacer.c
7
spacer.c
@ -6,7 +6,7 @@
|
|||||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/02/15 13:35:50 by cchauvet #+# #+# */
|
/* Created: 2023/02/15 13:35:50 by cchauvet #+# #+# */
|
||||||
/* Updated: 2023/02/16 14:53:16 by cchauvet ### ########.fr */
|
/* Updated: 2023/02/16 16:26:15 by cchauvet ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -101,6 +101,8 @@ char *ft_normalizer(char *str)
|
|||||||
char *out;
|
char *out;
|
||||||
char *temp;
|
char *temp;
|
||||||
|
|
||||||
|
if (ft_str_is_empty(str))
|
||||||
|
return (ft_strdup(" "));
|
||||||
temp = ft_spacer_after(str);
|
temp = ft_spacer_after(str);
|
||||||
if (temp == NULL)
|
if (temp == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
@ -109,6 +111,7 @@ char *ft_normalizer(char *str)
|
|||||||
if (out == NULL)
|
if (out == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
ft_space_simplifier(out);
|
ft_space_simplifier(out);
|
||||||
out[ft_strlen(out) - 1] = '\0';
|
if (out[ft_strlen(out) - 1] == ' ')
|
||||||
|
out[ft_strlen(out) - 1] = '\0';
|
||||||
return (out);
|
return (out);
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,9 @@ static int ft_pipe_is_alone(const char *str)
|
|||||||
{
|
{
|
||||||
while (str[i] == ' ')
|
while (str[i] == ' ')
|
||||||
i++;
|
i++;
|
||||||
if (str[i] != '|' && str[i] != '\0')
|
if (str[i] == '\0')
|
||||||
|
break ;
|
||||||
|
if (str[i] != '|')
|
||||||
check = 1;
|
check = 1;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -89,7 +91,7 @@ int ft_empty_verif(const char *str)
|
|||||||
int ft_syntatic_verif(const char *str)
|
int ft_syntatic_verif(const char *str)
|
||||||
{
|
{
|
||||||
return (ft_quote_verif(str)
|
return (ft_quote_verif(str)
|
||||||
|| ft_pipe_is_alone(str)
|
|
||||||
|| ft_empty_verif(str)
|
|| ft_empty_verif(str)
|
||||||
|
|| ft_pipe_is_alone(str)
|
||||||
|| ft_special_char_dub(str));
|
|| ft_special_char_dub(str));
|
||||||
}
|
}
|
||||||
|
23
utils/ft_str_is_empty.c
Normal file
23
utils/ft_str_is_empty.c
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_str_is_empty.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2023/02/16 16:12:46 by cchauvet #+# #+# */
|
||||||
|
/* Updated: 2023/02/16 16:13:07 by cchauvet ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
|
int ft_str_is_empty(const char *str)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (str[i] == ' ')
|
||||||
|
i++;
|
||||||
|
return (str[i] == '\0');
|
||||||
|
}
|
@ -6,7 +6,7 @@
|
|||||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/02/14 14:46:40 by cchauvet #+# #+# */
|
/* Created: 2023/02/14 14:46:40 by cchauvet #+# #+# */
|
||||||
/* Updated: 2023/02/16 15:15:05 by cchauvet ### ########.fr */
|
/* Updated: 2023/02/16 16:13:47 by cchauvet ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ char *ft_strreplace(const char *str, const char *fill,
|
|||||||
size_t start, size_t stop);
|
size_t start, size_t stop);
|
||||||
ssize_t ft_strnchr(const char *str, char c);
|
ssize_t ft_strnchr(const char *str, char c);
|
||||||
char *ft_getstr(const char *str, size_t n);
|
char *ft_getstr(const char *str, size_t n);
|
||||||
void ft_printn(const char *str, size_t n);
|
int ft_str_is_empty(const char *str);
|
||||||
char **ft_split_quoted(const char *s, char c);
|
char **ft_split_quoted(const char *s, char c);
|
||||||
void ft_strshift(char *str, int shift);
|
void ft_strshift(char *str, int shift);
|
||||||
char *ft_quote_remover(char *str);
|
char *ft_quote_remover(char *str);
|
||||||
|
Loading…
Reference in New Issue
Block a user