#129 + modif msg d'erreur historique corrompu
This commit is contained in:
parent
767934736b
commit
1ce1ce2cd1
9 changed files with 34 additions and 16 deletions
|
|
@ -6,14 +6,14 @@
|
||||||
# By: wescande <wescande@student.42.fr> +#+ +:+ +#+ #
|
# By: wescande <wescande@student.42.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2016/08/29 21:32:58 by wescande #+# #+# #
|
# Created: 2016/08/29 21:32:58 by wescande #+# #+# #
|
||||||
# Updated: 2017/03/21 00:39:34 by ariard ### ########.fr #
|
# Updated: 2017/03/21 10:36:25 by gwojda ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
NAME = 42sh
|
NAME = 42sh
|
||||||
|
|
||||||
CC = gcc
|
CC = gcc
|
||||||
FLAGS = -Wall -Wextra -Werror -fvisibility=hidden #-fsanitize=address
|
FLAGS = -Wall -Wextra -Werror -fvisibility=hidden -fsanitize=address
|
||||||
D_FLAGS = -g
|
D_FLAGS = -g
|
||||||
|
|
||||||
DELTA = $$(echo "$$(tput cols)-47"|bc)
|
DELTA = $$(echo "$$(tput cols)-47"|bc)
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/23 10:35:44 by gwojda #+# #+# */
|
/* Created: 2017/01/23 10:35:44 by gwojda #+# #+# */
|
||||||
/* Updated: 2017/03/20 12:32:15 by gwojda ### ########.fr */
|
/* Updated: 2017/03/21 10:02:04 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -55,6 +55,8 @@
|
||||||
# define TOUCHE_F5 892427035
|
# define TOUCHE_F5 892427035
|
||||||
# define TOUCHE_F6 925981467
|
# define TOUCHE_F6 925981467
|
||||||
|
|
||||||
|
# define SIZE_LINE 512
|
||||||
|
|
||||||
# define CORRUPT 1
|
# define CORRUPT 1
|
||||||
|
|
||||||
# define ERROR_CNTL_R 1
|
# define ERROR_CNTL_R 1
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/08 17:20:01 by gwojda #+# #+# */
|
/* Created: 2017/03/08 17:20:01 by gwojda #+# #+# */
|
||||||
/* Updated: 2017/03/18 12:23:18 by gwojda ### ########.fr */
|
/* Updated: 2017/03/21 10:09:42 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -34,10 +34,16 @@ static void c_replace_globbing(char **glob, size_t start)
|
||||||
ref_mid = ft_sstrtostr(glob, " ");
|
ref_mid = ft_sstrtostr(glob, " ");
|
||||||
ref_next = ft_strdup(str + pos);
|
ref_next = ft_strdup(str + pos);
|
||||||
data_singleton()->line.input = ft_str3join(ref_prev, ref_mid, ref_next);
|
data_singleton()->line.input = ft_str3join(ref_prev, ref_mid, ref_next);
|
||||||
free(ref_prev);
|
if (ft_strlen(data_singleton()->line.input) > SIZE_LINE)
|
||||||
free(ref_mid);
|
{
|
||||||
free(ref_next);
|
ft_strdel(&data_singleton()->line.input);
|
||||||
free(str);
|
data_singleton()->line.input = str;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ft_strdel(&str);
|
||||||
|
ft_strdel(&ref_prev);
|
||||||
|
ft_strdel(&ref_mid);
|
||||||
|
ft_strdel(&ref_next);
|
||||||
ft_sstrfree(glob);
|
ft_sstrfree(glob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/19 12:45:06 by gwojda #+# #+# */
|
/* Created: 2016/12/19 12:45:06 by gwojda #+# #+# */
|
||||||
/* Updated: 2017/03/17 11:56:42 by gwojda ### ########.fr */
|
/* Updated: 2017/03/21 10:32:34 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -49,8 +49,12 @@ int ft_v(char **str, size_t *pos)
|
||||||
if (!*str || !tmp)
|
if (!*str || !tmp)
|
||||||
return (0);
|
return (0);
|
||||||
while (tmp[++i])
|
while (tmp[++i])
|
||||||
|
{
|
||||||
|
if (ft_strlen(*str) > SIZE_LINE)
|
||||||
|
break ;
|
||||||
if (!(*str = ft_realloc_imput(*str, tmp[i], *pos + i)))
|
if (!(*str = ft_realloc_imput(*str, tmp[i], *pos + i)))
|
||||||
return (-1);
|
return (-1);
|
||||||
|
}
|
||||||
if (*pos)
|
if (*pos)
|
||||||
{
|
{
|
||||||
--(*pos);
|
--(*pos);
|
||||||
|
|
@ -75,7 +79,7 @@ int ft_x(char **str, size_t *pos)
|
||||||
ft_strdel(tmp);
|
ft_strdel(tmp);
|
||||||
if (!(*tmp = ft_strdupi_space(&(*str)[*pos])))
|
if (!(*tmp = ft_strdupi_space(&(*str)[*pos])))
|
||||||
return (-1);
|
return (-1);
|
||||||
i = ft_strlen(*tmp);
|
i = ft_strlen(*tmp) - 1;
|
||||||
while (i >= 0)
|
while (i >= 0)
|
||||||
{
|
{
|
||||||
if (!(*str = ft_remove_imput(*str, *pos + i)))
|
if (!(*str = ft_remove_imput(*str, *pos + i)))
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/19 16:28:49 by gwojda #+# #+# */
|
/* Created: 2016/12/19 16:28:49 by gwojda #+# #+# */
|
||||||
/* Updated: 2017/03/18 11:19:01 by gwojda ### ########.fr */
|
/* Updated: 2017/03/21 10:34:46 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/07 17:34:23 by gwojda #+# #+# */
|
/* Created: 2017/03/07 17:34:23 by gwojda #+# #+# */
|
||||||
/* Updated: 2017/03/17 16:01:44 by gwojda ### ########.fr */
|
/* Updated: 2017/03/21 10:39:24 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -29,7 +29,7 @@ static int ft_str_is_print(char *str)
|
||||||
static void corrupt_history(int corrupt, char *home)
|
static void corrupt_history(int corrupt, char *home)
|
||||||
{
|
{
|
||||||
if (corrupt)
|
if (corrupt)
|
||||||
ft_dprintf(2, "42sh: corrupt history file %s/.zsh_history\n", home);
|
ft_dprintf(2, "42sh: corrupt history file %s/.42sh_history\n", home);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ft_init_history(void)
|
void ft_init_history(void)
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/16 16:14:46 by gwojda #+# #+# */
|
/* Created: 2016/12/16 16:14:46 by gwojda #+# #+# */
|
||||||
/* Updated: 2017/03/16 16:39:24 by gwojda ### ########.fr */
|
/* Updated: 2017/03/21 10:03:23 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -20,6 +20,8 @@ char *ft_realloc_imput(char *str, int a, size_t pos)
|
||||||
|
|
||||||
tmp[0] = (char)a;
|
tmp[0] = (char)a;
|
||||||
tmp[1] = '\0';
|
tmp[1] = '\0';
|
||||||
|
if (ft_strlen(str) > SIZE_LINE)
|
||||||
|
return (str);
|
||||||
if (!str)
|
if (!str)
|
||||||
{
|
{
|
||||||
new_str = ft_strdup(tmp);
|
new_str = ft_strdup(tmp);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/05 16:02:43 by gwojda #+# #+# */
|
/* Created: 2017/01/05 16:02:43 by gwojda #+# #+# */
|
||||||
/* Updated: 2017/03/17 12:32:51 by gwojda ### ########.fr */
|
/* Updated: 2017/03/21 10:14:46 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -28,6 +28,8 @@ int ft_print(int ret, char **str, size_t *pos)
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
j = 0;
|
j = 0;
|
||||||
|
if (ft_strlen(*str) > SIZE_LINE)
|
||||||
|
return (0);
|
||||||
if (!(*str = ft_realloc_imput(*str, ret, *pos)))
|
if (!(*str = ft_realloc_imput(*str, ret, *pos)))
|
||||||
return (-1);
|
return (-1);
|
||||||
while (*(*str + *pos + j) && *(*str + *pos + j) != '\n')
|
while (*(*str + *pos + j) && *(*str + *pos + j) != '\n')
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/19 16:52:57 by gwojda #+# #+# */
|
/* Created: 2016/12/19 16:52:57 by gwojda #+# #+# */
|
||||||
/* Updated: 2017/03/17 10:47:31 by gwojda ### ########.fr */
|
/* Updated: 2017/03/21 10:15:13 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -23,6 +23,8 @@ static int ft_read_it_3(char **str, char t[5], size_t *pos, int *j)
|
||||||
{
|
{
|
||||||
if (t[i] && ft_isprint(t[i]))
|
if (t[i] && ft_isprint(t[i]))
|
||||||
{
|
{
|
||||||
|
if (ft_strlen(*str) > SIZE_LINE)
|
||||||
|
return (0);
|
||||||
if (!(*str = ft_realloc_imput(*str, t[i], *pos)))
|
if (!(*str = ft_realloc_imput(*str, t[i], *pos)))
|
||||||
return (-1);
|
return (-1);
|
||||||
++(*pos);
|
++(*pos);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue