"allez"
This commit is contained in:
Antoine Riard 2017-03-29 15:23:27 +02:00
commit 85b6cb2493
4 changed files with 22 additions and 22 deletions

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 18:08:31 by jhalford #+# #+# */
/* Updated: 2017/03/22 22:23:33 by wescande ### ########.fr */
/* Updated: 2017/03/29 14:48:09 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,11 +14,15 @@
char *ft_strtok(char *s, const char *delim)
{
static char *lasts;
int ch;
static char *lasts = NULL;
int ch;
if (s == 0)
if (!s)
{
if (!lasts)
return (NULL);
s = lasts;
}
if ((ch = *s++) == 0)
return (0);
while (ft_strchr(delim, ch))

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/25 16:02:05 by jhalford #+# #+# */
/* Updated: 2017/03/25 04:20:00 by jhalford ### ########.fr */
/* Updated: 2017/03/29 15:02:36 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -28,12 +28,9 @@ int bt_read_terminit(t_read *data)
term = bt_read_term(1);
if (!(data->flag & BT_READ_INTER))
return (0);
term.c_lflag = ECHO | ECHOE | ECHOK | ICANON;
term.c_lflag &= data->timeout ? ~ICANON : ~0;
term.c_lflag &= ~(ICANON | ECHO);
term.c_cc[VTIME] = data->timeout * 10;
term.c_cc[VMIN] = data->timeout ? 0 : 1;
if (data->flag & BT_READ_LS)
term.c_lflag &= ~ECHO;
term.c_cc[VEOL] = data->delim;
if (tcsetattr(0, TCSANOW, &term) < 0)
{

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/20 15:01:45 by jhalford #+# #+# */
/* Updated: 2017/03/25 15:10:27 by jhalford ### ########.fr */
/* Updated: 2017/03/29 15:19:11 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -53,14 +53,14 @@ int bt_read_loop(t_read *data)
char buf[2];
esc = 0;
i = 0;
if (data->prompt && (data->flag & BT_READ_INTER))
ft_printf(data->prompt);
if (!(i = 0) && data->prompt && (data->flag & BT_READ_INTER))
ft_putstr(data->prompt);
while (42)
{
if ((ret = read(data->fd, buf, 1)) <= 0)
if ((ret = read(data->fd, buf, 4)) <= 0)
return (ret);
buf[ret] = 0;
ft_putchar(data->flag & BT_READ_LS ? 0 : *buf);
if (!esc && *buf == data->delim)
break ;
esc = esc ? 0 : !(data->flag & BT_READ_LR) && (*buf == '\\');
@ -89,11 +89,10 @@ int bt_read_assign(t_read *data)
tok = ft_strtok(input, ifs);
while (*names)
{
if (!(builtin_setenv("setenv", (char*[]){"read", *names, tok}, NULL)))
if ((builtin_setenv("setenv", (char*[]){"read", *names, tok}, NULL)))
return (1);
ifs = names[1] ? ifs : NULL;
ifs = (++names)[1] ? ifs : NULL;
tok = ft_strtok(NULL, ifs);
names++;
}
return (0);
}

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/17 17:47:53 by wescande #+# #+# */
/* Updated: 2017/03/23 03:20:10 by wescande ### ########.fr */
/* Updated: 2017/03/29 14:59:17 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
@ -44,7 +44,7 @@ static void init_expand(t_bquote *me, char *content, int doifs)
char *content2;
ifs = doifs ? ft_getenv(data_singleton()->local_var, "IFS") : NULL;
content = ft_strtok(content, ifs);
content = content ? ft_strtok(content, ifs) : content;
if (!content || !(content2 = ft_strtok(NULL, ifs)))
{
ft_ld_pushfront(me->wk, gen_tab(ft_strjoinf(ft_strjoin(me->s1, content),
@ -83,9 +83,9 @@ static int search_bquote(t_bquote *me)
me->mid = ft_strsub(sta, 1, me->str - sta - 1);
me->s1 = ft_strsub(CH(*me->wk)[0], 0, sta - CH(*me->wk)[0]);
me->s2 = ft_strdup(me->str + 1);
if ((content = get_output(me->mid)))
init_expand(me, content,
!is_char_esc(me->esc, CH(*me->wk)[0], sta));
content = get_output(me->mid);
init_expand(me, content,
!is_char_esc(me->esc, CH(*me->wk)[0], sta));
ft_strdel(&me->mid);
ft_strdel(&me->s1);
ft_strdel(&me->s2);