Skip to content
This repository has been archived by the owner on Nov 30, 2024. It is now read-only.

Commit

Permalink
norminette
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandra Quesada committed Nov 10, 2022
1 parent 7534ba6 commit 4f81482
Show file tree
Hide file tree
Showing 19 changed files with 209 additions and 32 deletions.
5 changes: 3 additions & 2 deletions libft/ft_isspace.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: mcombeau <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/22 13:53:06 by mcombeau #+# #+# */
/* Updated: 2022/09/25 14:52:20 by mcombeau ### ########.fr */
/* Updated: 2022/11/10 00:57:38 by alexa ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -20,7 +20,8 @@

int ft_isspace(int c)
{
if (c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '\v' || c == '\f')
if (c == ' ' || c == '\t' || c == '\n' || c == '\r'
|| c == '\v' || c == '\f')
return (c);
return (0);
}
2 changes: 1 addition & 1 deletion minitester
Submodule minitester updated 1 files
+4 −7 minitester.sh
11 changes: 11 additions & 0 deletions sources/expansion/replace_var.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* replace_var.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: alexa <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/10 00:51:45 by alexa #+# #+# */
/* Updated: 2022/11/10 00:51:47 by alexa ### ########.fr */
/* */
/* ************************************************************************** */

#include "minishell.h"

Expand Down
11 changes: 11 additions & 0 deletions sources/expansion/var_expander_utils.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* var_expander_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: alexa <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/10 00:52:09 by alexa #+# #+# */
/* Updated: 2022/11/10 00:52:18 by alexa ### ########.fr */
/* */
/* ************************************************************************** */

#include "minishell.h"

Expand Down
12 changes: 12 additions & 0 deletions sources/lexer/parse_user_input.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parse_user_input.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: alexa <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/10 00:01:18 by alexa #+# #+# */
/* Updated: 2022/11/10 00:01:22 by alexa ### ########.fr */
/* */
/* ************************************************************************** */

#include "minishell.h"

static bool input_is_space(char *input)
Expand Down
Binary file added sources/parser/.fill_args_echo_utils.c.swp
Binary file not shown.
11 changes: 11 additions & 0 deletions sources/parser/cmd_lst_utils.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* cmd_lst_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: alexa <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/10 00:22:15 by alexa #+# #+# */
/* Updated: 2022/11/10 00:22:18 by alexa ### ########.fr */
/* */
/* ************************************************************************** */

#include "minishell.h"

Expand Down
12 changes: 12 additions & 0 deletions sources/parser/cmd_lst_utils_cleanup.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* cmd_lst_utils_cleanup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: alexa <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/10 00:21:24 by alexa #+# #+# */
/* Updated: 2022/11/10 00:21:27 by alexa ### ########.fr */
/* */
/* ************************************************************************** */

#include "minishell.h"

void lst_delone_cmd(t_command *lst, void (*del)(void *))
Expand Down
12 changes: 12 additions & 0 deletions sources/parser/create_commands.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* create_commands.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: alexa <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/10 00:16:58 by alexa #+# #+# */
/* Updated: 2022/11/10 00:17:32 by alexa ### ########.fr */
/* */
/* ************************************************************************** */

#include "minishell.h"

static void prep_no_arg_commands(t_data *data)
Expand Down
34 changes: 28 additions & 6 deletions sources/parser/fill_args_default.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* fill_args_default.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: alexa <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/10 00:05:49 by alexa #+# #+# */
/* Updated: 2022/11/10 00:45:21 by alexa ### ########.fr */
/* */
/* ************************************************************************** */

#include "minishell.h"

int count_arguments(t_token *temp)
{
int i;

i = 0;
while (temp && (temp->type == WORD || temp->type == VAR))
{
i++;
temp = temp->next;
}
return (i);
}

/*
** This function fills the array of arguments of the last_cmd by default mode:
** - It allocates the array of arguments thanks to the count_args function
Expand All @@ -10,16 +35,13 @@
int create_args_default_mode(t_token **token_node, t_command *last_cmd)
{
int i;
int nb_args;
t_token *temp;

i = 0;
temp = *token_node;
while (temp->type == WORD || temp->type == VAR)
{
i++;
temp = temp->next;
}
last_cmd->args = malloc(sizeof(char *) * (i + 2));
nb_args = count_arguments(temp);
last_cmd->args = malloc(sizeof(char *) * (nb_args + 2));
if (!last_cmd->args)
return (FAILURE);
temp = *token_node;
Expand Down
11 changes: 11 additions & 0 deletions sources/parser/fill_args_echo.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* fill_args_echo.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: alexa <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/10 00:02:55 by alexa #+# #+# */
/* Updated: 2022/11/10 00:03:12 by alexa ### ########.fr */
/* */
/* ************************************************************************** */

#include "minishell.h"

Expand Down
12 changes: 12 additions & 0 deletions sources/parser/fill_args_echo_utils.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* fill_args_echo_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: alexa <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/10 00:10:11 by alexa #+# #+# */
/* Updated: 2022/11/10 00:11:41 by alexa ### ########.fr */
/* */
/* ************************************************************************** */

#include "minishell.h"

/*
Expand Down
12 changes: 12 additions & 0 deletions sources/parser/parse_append.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parse_append.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: alexa <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/10 00:06:46 by alexa #+# #+# */
/* Updated: 2022/11/10 00:08:37 by alexa ### ########.fr */
/* */
/* ************************************************************************** */

#include "minishell.h"

/*
Expand Down
12 changes: 12 additions & 0 deletions sources/parser/parse_heredoc.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parse_heredoc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: alexa <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/10 00:09:01 by alexa #+# #+# */
/* Updated: 2022/11/10 00:09:19 by alexa ### ########.fr */
/* */
/* ************************************************************************** */

#include "minishell.h"

/* get_heredoc:
Expand Down
12 changes: 12 additions & 0 deletions sources/parser/parse_heredoc_utils.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parse_heredoc_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: alexa <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/10 00:09:37 by alexa #+# #+# */
/* Updated: 2022/11/10 00:09:40 by alexa ### ########.fr */
/* */
/* ************************************************************************** */

#include "minishell.h"

/* make_str_from_tab:
Expand Down
28 changes: 12 additions & 16 deletions sources/parser/parse_input.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parse_input.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: alexa <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/10 00:20:39 by alexa #+# #+# */
/* Updated: 2022/11/10 00:20:42 by alexa ### ########.fr */
/* */
/* ************************************************************************** */

#include "minishell.h"

/* INPUT -> REDIR_IN (<)
Expand All @@ -7,13 +19,6 @@
The general format for redirecting input is: [n]<word
Source : https://www.gnu.org/software/bash/manual/bash.html#Redirections
Exemple : sort < mylist.txt => on trie dans l'ordre alphabetique le contenu qui se
trouve dans "mylist.txt".
wc -l < test.txt => affiche le nb de lignes dans le fichier test
Probleme car avec ECHO ça marche différemment :
https://unix.stackexchange.com/questions/63658/redirecting-the-content-of-a-file-to-the-command-echo)
*/

bool remove_old_file_ref(t_io_fds *io, bool infile)
Expand Down Expand Up @@ -41,15 +46,6 @@ bool remove_old_file_ref(t_io_fds *io, bool infile)
return (true);
}

/*
static void display_error(t_command *cmd, char *infile)
{
cmd->error = errno;
cmd->err_msg = ft_strdup(strerror(errno));
printf("bash: %s: %s\n", infile, cmd->err_msg);
}
*/

/* open_infile:
* Opens an infile. If an infile was already set, frees it
* and overwrites it. If a previous infile open failed (file does
Expand Down
18 changes: 12 additions & 6 deletions sources/parser/parse_pipe.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parse_pipe.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: alexa <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/10 00:22:49 by alexa #+# #+# */
/* Updated: 2022/11/10 00:22:52 by alexa ### ########.fr */
/* */
/* ************************************************************************** */

#include "minishell.h"

// ex : echo bonjour | wc -l
/*
une commande deja cree : pour echo bonjour
on arrive au pipe : on doit creer une nouvelle commande
puis creer une aure commande
*/
void parse_pipe(t_command **cmd, t_token **token_lst)
{
t_command *last_cmd;
Expand Down
14 changes: 13 additions & 1 deletion sources/parser/parse_trunc.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parse_trunc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: alexa <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/10 00:16:18 by alexa #+# #+# */
/* Updated: 2022/11/10 00:16:26 by alexa ### ########.fr */
/* */
/* ************************************************************************** */

#include "minishell.h"

/*
Expand Down Expand Up @@ -87,4 +99,4 @@ exemple : grep test > test.txt test1.txt
*si line commence par un TRUNC (>) il faut creer la liste chainee,
et faire condition existence cmd + fonction pour corriger ca
*/
*/
12 changes: 12 additions & 0 deletions sources/parser/parse_word.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parse_word.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: alexa <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/10 00:21:47 by alexa #+# #+# */
/* Updated: 2022/11/10 00:22:01 by alexa ### ########.fr */
/* */
/* ************************************************************************** */

#include "minishell.h"

static bool contains_space(char *str)
Expand Down

0 comments on commit 4f81482

Please sign in to comment.