lexer function increment lexer.pos not lexer.str

This commit is contained in:
Jack Halford 2017-02-19 14:43:45 +01:00
parent f05172b9e1
commit 8abf9fe433
6 changed files with 9 additions and 24 deletions

1
42sh/.gitignore vendored
View file

@ -2,6 +2,7 @@ minishell
21sh
42sh
out
STDBUG
debug
.42sh_history
*.dSYM

View file

@ -1,18 +0,0 @@
4
42sh
Makefile
Session.vim
debug
donovan_segaults_06-02
file
file1
file2
file3
includes
libft
objs
out
pdf
script.sh
src
update_makefile.sh

@ -1 +1 @@
Subproject commit a82ea94ef7f50f8396d7bf6f9c08ab4a7faa994d
Subproject commit 0ca8ca817f32fc0345ef93ef74a3abe2583bd89c

View file

@ -21,13 +21,13 @@ int lexer_greatand(t_list **alst, t_lexer *lexer)
if (ft_isdigit(lexer->str[lexer->pos]))
{
token_append(token, lexer, 0, 0);
lexer->str++;
lexer->pos++;
return (lexer_greatand(alst, lexer));
}
else if (lexer->str[lexer->pos] == '-')
{
token_append(token, lexer, 0, 0);
lexer->str++;
lexer->pos++;
lexer->state = DEFAULT;
return (lexer_lex(&(*alst)->next, lexer));
}

View file

@ -21,13 +21,13 @@ int lexer_lessand(t_list **alst, t_lexer *lexer)
if (ft_isdigit(lexer->str[lexer->pos]))
{
token_append(token, lexer, 0, 0);
lexer->str++;
lexer->pos++;
return (lexer_lessand(alst, lexer));
}
else if (lexer->str[lexer->pos] == '-')
{
token_append(token, lexer, 0, 0);
lexer->str++;
lexer->pos++;
lexer->state = DEFAULT;
return (lexer_lex(&(*alst)->next, lexer));
}

View file

@ -53,7 +53,8 @@ int interactive_shell()
token = NULL;
ast = NULL;
do {
ft_strappend(&lexer.str, readline(stack_to_prompt(lexer.stack)));
char *str = readline(stack_to_prompt(lexer.stack));
ft_strappend(&lexer.str, str);
if (get_lexer_stack(lexer) == BACKSLASH)
pop(&lexer.stack);
else if (get_lexer_stack(lexer) == DLESS)
@ -74,6 +75,7 @@ int interactive_shell()
btree_print(STDBUG, ast, &ft_putast);
if (ft_exec(&ast))
return (1);
DG("gonna free [%s] @ [%p]", lexer.str, lexer.str);
ft_strdel(&lexer.str);
return (0);
}