mirror of
https://github.com/KeyZox71/ft_minipowershell.git
synced 2025-03-15 11:26:51 +01:00
「✨」 feat: Check for unclosed quote
This commit is contained in:
@ -6,7 +6,7 @@
|
|||||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/04/25 12:20:26 by adjoly #+# #+# */
|
/* Created: 2024/04/25 12:20:26 by adjoly #+# #+# */
|
||||||
/* Updated: 2024/06/18 12:58:53 by adjoly ### ########.fr */
|
/* Updated: 2024/06/21 12:41:11 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -42,6 +42,7 @@ char **split_argv(char *readline);
|
|||||||
char *env_var_replace(char *readline, t_env *env);
|
char *env_var_replace(char *readline, t_env *env);
|
||||||
size_t get_size_with_env(char *readline, t_env *env);
|
size_t get_size_with_env(char *readline, t_env *env);
|
||||||
size_t strlen_till_char(char *s, int c);
|
size_t strlen_till_char(char *s, int c);
|
||||||
|
void check_quote(char *readline);
|
||||||
/**
|
/**
|
||||||
* @brief Take the argv of a command a split the argv and the
|
* @brief Take the argv of a command a split the argv and the
|
||||||
* command it self
|
* command it self
|
||||||
|
48
src/parsing/check_error/check_quote.c
Normal file
48
src/parsing/check_error/check_quote.c
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* check_quote.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2024/06/21 11:59:34 by adjoly #+# #+# */
|
||||||
|
/* Updated: 2024/06/21 12:40:56 by adjoly ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "parsing.h"
|
||||||
|
#include "tokenizer.h"
|
||||||
|
|
||||||
|
size_t count_quote(char *readline, t_quote type)
|
||||||
|
{
|
||||||
|
char *tmp;
|
||||||
|
size_t count;
|
||||||
|
|
||||||
|
tmp = readline;
|
||||||
|
count = 0;
|
||||||
|
while (*tmp)
|
||||||
|
{
|
||||||
|
if (*tmp == type)
|
||||||
|
count++;
|
||||||
|
tmp++;
|
||||||
|
}
|
||||||
|
return (count);
|
||||||
|
}
|
||||||
|
|
||||||
|
void check_quote(char *readline)
|
||||||
|
{
|
||||||
|
size_t count;
|
||||||
|
|
||||||
|
count = count_quote(readline, DOUBLE);
|
||||||
|
if (count % 2)
|
||||||
|
{
|
||||||
|
ft_putendl_fd("double quote error", STDERR_FILENO);
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
count = count_quote(readline, SINGLE);
|
||||||
|
if (count % 2)
|
||||||
|
{
|
||||||
|
ft_putendl_fd("single quote error", STDERR_FILENO);
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
@ -6,7 +6,7 @@
|
|||||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/20 20:06:13 by adjoly #+# #+# */
|
/* Created: 2024/05/20 20:06:13 by adjoly #+# #+# */
|
||||||
/* Updated: 2024/06/20 14:35:26 by adjoly ### ########.fr */
|
/* Updated: 2024/06/20 17:41:33 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user