summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSalad <water_appreciator@protonmail.com>2020-10-19 17:40:44 +0200
committerSalad <water_appreciator@protonmail.com>2020-10-19 17:40:44 +0200
commit36184c4d5906043241d912390b788343f088bff1 (patch)
tree30233749e79f3cacfeddd1141454906bd375d57e
parentFIX ALL NIG (diff)
download42-minishell-36184c4d5906043241d912390b788343f088bff1.tar.gz
42-minishell-36184c4d5906043241d912390b788343f088bff1.tar.bz2
42-minishell-36184c4d5906043241d912390b788343f088bff1.tar.xz
42-minishell-36184c4d5906043241d912390b788343f088bff1.tar.zst
42-minishell-36184c4d5906043241d912390b788343f088bff1.zip
norme + backslash + delchar + init --> gnl
-rw-r--r--src/c_init.c19
-rw-r--r--src/c_init.h2
-rw-r--r--src/c_input.c13
-rw-r--r--src/c_keys.c11
-rw-r--r--src/c_utils.c21
-rw-r--r--src/m_loop.c2
-rw-r--r--src/m_loop_next.c23
7 files changed, 27 insertions, 64 deletions
diff --git a/src/c_init.c b/src/c_init.c
index 0e48b2f..69885fc 100644
--- a/src/c_init.c
+++ b/src/c_init.c
@@ -23,8 +23,7 @@
#include "m_prompt.h"
static t_caps
- *c_get_struct(int mode,
- t_caps *src)
+ *c_get_struct(int mode, t_caps *src)
{
static t_caps *caps;
@@ -60,10 +59,7 @@ int16_t
}
int16_t
-c_read_cap(char *buf,
- char *line,
- t_caps *tcaps,
- t_msh *msh)
+c_read_cap(char *buf, char *line, t_caps *tcaps, t_msh *msh)
{
if (((*((unsigned int *)buf)) == LEFT_K) || ((*((unsigned int *)buf)) == CTRL_B))
return (c_key_left(ft_strlen(msh->ps[tcaps->psx]), tcaps));
@@ -82,19 +78,15 @@ c_read_cap(char *buf,
}
static char
- *c_process_key(char *buf,
- t_caps *tcaps,
- t_msh *msh)
+ *c_process_key(char *buf, t_caps *tcaps, t_msh *msh)
{
static char *line = NULL;
int i;
i = -1;
if (line == NULL)
- {
if (!(line = ft_calloc(1, sizeof(char))))
return (NULL);
- }
if (ft_isprint(buf[0]))
{
line = c_insert_char(line, buf[0], tcaps);
@@ -120,10 +112,7 @@ static char
}
int16_t
-c_init_tcaps(int32_t fd,
- char **line,
- uint8_t psx,
- t_msh *msh)
+c_gnl(int32_t fd, char **line, uint8_t psx, t_msh *msh)
{
t_caps tcaps;
char *term;
diff --git a/src/c_init.h b/src/c_init.h
index 6317871..86eb89a 100644
--- a/src/c_init.h
+++ b/src/c_init.h
@@ -41,7 +41,7 @@ typedef struct s_caps
uint8_t psx; /*cursor position (line)*/
} t_caps;
-int16_t c_init_tcaps(int32_t fd, char **line, uint8_t psx, t_msh *msh);
+int16_t c_gnl(int32_t fd, char **line, uint8_t psx, t_msh *msh);
int16_t c_set_term_raw(uint8_t mode);
#endif
diff --git a/src/c_input.c b/src/c_input.c
index 1cc9ce0..bbc6f5a 100644
--- a/src/c_input.c
+++ b/src/c_input.c
@@ -51,10 +51,7 @@ uint16_t
}
uint32_t
-c_get_line_num(char *line,
- uint32_t cpos,
- uint32_t plen,
- t_caps *tcaps)
+c_get_line_num(char *line, uint32_t cpos, uint32_t plen, t_caps *tcaps)
{
uint32_t it;
uint32_t line_num;
@@ -76,9 +73,7 @@ c_get_line_num(char *line,
}
int16_t
- c_back_slash(char **line,
- uint32_t plen,
- t_caps *tcaps)
+ c_back_slash(char **line, uint32_t plen, t_caps *tcaps)
{
if (tcaps->cpos >= 1)
{
@@ -90,9 +85,7 @@ int16_t
}
int16_t
- c_ctrl_c(char *line,
- t_caps *tcaps,
- t_msh *msh)
+ c_ctrl_c(char *line, t_caps *tcaps, t_msh *msh)
{
(void)tcaps;
(void)line;
diff --git a/src/c_keys.c b/src/c_keys.c
index 5a036e6..cd3e6f1 100644
--- a/src/c_keys.c
+++ b/src/c_keys.c
@@ -18,9 +18,7 @@
#include "m_prompt.h"
int16_t
- c_ctrl_l(char *line,
- t_caps *tcaps,
- t_msh *msh)
+ c_ctrl_l(char *line, t_caps *tcaps, t_msh *msh)
{
tputs(tgetstr("cl", NULL), 1, ft_putchar);
m_prompt_psx(1, msh);
@@ -85,9 +83,7 @@ int16_t
}
int16_t
- c_key_right(uint32_t len,
- uint32_t plen,
- t_caps *tcaps)
+ c_key_right(uint32_t len, uint32_t plen, t_caps *tcaps)
{
if ((((tcaps->cpos + plen + 1) % (tcaps->ws.ws_col)) == 0)
&& tcaps->cpos < len)
@@ -106,8 +102,7 @@ int16_t
}
int16_t
- c_key_left(uint32_t plen,
- t_caps *tcaps)
+ c_key_left(uint32_t plen, t_caps *tcaps)
{
int32_t pos;
diff --git a/src/c_utils.c b/src/c_utils.c
index ad1ccba..3c21bff 100644
--- a/src/c_utils.c
+++ b/src/c_utils.c
@@ -30,8 +30,7 @@
*/
char
- *c_new_line(char *line,
- t_caps *tcaps)
+ *c_new_line(char *line, t_caps *tcaps)
{
char *ret;
@@ -50,9 +49,7 @@ char
}
char
- *c_insert_char(char *str,
- char c,
- t_caps *tcaps)
+ *c_insert_char(char *str, char c, t_caps *tcaps)
{
int32_t i;
size_t j;
@@ -79,8 +76,7 @@ char
}
char
- *c_delchar(char *str,
- uint16_t cpos)
+ *c_delchar(char *str, uint16_t cpos)
{
char *dst;
uint16_t i;
@@ -105,14 +101,13 @@ char
}
static int16_t
- c_redraw_next(size_t plen,
- uint32_t len,
- t_caps *tcaps)
+ c_redraw_next(size_t plen, uint32_t len, t_caps *tcaps)
{
uint32_t i;
uint32_t j;
- i = (tcaps->nlines == tcaps->lpos) ? 0 : tcaps->ws.ws_col * (tcaps->lpos - 1);
+ i = (tcaps->nlines == tcaps->lpos) ? 0 :
+ tcaps->ws.ws_col * (tcaps->lpos - 1);
j = tcaps->nlines;
if (tcaps->nlines != tcaps->lpos)
{
@@ -136,9 +131,7 @@ static int16_t
}
int16_t
- c_redraw_line(char *line,
- t_caps *tcaps,
- t_msh *msh)
+ c_redraw_line(char *line, t_caps *tcaps, t_msh *msh)
{
uint32_t i;
uint32_t j;
diff --git a/src/m_loop.c b/src/m_loop.c
index 3269fe4..6bba915 100644
--- a/src/m_loop.c
+++ b/src/m_loop.c
@@ -44,7 +44,7 @@ uint8_t
/* if (fd == STDIN_FILENO) */
/* m_prompt_psx(1, msh); */
/* gnl = get_next_line(fd, &line); */
- gnl = c_init_tcaps(fd, &line, 1, msh);
+ gnl = c_gnl(fd, &line, 1, msh);
if (line[0] != '\0')
{
line = m_check_multi_backslash(fd, line, msh);
diff --git a/src/m_loop_next.c b/src/m_loop_next.c
index d7d3377..90ffc01 100644
--- a/src/m_loop_next.c
+++ b/src/m_loop_next.c
@@ -23,19 +23,13 @@ static char
{
char *counter_line;
- /* if (fd == STDIN_FILENO) */
- /* m_prompt_psx(psx, msh); */
- /* get_next_line(fd, &counter_line); */
- c_init_tcaps(fd, &counter_line, psx, msh);
- if (counter_line[0] != 0)
- {
- line = ft_nrealloc(line,
- ft_strlen(line) + 1,
- ft_strlen(line) + ft_strlen(counter_line));
- ft_memcpy(line + ft_strlen(line) - 1,
- counter_line,
- ft_strlen(counter_line) + 1);
- }
+ c_gnl(fd, &counter_line, psx, msh);
+ line = ft_nrealloc(line,
+ ft_strlen(line) + 1,
+ ft_strlen(line) + ft_strlen(counter_line));
+ ft_memcpy(line + ft_strlen(line) - 1,
+ counter_line,
+ ft_strlen(counter_line) + 1);
ft_memdel((void*)&counter_line);
return (line);
}
@@ -47,8 +41,7 @@ static char
if (fd == STDIN_FILENO)
m_prompt_psx(psx, msh);
- /* get_next_line(fd, &counter_line); */
- c_init_tcaps(fd, &counter_line, psx, msh);
+ c_gnl(fd, &counter_line, psx, msh);
if (counter_line[0] != 0)
{
line = ft_nrealloc(line,