summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-10-01 18:44:17 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-10-01 18:44:17 +0200
commit054058a9fe42d747fd9bc3444ddefbe87106ac1c (patch)
treefdcc232e3c71f4ceb6bb8f7f1106ec5d925b87ee
parentNormed m_init (diff)
download42-minishell-054058a9fe42d747fd9bc3444ddefbe87106ac1c.tar.gz
42-minishell-054058a9fe42d747fd9bc3444ddefbe87106ac1c.tar.bz2
42-minishell-054058a9fe42d747fd9bc3444ddefbe87106ac1c.tar.xz
42-minishell-054058a9fe42d747fd9bc3444ddefbe87106ac1c.tar.zst
42-minishell-054058a9fe42d747fd9bc3444ddefbe87106ac1c.zip
Normed m_loop
-rw-r--r--src/m_loop.c17
-rw-r--r--src/m_loop.h8
-rw-r--r--src/m_loop_next.c10
-rw-r--r--src/m_loop_next.h2
4 files changed, 20 insertions, 17 deletions
diff --git a/src/m_loop.c b/src/m_loop.c
index 8912284..fe4a4b8 100644
--- a/src/m_loop.c
+++ b/src/m_loop.c
@@ -29,8 +29,7 @@
#include "u_parse.h"
#include "u_vars.h"
-static void
- m_parse_and_run_line(char line[], t_msh *msh)
+static void m_parse_and_run_line(char line[], t_msh *msh)
{
t_line_block *ptr;
uint8_t previf;
@@ -56,8 +55,7 @@ static void
s_line_clear(&msh->curr);
}
-void
- m_dump_hist(char hist[], t_msh *msh)
+void m_dump_hist(char hist[], t_msh *msh)
{
char histfile[PATH_MAX];
int32_t fd;
@@ -77,8 +75,7 @@ void
}
}
-static void
- m_handle_hist(char hist[], char line[], t_msh *msh)
+static void m_handle_hist(char hist[], char line[], t_msh *msh)
{
static uint16_t hist_i = 0;
@@ -121,8 +118,7 @@ static void m_delete_comments(char line[])
}
}
-uint8_t
- m_loop(int32_t fd, t_msh *msh)
+uint8_t m_loop(int32_t fd, t_msh *msh)
{
static char hist[255 * 4096];
char *line;
@@ -138,10 +134,7 @@ uint8_t
m_delete_comments(line);
if (line[0] != C_NUL)
{
- line = m_check_multi_backslash(fd, line, msh);
- line = m_check_multi_pipe(fd, line, msh);
- line = m_check_multi_and(fd, line, msh);
- line = m_check_multi_quotes(fd, line, msh);
+ line = m_check_multis(fd, line, msh);
if (fd == STDIN_FILENO)
m_handle_hist(hist, line, msh);
m_parse_and_run_line(line, msh);
diff --git a/src/m_loop.h b/src/m_loop.h
index 1f60744..c74a5f9 100644
--- a/src/m_loop.h
+++ b/src/m_loop.h
@@ -10,12 +10,12 @@
/* */
/* ************************************************************************** */
-#ifndef M_LOOP
-#define M_LOOP
+#ifndef FT_M_LOOP
+# define FT_M_LOOP
-#include <stdint.h>
+# include <stdint.h>
-#include "s_struct.h"
+# include "s_struct.h"
void m_dump_hist(t_msh *msh);
uint8_t m_loop(int32_t fd, t_msh *msh);
diff --git a/src/m_loop_next.c b/src/m_loop_next.c
index d138206..b312c0b 100644
--- a/src/m_loop_next.c
+++ b/src/m_loop_next.c
@@ -230,3 +230,13 @@ char
}
return (line);
}
+
+char *m_check_multis(int32_t fd, char line[], t_msh *msh)
+{
+ line = m_check_multi_backslash(fd, line, msh);
+ line = m_check_multi_pipe(fd, line, msh);
+ line = m_check_multi_and(fd, line, msh);
+ line = m_check_multi_quotes(fd, line, msh);
+
+ return (line);
+}
diff --git a/src/m_loop_next.h b/src/m_loop_next.h
index b4ca62c..b400e76 100644
--- a/src/m_loop_next.h
+++ b/src/m_loop_next.h
@@ -21,6 +21,6 @@ char *m_check_multi_backslash(int32_t fd, char line[], t_msh *msh);
char *m_check_multi_pipe(int32_t fd, char line[], t_msh *msh);
char *m_check_multi_and(int32_t fd, char line[], t_msh *msh);
char *m_check_multi_quotes(int32_t fd, char line[], t_msh *msh);
-
+char *m_check_multis(int32_t fd, char line[], t_msh *msh);
#endif