rectif bquote vide + protection strtok
This commit is contained in:
parent
e87dbff14c
commit
042785b412
2 changed files with 13 additions and 9 deletions
|
|
@ -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;
|
||||
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))
|
||||
|
|
|
|||
|
|
@ -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,7 +83,7 @@ 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)))
|
||||
content = get_output(me->mid);
|
||||
init_expand(me, content,
|
||||
!is_char_esc(me->esc, CH(*me->wk)[0], sta));
|
||||
ft_strdel(&me->mid);
|
||||
|
|
|
|||
Loading…
Reference in a new issue