diff --git a/Makefile b/Makefile index c1a1cb7..79a8eb1 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,7 @@ ifeq ($(CFLAGS),) endif export CFLAGS srcs = \ + src/parser/matchers/metacharacter.c objs = $(srcs:.c=.o) export objs diff --git a/src/parser/matchers/metacharacter.c b/src/parser/matchers/metacharacter.c new file mode 100644 index 0000000..7ae4756 --- /dev/null +++ b/src/parser/matchers/metacharacter.c @@ -0,0 +1,30 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* metacharacter.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kcolin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2025/02/06 15:23:31 by kcolin #+# #+# */ +/* Updated: 2025/02/06 15:47:42 by kcolin ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "metacharacter.h" + +// FIXME: use ft_strchr +/* +** return true if the character is a metacharacter +** +** Bash reference manual: +** A character that, when unquoted, separates words. A metacharacter is a space, +** tab, newline, or one of the following characters: ‘|’, ‘&’, ‘;’, ‘(’, ‘)’, +** ‘<’, or ‘>’. +*/ +bool is_metacharacter(char c) +{ + if (c == ' ' || c == '\t' || c == '\n' || c == '|' || c == '&' || c == ';' + || c == '(' || c == ')' || c == '<' || c == '>') + return (true); + return (false); +} diff --git a/src/parser/matchers/metacharacter.h b/src/parser/matchers/metacharacter.h new file mode 100644 index 0000000..4e8935b --- /dev/null +++ b/src/parser/matchers/metacharacter.h @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* metacharacter.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kcolin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2025/02/06 15:22:57 by kcolin #+# #+# */ +/* Updated: 2025/02/06 15:22:57 by kcolin ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef METACHARACTER_H +# define METACHARACTER_H + +# include + +bool is_metacharacter(char c); + +#endif