summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-10-02 21:12:28 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-10-02 21:12:28 +0200
commita0ba5acfc412f1e684bf6aa56353d682c715394c (patch)
tree1359bc19a7606e7408ac32e5afdc0142ebb3e20e
parentNorming p_lblock_next (diff)
download42-minishell-a0ba5acfc412f1e684bf6aa56353d682c715394c.tar.gz
42-minishell-a0ba5acfc412f1e684bf6aa56353d682c715394c.tar.bz2
42-minishell-a0ba5acfc412f1e684bf6aa56353d682c715394c.tar.xz
42-minishell-a0ba5acfc412f1e684bf6aa56353d682c715394c.tar.zst
42-minishell-a0ba5acfc412f1e684bf6aa56353d682c715394c.zip
Update
Diffstat (limited to '')
-rw-r--r--Makefile1
-rw-r--r--src/p_lblock_next.c20
-rw-r--r--src/p_lblock_next.h11
-rw-r--r--src/p_subst_home.c39
-rw-r--r--src/p_subst_home.h20
-rw-r--r--src/s_com.c1
6 files changed, 66 insertions, 26 deletions
diff --git a/Makefile b/Makefile
index e5dde07..4b77b31 100644
--- a/Makefile
+++ b/Makefile
@@ -80,6 +80,7 @@ SRCS_NAME += p_lblock_more
SRCS_NAME += p_redirs
SRCS_NAME += p_redirs_heredoc
SRCS_NAME += p_split
+SRCS_NAME += p_subst_home
SRCS_NAME += u_alias
SRCS_NAME += u_parse
SRCS_NAME += u_path
diff --git a/src/p_lblock_next.c b/src/p_lblock_next.c
index 03d7f80..d964f11 100644
--- a/src/p_lblock_next.c
+++ b/src/p_lblock_next.c
@@ -191,26 +191,6 @@ size_t p_subst_alias(char word[], t_bool reset, t_msh *msh)
return (0);
}
-char **p_subst_home(char *words[], t_msh *msh)
-{
- char path[PATH_MAX];
- char **ptr;
-
- u_get_var_value(path, "$HOME", PATH_MAX, msh);
- if (path[0] == C_NUL)
- return (words);
- ptr = words;
- while (*ptr != NULL)
- {
- if (*ptr[0] == '~')
- {
- *ptr = ft_strsubst(*ptr, "~", path);
- }
- ptr++;
- }
- return (words);
-}
-
static char **p_alloc_rewords(char *words[], int64_t j, t_msh *msh)
{
char **rewords;
diff --git a/src/p_lblock_next.h b/src/p_lblock_next.h
index 4ffdfcf..7af7881 100644
--- a/src/p_lblock_next.h
+++ b/src/p_lblock_next.h
@@ -10,18 +10,17 @@
/* */
/* ************************************************************************** */
-#ifndef P_LCOM_NEXT_H
-#define P_LCOM_NEXT_H
+#ifndef FT_P_LCOM_NEXT_H
+# define FT_P_LCOM_NEXT_H
-#include <libft.h>
-#include <stdint.h>
+# include <libft.h>
+# include <stdint.h>
-#include "s_struct.h"
+# include "s_struct.h"
void p_subst_vars(char word[], t_msh *msh);
size_t p_subst_alias(char word[], t_bool reset, t_msh *msh);
char **p_subst_args(const char word[], int8_t redir);
-char **p_subst_home(char *word[], t_msh *msh);
char **p_check_args_equals(char *words[], t_msh *msh);
#endif
diff --git a/src/p_subst_home.c b/src/p_subst_home.c
new file mode 100644
index 0000000..ee9ed42
--- /dev/null
+++ b/src/p_subst_home.c
@@ -0,0 +1,39 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* p_subst_home.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/02/14 17:19:27 by rbousset #+# #+# */
+/* Updated: 2020/02/14 17:19:29 by rbousset ### ########lyon.fr */
+/* */
+/* ************************************************************************** */
+
+#include <libft.h>
+#include <stddef.h>
+#include <limits.h>
+
+#include "d_define.h"
+#include "s_struct.h"
+#include "u_vars.h"
+
+char **p_subst_home(char *words[], t_msh *msh)
+{
+ char path[PATH_MAX];
+ char **ptr;
+
+ u_get_var_value(path, "$HOME", PATH_MAX, msh);
+ if (path[0] == C_NUL)
+ return (words);
+ ptr = words;
+ while (*ptr != NULL)
+ {
+ if (*ptr[0] == '~')
+ {
+ *ptr = ft_strsubst(*ptr, "~", path);
+ }
+ ptr++;
+ }
+ return (words);
+}
diff --git a/src/p_subst_home.h b/src/p_subst_home.h
new file mode 100644
index 0000000..59f1f00
--- /dev/null
+++ b/src/p_subst_home.h
@@ -0,0 +1,20 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* p_subst_home.h :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/02/14 17:19:27 by rbousset #+# #+# */
+/* Updated: 2020/02/14 17:19:29 by rbousset ### ########lyon.fr */
+/* */
+/* ************************************************************************** */
+
+#ifndef FT_P_SUBST_HOME_H
+# define FT_P_SUBST_HOME_H
+
+#include "s_struct.h"
+
+char **p_subst_home(char *word[], t_msh *msh);
+
+#endif
diff --git a/src/s_com.c b/src/s_com.c
index 4f06c84..84e0f35 100644
--- a/src/s_com.c
+++ b/src/s_com.c
@@ -19,6 +19,7 @@
#include "p_args.h"
#include "p_lblock.h"
#include "p_lblock_next.h"
+#include "p_subst_home.h"
#include "p_redirs.h"
#include "s_lredir.h"
#include "s_struct.h"