summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libft/src/ft_nrealloc.c4
-rw-r--r--libft/src/ft_strsubst.c4
-rw-r--r--src/p_args_len.c3
-rw-r--r--src/p_lblock_next.c10
-rw-r--r--src/s_com.c7
-rw-r--r--src/u_vars_next.c6
6 files changed, 17 insertions, 17 deletions
diff --git a/libft/src/ft_nrealloc.c b/libft/src/ft_nrealloc.c
index 82975d1..6b42380 100644
--- a/libft/src/ft_nrealloc.c
+++ b/libft/src/ft_nrealloc.c
@@ -21,7 +21,7 @@ void
if (!ptr)
{
- if (!(ptr = malloc(newsize)))
+ if ((ptr = malloc(newsize)) == NULL)
return (NULL);
return (ptr);
}
@@ -30,7 +30,7 @@ void
ft_memdel((void*)&ptr);
return (NULL);
}
- if (!(nptr = malloc(newsize)))
+ if ((nptr = malloc(newsize)) == NULL)
return (ptr);
ft_memcpy(nptr, ptr, oldsize);
ft_memdel((void*)&ptr);
diff --git a/libft/src/ft_strsubst.c b/libft/src/ft_strsubst.c
index 57e0ac8..3c5c643 100644
--- a/libft/src/ft_strsubst.c
+++ b/libft/src/ft_strsubst.c
@@ -20,10 +20,10 @@ char
char *nstr;
char *ptr;
- if (!(ptr = ft_strnstr(str, pattern, ft_strlen(str))))
+ if ((ptr = ft_strnstr(str, pattern, ft_strlen(str))) == NULL)
return (NULL);
nlen = ft_strlen(str) - ft_strlen(pattern) + ft_strlen(subst);
- if (!(nstr = (char*)malloc((nlen + 1) * sizeof(char))))
+ if ((nstr = (char*)malloc((nlen + 1) * sizeof(char))) == NULL)
return (NULL);
ft_memcpy(nstr, str, ptr - str);
ft_memcpy(nstr + (ptr - str), subst, ft_strlen(subst));
diff --git a/src/p_args_len.c b/src/p_args_len.c
index 3e5bfbf..e624b37 100644
--- a/src/p_args_len.c
+++ b/src/p_args_len.c
@@ -49,7 +49,8 @@ size_t
terminate = p_meet_whitespace(word, ptr, mode);
ptr++;
}
- ptr -= 1;
+ if (*ptr != C_NUL)
+ ptr -= 1;
return (ptr - word);
}
diff --git a/src/p_lblock_next.c b/src/p_lblock_next.c
index 56a789d..8b22f7c 100644
--- a/src/p_lblock_next.c
+++ b/src/p_lblock_next.c
@@ -28,8 +28,8 @@
static char
*p_subst_this_var(char **p, int64_t i, char word[], t_msh *msh)
{
- char tmp[4096];
- char varval[4096];
+ char tmp[ARG_MAX];
+ char varval[ARG_MAX];
char *ptr;
size_t varlen;
@@ -42,7 +42,9 @@ static char
ft_strlcpy(tmp, ptr + i, varlen + 1 - i);
u_get_var_value(varval, tmp, 4096, msh);
ft_strlcpy(tmp, ptr + varlen, varlen);
- word = ft_nrealloc(word, i, i + ft_strlen(varval) + ft_strlen(tmp) + 1);
+ if ((word = ft_nrealloc(word, i, i + ft_strlen(varval) +
+ ft_strlen(tmp) + 1)) == NULL)
+ return (NULL);
ft_strlcpy(word + i, varval, ft_strlen(varval) + 1);
ft_strlcpy(word + (i + ft_strlen(varval)), tmp, ft_strlen(tmp) + 1);
*(p) = word + (i + ft_strlen(varval) - 1);
@@ -143,7 +145,7 @@ static char
j = 0;
while (words[i + j] != NULL)
j++;
- if (!(rewords = (char**)malloc((j + 1) * sizeof(char*))))
+ if ((rewords = (char**)malloc((j + 1) * sizeof(char*))) == NULL)
{
ft_delwords(words);
f_alloc_and_destroy_msh(msh);
diff --git a/src/s_com.c b/src/s_com.c
index dc81046..36018ef 100644
--- a/src/s_com.c
+++ b/src/s_com.c
@@ -20,8 +20,7 @@
#include "s_struct.h"
static int8_t
- fill_com(char *words[],
- t_com **com)
+ fill_com(char *words[], t_com **com)
{
/* TODO: norme */
uint64_t i;
@@ -59,8 +58,7 @@ static int8_t
}
static void
- s_com_cpy_env_fork(t_com **com,
- t_msh *msh)
+ s_com_cpy_env_fork(t_com **com, t_msh *msh)
{
size_t i;
size_t j;
@@ -120,6 +118,7 @@ t_com
return (NULL);
if ((words = p_subst_home(words, msh)) == NULL)
return (NULL);
+ ft_printf("%s\n", *words);
words = p_check_args_equals(words, msh);
if (msh->env_fork_tmp[0][0] != '\0')
s_com_cpy_env_fork(&com, msh);
diff --git a/src/u_vars_next.c b/src/u_vars_next.c
index 6f63fb4..2135c6b 100644
--- a/src/u_vars_next.c
+++ b/src/u_vars_next.c
@@ -22,8 +22,7 @@
#include "u_utils.h"
static int64_t
- u_get_env_var_line(const char varname[],
- t_msh *msh)
+ u_get_env_var_line(const char varname[], t_msh *msh)
{
char **env_dup;
int64_t i;
@@ -44,8 +43,7 @@ static int64_t
}
static t_bool
- u_get_custom_var_existance(const char varname[],
- t_msh *msh)
+ u_get_custom_var_existance(const char varname[], t_msh *msh)
{
t_lvars *ptr;