mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
matcher: is_quote
This commit is contained in:
parent
591518e9bc
commit
e10ed04169
4 changed files with 47 additions and 3 deletions
23
src/parser/matchers/quote.c
Normal file
23
src/parser/matchers/quote.c
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* quote.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/20 13:21:08 by khais #+# #+# */
|
||||
/* Updated: 2025/02/20 13:22:12 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "quote.h"
|
||||
|
||||
/*
|
||||
** return true if c is either ' or "
|
||||
*/
|
||||
bool is_quote(char c)
|
||||
{
|
||||
if (c == '\'' || c == '"')
|
||||
return (true);
|
||||
return (false);
|
||||
}
|
||||
20
src/parser/matchers/quote.h
Normal file
20
src/parser/matchers/quote.h
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* quote.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/20 13:20:46 by khais #+# #+# */
|
||||
/* Updated: 2025/02/20 13:21:28 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef QUOTE_H
|
||||
# define QUOTE_H
|
||||
|
||||
# include <stdbool.h>
|
||||
|
||||
bool is_quote(char c);
|
||||
|
||||
#endif
|
||||
|
|
@ -6,12 +6,13 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/19 13:20:01 by jguelen #+# #+# */
|
||||
/* Updated: 2025/02/20 13:22:35 by khais ### ########.fr */
|
||||
/* Updated: 2025/02/20 13:22:57 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "wordsplit.h"
|
||||
#include "rule_utils.h"
|
||||
#include "../matchers/quote.h"
|
||||
|
||||
/*
|
||||
** cf. Token Recognition section at
|
||||
|
|
@ -74,8 +75,7 @@ bool rule_operator_end(t_token_build *builder, char *original)
|
|||
*/
|
||||
bool rule_quote(t_token_build *builder, char *original)
|
||||
{
|
||||
// FIXME
|
||||
if (original[builder->idx] == '\'' || original[builder->idx] == '"')
|
||||
if (is_quote(original[builder->idx]))
|
||||
{
|
||||
quote_flip(builder, original[builder->idx]);
|
||||
builder->idx++;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue