mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
new matcher: metacharacter (separates words)
This commit is contained in:
parent
60d9b212fb
commit
7a99014485
3 changed files with 51 additions and 0 deletions
1
Makefile
1
Makefile
|
|
@ -11,6 +11,7 @@ ifeq ($(CFLAGS),)
|
||||||
endif
|
endif
|
||||||
export CFLAGS
|
export CFLAGS
|
||||||
srcs = \
|
srcs = \
|
||||||
|
src/parser/matchers/metacharacter.c
|
||||||
|
|
||||||
objs = $(srcs:.c=.o)
|
objs = $(srcs:.c=.o)
|
||||||
export objs
|
export objs
|
||||||
|
|
|
||||||
30
src/parser/matchers/metacharacter.c
Normal file
30
src/parser/matchers/metacharacter.c
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* metacharacter.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: kcolin <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* 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);
|
||||||
|
}
|
||||||
20
src/parser/matchers/metacharacter.h
Normal file
20
src/parser/matchers/metacharacter.h
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* metacharacter.h :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: kcolin <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* 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 <stdbool.h>
|
||||||
|
|
||||||
|
bool is_metacharacter(char c);
|
||||||
|
|
||||||
|
#endif
|
||||||
Loading…
Add table
Add a link
Reference in a new issue