From ad1f44c7ff032c3b20d493805e544cd70ed4bb89 Mon Sep 17 00:00:00 2001 From: salad Date: Wed, 26 Aug 2020 18:44:24 +0200 Subject: s**** f***** --- Makefile | 3 ++- libft/Makefile | 2 +- src/b_cd.c | 2 +- src/c_init.c | 32 ++++++++++++++++++++++++++++++++ src/c_init.h | 19 +++++++++++++++++++ src/m_loop.c | 6 ++++-- src/s_init.c | 2 +- src/u_utils.c | 9 ++------- src/u_utils.h | 3 --- 9 files changed, 62 insertions(+), 16 deletions(-) create mode 100644 src/c_init.c create mode 100644 src/c_init.h diff --git a/Makefile b/Makefile index 29f8d96..0524861 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,7 @@ SRCS_NAME += b_export_mute SRCS_NAME += b_pwd SRCS_NAME += b_type SRCS_NAME += b_unset +SRCS_NAME += c_init SRCS_NAME += e_builtins SRCS_NAME += e_externs SRCS_NAME += e_externs_next @@ -86,7 +87,7 @@ ifeq (${OS}, FreeBSD) CC = /usr/bin/cc endif ifeq (${OS}, Linux) -CC = /usr/bin/clang-9 +CC = clang endif ifeq (${OS}, Darwin) CC = clang diff --git a/libft/Makefile b/libft/Makefile index 6ada2e1..4e5095b 100644 --- a/libft/Makefile +++ b/libft/Makefile @@ -128,7 +128,7 @@ ifeq (${OS}, FreeBSD) CC = /usr/bin/cc endif ifeq (${OS}, Linux) -CC = /usr/bin/clang-9 +CC = clang endif ifeq (${OS}, Darwin) CC = clang diff --git a/src/b_cd.c b/src/b_cd.c index e322ef8..40fbc1a 100644 --- a/src/b_cd.c +++ b/src/b_cd.c @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include "b_export_next.h" #include "f_fail.h" diff --git a/src/c_init.c b/src/c_init.c new file mode 100644 index 0000000..5cf46f3 --- /dev/null +++ b/src/c_init.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* u_init.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/14 17:19:27 by rbousset #+# #+# */ +/* Updated: 2020/02/14 17:19:29 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include +#include + +void u_handle_sigwinch(int dummy_signal) +{ + (void)dummy_signal; + tputs(LC, 1, ft_putchar); + fflush(stdout); +} + +int16_t c_init_tcaps(void) +{ + char *bp; + char *term; + char *LC; + + term = getenv("TERM"); + tgetent(bp, term); + LC = tgetstr("lc", &term); +} diff --git a/src/c_init.h b/src/c_init.h new file mode 100644 index 0000000..da3d549 --- /dev/null +++ b/src/c_init.h @@ -0,0 +1,19 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* u_init.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/14 17:19:27 by rbousset #+# #+# */ +/* Updated: 2020/02/14 17:19:29 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef U_INIT_H +#define U_INIT_H + +int c_init_tcaps(void); +void u_handle_sigwinch(int dummy_signal); + +#endif diff --git a/src/m_loop.c b/src/m_loop.c index 86d641f..ed92fd5 100644 --- a/src/m_loop.c +++ b/src/m_loop.c @@ -14,13 +14,14 @@ #include #include #include +#include #include "e_line.h" #include "m_loop_next.h" #include "m_prompt.h" #include "p_line.h" #include "s_line.h" -#include "u_utils.h" +#include "c_init.h" static void m_parse_and_run_line(char *line, t_msh *msh) @@ -37,7 +38,8 @@ uint8_t char *line; int8_t gnl; - signal(SIGWINCH, u_handle_sigwinch); + c_init_tcaps(); + signal(SIGWINCH, u_handle_sigwinch); gnl = 1; while (gnl > 0) { diff --git a/src/s_init.c b/src/s_init.c index 7b36653..7f4c6b9 100644 --- a/src/s_init.c +++ b/src/s_init.c @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/u_utils.c b/src/u_utils.c index b4ef987..745b79c 100644 --- a/src/u_utils.c +++ b/src/u_utils.c @@ -15,6 +15,8 @@ #include #include #include +#include +#include #include "f_fail.h" #include "s_struct.h" @@ -66,10 +68,3 @@ uint64_t } return (argc); } - -int u_handle_sigwinch(int dummy_signal) -{ - term = getenv(); - tputs(, 1, ft_putchar); - fflush(stdout); -} diff --git a/src/u_utils.h b/src/u_utils.h index 020da83..6362e14 100644 --- a/src/u_utils.h +++ b/src/u_utils.h @@ -14,12 +14,9 @@ #define U_UTILS_H #include -#include -#include void u_eof_stdin(void); uint64_t u_builtins_get_argc(const char *args[]); char **u_get_env_var_names(t_msh *msh); -int u_handle_sigwinch(int dummy_signal); #endif -- cgit v1.2.3