-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed bug in lexer that would cause it to create bad nodes for spaces
- Loading branch information
Jean Teissier
authored and
Jean Teissier
committed
Jul 17, 2024
1 parent
3f62f47
commit 615cee0
Showing
6 changed files
with
55 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: jteissie <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2024/06/07 16:53:36 by jteissie #+# #+# */ | ||
/* Updated: 2024/07/17 14:25:18 by jteissie ### ########.fr */ | ||
/* Updated: 2024/07/17 18:55:34 by jteissie ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -23,10 +23,12 @@ | |
# define EXIT_FAILURE 1 | ||
# define CHILD 0 | ||
# define PARENT 1 | ||
# define BUILT_IN 2 | ||
|
||
void trash(char **array); | ||
void handle_error(char *message, int code); | ||
void execute_cmd(char *cmd, char **env, t_parser *data); | ||
int count_commands(t_parser *data); | ||
|
||
int process_files(t_lex_parser *table); | ||
int get_redirections(t_lex_parser *roaming, char *redirection[]); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: jteissie <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2024/06/07 14:19:59 by jteissie #+# #+# */ | ||
/* Updated: 2024/07/17 14:28:01 by jteissie ### ########.fr */ | ||
/* Updated: 2024/07/17 18:56:55 by jteissie ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -35,43 +35,41 @@ void wait_for_children(int index) | |
} | ||
} | ||
|
||
int count_commands(t_parser *data) | ||
int filter_cmd(t_lex_parser *roaming, char **envp, int std_fds[], t_parser *data) | ||
{ | ||
t_lex_parser *roaming; | ||
t_cmd_table *cmd_table; | ||
int cmd_count; | ||
|
||
roaming = data->node; | ||
cmd_count = 0; | ||
while (roaming) | ||
cmd_count = count_commands(data); | ||
cmd_table = roaming->table; | ||
if (cmd_count == 1 && is_builtin(cmd_table->cmd, 0) == TRUE) | ||
{ | ||
if (roaming->type == TK_PARS_CMD) | ||
{ | ||
cmd_count++; | ||
} | ||
roaming = roaming->next; | ||
execute_builtin(cmd_table->cmd, envp, data, PARENT); | ||
return (BUILT_IN); | ||
} | ||
return (cmd_count); | ||
else if (process_command(roaming, envp, data, std_fds) == PANIC) | ||
return (PANIC); | ||
return (SUCCESS); | ||
} | ||
|
||
int execute_commands(t_parser *data, char **envp, int std_fds[]) | ||
{ | ||
int cmd_count; | ||
int index; | ||
int status; | ||
t_lex_parser *roaming; | ||
t_cmd_table *cmd_table; | ||
|
||
cmd_count = count_commands(data); | ||
index = cmd_count; | ||
roaming = data->node; | ||
status = SUCCESS; | ||
while (roaming && index) | ||
{ | ||
if (roaming->type == TK_PARS_CMD) | ||
{ | ||
cmd_table = roaming->table; | ||
if (cmd_count == 1 && is_builtin(cmd_table->cmd, 0) == TRUE) | ||
execute_builtin(cmd_table->cmd, envp, data, PARENT); | ||
else if (process_command(roaming, envp, data, std_fds) == PANIC) | ||
return (PANIC); | ||
status = filter_cmd(roaming, envp, std_fds, data); | ||
if (status == BUILT_IN || status == PANIC) | ||
break ; | ||
index--; | ||
} | ||
roaming = roaming->next; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: jteissie <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2024/06/07 18:14:25 by jteissie #+# #+# */ | ||
/* Updated: 2024/07/17 14:24:46 by jteissie ### ########.fr */ | ||
/* Updated: 2024/07/17 18:55:04 by jteissie ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -34,6 +34,24 @@ void trash(char **array) | |
free(array); | ||
} | ||
|
||
int count_commands(t_parser *data) | ||
{ | ||
t_lex_parser *roaming; | ||
int cmd_count; | ||
|
||
roaming = data->node; | ||
cmd_count = 0; | ||
while (roaming) | ||
{ | ||
if (roaming->type == TK_PARS_CMD) | ||
{ | ||
cmd_count++; | ||
} | ||
roaming = roaming->next; | ||
} | ||
return (cmd_count); | ||
} | ||
|
||
void check_pipes(t_lex_parser *table, int pipe_status[]) | ||
{ | ||
t_lex_parser *roaming; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters