summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsalad <fmoenne-@student.le-101.fr>2020-11-02 15:23:19 +0100
committersalad <fmoenne-@student.le-101.fr>2020-11-02 15:23:19 +0100
commit541d187f9fa37f79b5815a5d4d52ac5ad5bf2bab (patch)
tree6098829ac4007b672893e800ea56453071672973
parentomw to sed-town (diff)
download42-minishell-541d187f9fa37f79b5815a5d4d52ac5ad5bf2bab.tar.gz
42-minishell-541d187f9fa37f79b5815a5d4d52ac5ad5bf2bab.tar.bz2
42-minishell-541d187f9fa37f79b5815a5d4d52ac5ad5bf2bab.tar.xz
42-minishell-541d187f9fa37f79b5815a5d4d52ac5ad5bf2bab.tar.zst
42-minishell-541d187f9fa37f79b5815a5d4d52ac5ad5bf2bab.zip
merge happenned
-rw-r--r--Makefile1
-rw-r--r--libft/Makefile2
-rw-r--r--src/c_init.c12
-rw-r--r--src/c_init.h12
-rw-r--r--src/c_input.c20
-rw-r--r--src/c_input.h10
-rw-r--r--src/c_keys.c28
-rw-r--r--src/c_keys.h10
-rw-r--r--src/c_utils.c26
-rw-r--r--src/c_utils.h4
-rw-r--r--src/m_loop.c1
-rw-r--r--src/m_loop_counter.c7
12 files changed, 68 insertions, 65 deletions
diff --git a/Makefile b/Makefile
index 6841aed..3e94e0c 100644
--- a/Makefile
+++ b/Makefile
@@ -134,6 +134,7 @@ CDEFS = -D_POSIX_C_SOURCE=200112L
#------------------------------------------------------------------------------#
LDFLAGS = -L${LFT_DIR}
LDFLAGS += -lft
+LDFLAGS += -lncurses
#==============================================================================#
#--------------------------------- UNIX ---------------------------------------#
#==============================================================================#
diff --git a/libft/Makefile b/libft/Makefile
index 701d902..94ef43b 100644
--- a/libft/Makefile
+++ b/libft/Makefile
@@ -134,7 +134,7 @@ ifeq (${OS}, FreeBSD)
CC = /usr/bin/cc
endif
ifeq (${OS}, Linux)
-CC = /usr/bin/clang-9
+CC = /usr/bin/clang
endif
ifeq (${OS}, Darwin)
CC = clang
diff --git a/src/c_init.c b/src/c_init.c
index 77d3023..6847c14 100644
--- a/src/c_init.c
+++ b/src/c_init.c
@@ -23,8 +23,8 @@
#include "s_struct.h"
#include "m_prompt.h"
-int16_t
- c_set_term_raw(uint8_t mode)
+short
+ c_set_term_raw(char mode)
{
struct termios tios;
@@ -61,10 +61,10 @@ static void
c_redraw_line(*line, tcaps, msh);
}
-static int16_t
+static short
c_read_cap(char *buf, char *line, t_caps *tcaps, t_msh *msh)
{
- uint32_t plen;
+ unsigned int plen;
plen = ft_strlen(msh->ps[tcaps->psx]);
if (((*((unsigned int *)buf)) == LEFT_K) ||
@@ -119,8 +119,8 @@ static char
return ((buf[0] == '\n') ? c_new_line(line, tcaps) : NULL);
}
-int16_t
- c_gnl(int32_t fd, char **line, uint8_t psx, t_msh *msh)
+short
+ c_gnl(int fd, char **line, char psx, t_msh *msh)
{
t_caps tcaps;
char nread[5];
diff --git a/src/c_init.h b/src/c_init.h
index e723563..db7d777 100644
--- a/src/c_init.h
+++ b/src/c_init.h
@@ -37,13 +37,13 @@ typedef struct s_caps
{
struct termios tios;
struct winsize ws;
- uint32_t cpos;
- uint32_t lpos;
- uint32_t nlines;
- uint8_t psx;
+ unsigned int cpos;
+ unsigned int lpos;
+ unsigned int nlines;
+ unsigned short psx;
} t_caps;
-int16_t c_gnl(int32_t fd, char **line, uint8_t psx, t_msh *msh);
-int16_t c_set_term_raw(uint8_t mode);
+short c_gnl(int fd, char **line, char psx, t_msh *msh);
+short c_set_term_raw(char mode);
#endif
diff --git a/src/c_input.c b/src/c_input.c
index 8fb4b72..24e45e3 100644
--- a/src/c_input.c
+++ b/src/c_input.c
@@ -23,8 +23,8 @@
#include "m_prompt.h"
#include "m_loop.h"
-int16_t
- c_init_line(uint8_t psx, t_caps *tcaps)
+short
+ c_init_line(char psx, t_caps *tcaps)
{
char *term;
@@ -45,7 +45,7 @@ int16_t
return (-1);
}
-uint16_t
+unsigned short
c_get_win_size(struct winsize *ws)
{
if (!(ioctl(STDOUT_FILENO, TIOCGWINSZ, ws)))
@@ -57,12 +57,12 @@ uint16_t
return (1);
}
-uint32_t
- c_get_line_num(char *line, uint32_t cpos, uint32_t plen, t_caps *tcaps)
+unsigned int
+ c_get_line_num(char *line, unsigned int cpos, unsigned int plen, t_caps *tcaps)
{
- uint32_t it;
- uint32_t line_num;
- uint32_t len;
+ unsigned int it;
+ unsigned int line_num;
+ unsigned int len;
it = 0;
line_num = 0;
@@ -79,8 +79,8 @@ uint32_t
return (line_num);
}
-int16_t
- c_back_slash(char **line, uint32_t plen, t_caps *tcaps)
+short
+ c_back_slash(char **line, unsigned int plen, t_caps *tcaps)
{
if (tcaps->cpos >= 1)
{
diff --git a/src/c_input.h b/src/c_input.h
index f22166a..01aaa15 100644
--- a/src/c_input.h
+++ b/src/c_input.h
@@ -13,11 +13,11 @@
#ifndef C_INPUT_H
# define C_INPUT_H
-int16_t c_back_slash(char **line, uint32_t plen, t_caps *tcaps);
-int16_t c_ctrl_c(char *line, t_caps *tcaps, t_msh *msh);
-uint32_t c_get_line_num(char *line, uint32_t cpos, uint32_t plen,
+short c_back_slash(char **line, unsigned int plen, t_caps *tcaps);
+short c_ctrl_c(char *line, t_caps *tcaps, t_msh *msh);
+unsigned int c_get_line_num(char *line, unsigned int cpos, unsigned int plen,
t_caps *tcaps);
-int16_t c_init_line(uint8_t psx, t_caps *tcaps);
-uint16_t c_get_win_size(struct winsize *ws);
+short c_init_line(char psx, t_caps *tcaps);
+unsigned short c_get_win_size(struct winsize *ws);
#endif
diff --git a/src/c_keys.c b/src/c_keys.c
index e0f734c..593c6d4 100644
--- a/src/c_keys.c
+++ b/src/c_keys.c
@@ -17,7 +17,7 @@
#include "c_utils.h"
#include "m_prompt.h"
-int16_t
+short
c_ctrl_l(char *line, t_caps *tcaps, t_msh *msh)
{
tputs(tgetstr("cl", NULL), 1, ft_putchar);
@@ -26,11 +26,11 @@ int16_t
return (1);
}
-int16_t
- c_home_key(uint32_t plen, t_caps *tcaps)
+short
+ c_home_key(unsigned int plen, t_caps *tcaps)
{
- uint32_t i;
- int16_t j;
+ unsigned int i;
+ short j;
i = tcaps->cpos;
j = tcaps->lpos;
@@ -53,11 +53,11 @@ int16_t
return (1);
}
-int16_t
- c_end_key(uint16_t size, uint32_t plen, t_caps *tcaps)
+short
+ c_end_key(unsigned short size, unsigned int plen, t_caps *tcaps)
{
- uint16_t i;
- uint16_t j;
+ unsigned short i;
+ unsigned short j;
i = tcaps->cpos;
j = tcaps->lpos;
@@ -82,8 +82,8 @@ int16_t
return (1);
}
-int16_t
- c_key_right(uint32_t len, uint32_t plen, t_caps *tcaps)
+short
+ c_key_right(unsigned int len, unsigned int plen, t_caps *tcaps)
{
if ((((tcaps->cpos + plen + 1) % (tcaps->ws.ws_col)) == 0) &&
tcaps->cpos < len)
@@ -101,10 +101,10 @@ int16_t
return (1);
}
-int16_t
- c_key_left(uint32_t plen, t_caps *tcaps)
+short
+ c_key_left(unsigned int plen, t_caps *tcaps)
{
- int32_t pos;
+ int pos;
pos = -1;
if (((tcaps->cpos + plen) % tcaps->ws.ws_col) == 0 &&
diff --git a/src/c_keys.h b/src/c_keys.h
index 12b17ee..d64a908 100644
--- a/src/c_keys.h
+++ b/src/c_keys.h
@@ -13,10 +13,10 @@
#ifndef C_KEYS_H
# define C_KEYS_H
-int16_t c_key_right(uint32_t len, uint32_t plen, t_caps *tcaps);
-int16_t c_key_left(uint32_t plen, t_caps *tcaps);
-int16_t c_home_key(uint32_t plen, t_caps *tcaps);
-int16_t c_end_key(uint16_t size, uint32_t plen, t_caps *tcaps);
-int16_t c_ctrl_l(char *line, t_caps *tcaps, t_msh *msh);
+short c_key_right(unsigned int len, unsigned int plen, t_caps *tcaps);
+short c_key_left(unsigned int plen, t_caps *tcaps);
+short c_home_key(unsigned int plen, t_caps *tcaps);
+short c_end_key(unsigned short size, unsigned int plen, t_caps *tcaps);
+short c_ctrl_l(char *line, t_caps *tcaps, t_msh *msh);
#endif
diff --git a/src/c_utils.c b/src/c_utils.c
index 043bd27..3198dff 100644
--- a/src/c_utils.c
+++ b/src/c_utils.c
@@ -50,7 +50,7 @@ char
char
*c_insert_char(char *str, char c, t_caps *tcaps)
{
- int32_t i;
+ int i;
size_t j;
size_t len;
char *dst;
@@ -60,9 +60,9 @@ char
len = (ft_strlen(str) + 2);
if (!(dst = (char*)malloc((len) * sizeof(char))))
return (NULL);
- while (++i < (int32_t)len)
+ while (++i < (int)len)
{
- if (i == (int32_t)tcaps->cpos)
+ if (i == (int)tcaps->cpos)
dst[i] = c;
else
{
@@ -75,11 +75,11 @@ char
}
char
- *c_delchar(char *str, uint16_t cpos)
+ *c_delchar(char *str, unsigned short cpos)
{
char *dst;
- uint16_t i;
- uint16_t j;
+ unsigned short i;
+ unsigned short j;
j = 0;
i = 0;
@@ -99,11 +99,11 @@ char
return (dst);
}
-static int16_t
- c_redraw_next(size_t plen, uint32_t len, t_caps *tcaps)
+static short
+ c_redraw_next(size_t plen, unsigned int len, t_caps *tcaps)
{
- uint32_t i;
- uint32_t j;
+ unsigned int i;
+ unsigned int j;
i = (tcaps->nlines == tcaps->lpos) ? 0 :
tcaps->ws.ws_col * (tcaps->lpos - 1);
@@ -129,11 +129,11 @@ static int16_t
return (len);
}
-int16_t
+short
c_redraw_line(char *line, t_caps *tcaps, t_msh *msh)
{
- uint32_t i;
- uint32_t j;
+ unsigned int i;
+ unsigned int j;
tcaps->nlines = c_get_line_num(line, tcaps->cpos,
ft_strlen(msh->ps[tcaps->psx]), tcaps);
diff --git a/src/c_utils.h b/src/c_utils.h
index 730d29a..f33c961 100644
--- a/src/c_utils.h
+++ b/src/c_utils.h
@@ -17,7 +17,7 @@
char *c_new_line(char *line, t_caps *tcaps);
char *c_insert_char(char *str, char c, t_caps *tcaps);
-char *c_delchar(char *str, uint16_t cpos);
-int16_t c_redraw_line(char *line, t_caps *tcaps, t_msh *msh);
+char *c_delchar(char *str, unsigned short cpos);
+short c_redraw_line(char *line, t_caps *tcaps, t_msh *msh);
#endif
diff --git a/src/m_loop.c b/src/m_loop.c
index 181f384..94e3027 100644
--- a/src/m_loop.c
+++ b/src/m_loop.c
@@ -20,6 +20,7 @@
# include <limits.h>
#endif
+#include "c_init.h"
#include "d_define.h"
#include "e_line.h"
#include "m_loop_multis.h"
diff --git a/src/m_loop_counter.c b/src/m_loop_counter.c
index 85609dd..430968a 100644
--- a/src/m_loop_counter.c
+++ b/src/m_loop_counter.c
@@ -13,6 +13,7 @@
#include <libft.h>
#include <unistd.h>
+#include "c_init.h"
#include "m_prompt.h"
#include "s_struct.h"
@@ -23,7 +24,7 @@ char *m_counter_line_backslash(int fd,
{
char *counter_line;
- c_gnl(fd, &line, psx, msh);
+ c_gnl(fd, &counter_line, psx, msh);
if (counter_line[0] != C_NUL)
{
l = ft_nrealloc(l,
@@ -41,7 +42,7 @@ char *m_counter_line_pipes(int fd, unsigned char psx, char *line, t_msh *msh)
{
char *counter_line;
- c_gnl(fd, &line, psx, msh);
+ c_gnl(fd, &counter_line, psx, msh);
if (counter_line[0] != C_NUL)
{
line = ft_nrealloc(line,
@@ -62,7 +63,7 @@ char *m_counter_line_quotes(int fd,
{
char *counter_line;
- c_gnl(fd, &line, psx, msh);
+ c_gnl(fd, &counter_line, psx, msh);
if (counter_line[0] != C_NUL)
{
line = ft_nrealloc(line,