correction segv edition de ligne + ajout table de hash

This commit is contained in:
gwojda 2017-02-18 14:44:41 +01:00
commit 36f45536fe
4 changed files with 20 additions and 16 deletions

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/17 15:38:14 by jhalford #+# #+# */ /* Created: 2017/02/17 15:38:14 by jhalford #+# #+# */
/* Updated: 2017/02/17 15:44:48 by jhalford ### ########.fr */ /* Updated: 2017/02/17 16:29:42 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */ /* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/27 18:19:55 by wescande #+# #+# */ /* Created: 2017/01/27 18:19:55 by wescande #+# #+# */
/* Updated: 2017/02/17 15:45:15 by jhalford ### ########.fr */ /* Updated: 2017/02/17 16:29:20 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,21 +6,19 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/11 16:46:27 by jhalford #+# #+# */ /* Created: 2017/01/11 16:46:27 by jhalford #+# #+# */
/* Updated: 2017/02/17 15:48:39 by jhalford ### ########.fr */ /* Updated: 2017/02/17 16:34:34 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "lexer.h" #include "lexer.h"
int bquotes_insert_words(t_list *cur_word, char *word, char *after_bq) int bquotes_insert_words(t_list *cur_word, char *word, char *after_bq, char *ifs)
{ {
char *ifs;
t_list *new_word; t_list *new_word;
t_list *after_word; t_list *after_word;
t_token *token; t_token *token;
after_word = cur_word->next; after_word = cur_word->next;
ifs = ft_getenv(data_singleton()->env, "IFS");
if (ifs) if (ifs)
word = ft_strtok(word, ifs); word = ft_strtok(word, ifs);
token = cur_word->content; token = cur_word->content;
@ -46,6 +44,8 @@ int bquotes_substitute(t_list *cur_word, char *bq_start, char *bq_end)
char *output; char *output;
char *last_char; char *last_char;
char *after_bq; char *after_bq;
char *ifs;
t_token *token;
*bq_start = 0; *bq_start = 0;
*bq_end = 0; *bq_end = 0;
@ -57,7 +57,10 @@ int bquotes_substitute(t_list *cur_word, char *bq_start, char *bq_end)
} }
DG("output = [%s]", output); DG("output = [%s]", output);
after_bq = ft_strdup(bq_end + 1); after_bq = ft_strdup(bq_end + 1);
bquotes_insert_words(cur_word, output ? output : "", after_bq); token = cur_word->content;
ifs = is_char_esc(token->esc, token->data, bq_start) ?
NULL : ft_getenv(data_singleton()->env, "IFS");
bquotes_insert_words(cur_word, output ? output : "", after_bq, ifs);
ft_strdel(&output); ft_strdel(&output);
ft_strdel(&after_bq); ft_strdel(&after_bq);
return (0); return (0);
@ -66,17 +69,18 @@ int bquotes_substitute(t_list *cur_word, char *bq_start, char *bq_end)
int bquotes_expand(t_list **alst) int bquotes_expand(t_list **alst)
{ {
t_list *cur_word; t_list *cur_word;
t_list *lst;
char *bq_start; char *bq_start;
char *bq_end; char *bq_end;
t_flag tk; t_flag tk_word;
t_token *token;
tk = TK_WORD; tk_word = TK_WORD;
cur_word = *alst; cur_word = *alst;
while ((lst = ft_lst_find(cur_word, &tk, token_cmp_type))) while ((cur_word = ft_lst_find(cur_word, &tk_word, token_cmp_type)))
{ {
cur_word = lst; token = cur_word->content;
if (!(bq_start = ft_strchr(((t_token*)cur_word->content)->data, '`'))) if (!(bq_start = ft_strchr(token->data, '`'))
|| is_char_esc(token->esc2, token->data, bq_start))
{ {
cur_word = cur_word->next; cur_word = cur_word->next;
return (0); return (0);
@ -88,9 +92,9 @@ int bquotes_expand(t_list **alst)
} }
if (bquotes_substitute(cur_word, bq_start, bq_end)) if (bquotes_substitute(cur_word, bq_start, bq_end))
return (-1); return (-1);
if (!(*((t_token*)cur_word->content)->data)) if (!(*token->data))
ft_lst_delif(alst, cur_word->content, ft_addrcmp, token_free); ft_lst_delif(alst, cur_word->content, ft_addrcmp, token_free);
cur_word = lst; cur_word = *alst;
} }
return (0); return (0);
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */ /* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */
/* Updated: 2017/02/17 15:26:59 by jhalford ### ########.fr */ /* Updated: 2017/02/17 16:35:24 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */