mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
wordsplit: rename token_build to builder in argument names
This commit is contained in:
parent
b23eb0f244
commit
6f8a86732b
4 changed files with 56 additions and 56 deletions
|
|
@ -6,11 +6,12 @@
|
|||
/* By: jguelen <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/19 13:20:01 by jguelen #+# #+# */
|
||||
/* Updated: 2025/02/19 18:46:49 by khais ### ########.fr */
|
||||
/* Updated: 2025/02/20 11:50:44 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "wordsplit.h"
|
||||
#include "../matchers/operator_combo.h"
|
||||
|
||||
/*
|
||||
** cf. Token Recognition section at
|
||||
|
|
@ -21,11 +22,11 @@
|
|||
** 1. If the end of input is recognized, the current token (if any) shall be
|
||||
** delimited.
|
||||
*/
|
||||
bool rule_eof(t_token_build *token_build, char *original)
|
||||
bool rule_eof(t_token_build *builder, char *original)
|
||||
{
|
||||
if (original[token_build->current_index] == '\0')
|
||||
if (original[builder->current_index] == '\0')
|
||||
{
|
||||
delimit(token_build);
|
||||
delimit(builder);
|
||||
return (true);
|
||||
}
|
||||
return (false);
|
||||
|
|
@ -36,13 +37,13 @@ bool rule_eof(t_token_build *token_build, char *original)
|
|||
** character is not quoted and can be used with the previous characters to form
|
||||
** an operator, it shall be used as part of that (operator) token.
|
||||
*/
|
||||
bool rule_combine_operator(t_token_build *token_build, char *original)
|
||||
bool rule_combine_operator(t_token_build *builder, char *original)
|
||||
{
|
||||
if (token_build->currently_in_operator && token_build->quote == '\0'
|
||||
&& is_operator_combo(token_build->cur_token->buffer, original[token_build->current_index]))
|
||||
if (builder->currently_in_operator && builder->quote == '\0'
|
||||
&& is_operator_combo(builder->cur_token->buffer, original[builder->current_index]))
|
||||
{
|
||||
push_char(token_build, original[token_build->current_index]);
|
||||
token_build->current_index++;
|
||||
push_char(builder, original[builder->current_index]);
|
||||
builder->current_index++;
|
||||
return (true);
|
||||
}
|
||||
return (false);
|
||||
|
|
@ -53,12 +54,12 @@ bool rule_combine_operator(t_token_build *token_build, char *original)
|
|||
** character cannot be used with the previous characters to form an operator,
|
||||
** the operator containing the previous character shall be delimited.
|
||||
*/
|
||||
bool rule_operator_end(t_token_build *token_build, char *original)
|
||||
bool rule_operator_end(t_token_build *builder, char *original)
|
||||
{
|
||||
if (token_build->currently_in_operator && token_build->quote == '\0'
|
||||
&& !is_operator_combo(token_build->cur_token->buffer, original[token_build->current_index]))
|
||||
if (builder->currently_in_operator && builder->quote == '\0'
|
||||
&& !is_operator_combo(builder->cur_token->buffer, original[builder->current_index]))
|
||||
{
|
||||
delimit(token_build);
|
||||
delimit(builder);
|
||||
return (true);
|
||||
}
|
||||
return (false);
|
||||
|
|
@ -72,16 +73,16 @@ bool rule_operator_end(t_token_build *token_build, char *original)
|
|||
** operators, between the <quotation-mark> and the end of the quoted text. The
|
||||
** token shall not be delimited by the end of the quoted field.
|
||||
*/
|
||||
bool rule_quote(t_token_build *token_build, char *original)
|
||||
bool rule_quote(t_token_build *builder, char *original)
|
||||
{
|
||||
if (original[token_build->current_index] == '\'' || original[token_build->current_index] == '"')
|
||||
if (original[builder->current_index] == '\'' || original[builder->current_index] == '"')
|
||||
{
|
||||
quote_flip(token_build, original[token_build->current_index]);
|
||||
token_build->current_index++;
|
||||
quote_flip(builder, original[builder->current_index]);
|
||||
builder->current_index++;
|
||||
return (true);
|
||||
}
|
||||
return (false);
|
||||
|
||||
}
|
||||
|
||||
bool token_rule_5(t_token_build *token_build, char *original);
|
||||
bool token_rule_5(t_token_build *builder, char *original);
|
||||
|
|
|
|||
|
|
@ -6,11 +6,13 @@
|
|||
/* By: jguelen <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/19 13:21:18 by jguelen #+# #+# */
|
||||
/* Updated: 2025/02/19 18:48:03 by khais ### ########.fr */
|
||||
/* Updated: 2025/02/20 11:50:59 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "wordsplit.h"
|
||||
#include "../matchers/operator_start.h"
|
||||
#include "../matchers/blank.h"
|
||||
|
||||
/*
|
||||
** cf. Token Recognition section at
|
||||
|
|
@ -23,12 +25,12 @@
|
|||
** The current character shall be used as the beginning of the next (operator)
|
||||
** token.
|
||||
*/
|
||||
bool rule_new_operator(t_token_build *token_build, char *original)
|
||||
bool rule_new_operator(t_token_build *builder, char *original)
|
||||
{
|
||||
if (token_build->quote == '\0' && is_operator_start(original[token_build->current_index]))
|
||||
if (builder->quote == '\0' && is_operator_start(original[builder->current_index]))
|
||||
{
|
||||
operator_start(token_build, original[token_build->current_index]);
|
||||
token_build->current_index++;
|
||||
operator_start(builder, original[builder->current_index]);
|
||||
builder->current_index++;
|
||||
return (true);
|
||||
}
|
||||
return (false);
|
||||
|
|
@ -38,12 +40,12 @@ bool rule_new_operator(t_token_build *token_build, char *original)
|
|||
** 7. If the current character is an unquoted <blank>, any token containing the
|
||||
** previous character is delimited and the current character shall be discarded.
|
||||
*/
|
||||
bool rule_delimit_blank(t_token_build *token_build, char *original)
|
||||
bool rule_delimit_blank(t_token_build *builder, char *original)
|
||||
{
|
||||
if (is_blank(original[token_build->current_index]) && token_build->quote == '\0')
|
||||
if (is_blank(original[builder->current_index]) && builder->quote == '\0')
|
||||
{
|
||||
delimit(token_build);
|
||||
token_build->current_index++;
|
||||
delimit(builder);
|
||||
builder->current_index++;
|
||||
return (true);
|
||||
}
|
||||
return (false);
|
||||
|
|
@ -53,12 +55,12 @@ bool rule_delimit_blank(t_token_build *token_build, char *original)
|
|||
** 8. If the previous character was part of a word, the current character shall
|
||||
** be appended to that word.
|
||||
*/
|
||||
bool rule_combine_word(t_token_build *token_build, char *original)
|
||||
bool rule_combine_word(t_token_build *builder, char *original)
|
||||
{
|
||||
if (token_build->currently_in_word)
|
||||
if (builder->currently_in_word)
|
||||
{
|
||||
push_char(token_build, original[token_build->current_index]);
|
||||
token_build->current_index++;
|
||||
push_char(builder, original[builder->current_index]);
|
||||
builder->current_index++;
|
||||
return (true);
|
||||
}
|
||||
return (false);
|
||||
|
|
@ -67,9 +69,9 @@ bool rule_combine_word(t_token_build *token_build, char *original)
|
|||
/*
|
||||
** 10. The current character is used as the start of a new word.
|
||||
*/
|
||||
bool rule_new_word(t_token_build *token_build, char *original)
|
||||
bool rule_new_word(t_token_build *builder, char *original)
|
||||
{
|
||||
new_word(token_build, original[token_build->current_index]);
|
||||
token_build->current_index++;
|
||||
new_word(builder, original[builder->current_index]);
|
||||
builder->current_index++;
|
||||
return (true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
/* +:+ +:+ +:+ */
|
||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/19 18:48/03 by khais #+# #+# */
|
||||
/* Updated: 2025/02/19 18:48:03 by khais ### ########.fr */
|
||||
/* Created: 2025/02/20 11:48/20 by khais #+# #+# */
|
||||
/* Updated: 2025/02/20 11:48:20 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -16,10 +16,6 @@
|
|||
# include "../wordlist/wordlist.h"
|
||||
# include <stdbool.h>
|
||||
# include "../../buffer/buffer.h"
|
||||
# include "../matchers/blank.h"
|
||||
# include "../matchers/operator_start.h"
|
||||
# include "../matchers/operator_combo.h"
|
||||
# include <stdlib.h>
|
||||
|
||||
typedef struct s_token_build
|
||||
{
|
||||
|
|
@ -31,20 +27,20 @@ typedef struct s_token_build
|
|||
size_t current_index;
|
||||
} t_token_build;
|
||||
|
||||
void delimit(t_token_build *token_build);
|
||||
void push_char(t_token_build *token_build, char c);
|
||||
void new_word(t_token_build *token_build, char c);
|
||||
void quote_flip(t_token_build *token_build, char c);
|
||||
void operator_start(t_token_build *token_build, char c);
|
||||
bool rule_eof(t_token_build *token_build, char *original);
|
||||
bool rule_combine_operator(t_token_build *token_build, char *original);
|
||||
bool rule_operator_end(t_token_build *token_build, char *original);
|
||||
bool rule_quote(t_token_build *token_build, char *original);
|
||||
bool token_rule_5(t_token_build *token_build, char *original);
|
||||
bool rule_new_operator(t_token_build *token_build, char *original);
|
||||
bool rule_delimit_blank(t_token_build *token_build, char *original);
|
||||
bool rule_combine_word(t_token_build *token_build, char *original);
|
||||
bool rule_new_word(t_token_build *token_build, char *original);
|
||||
void delimit(t_token_build *builder);
|
||||
void push_char(t_token_build *builder, char c);
|
||||
void new_word(t_token_build *builder, char c);
|
||||
void quote_flip(t_token_build *builder, char c);
|
||||
void operator_start(t_token_build *builder, char c);
|
||||
bool rule_eof(t_token_build *builder, char *original);
|
||||
bool rule_combine_operator(t_token_build *builder, char *original);
|
||||
bool rule_operator_end(t_token_build *builder, char *original);
|
||||
bool rule_quote(t_token_build *builder, char *original);
|
||||
bool token_rule_5(t_token_build *builder, char *original);
|
||||
bool rule_new_operator(t_token_build *builder, char *original);
|
||||
bool rule_delimit_blank(t_token_build *builder, char *original);
|
||||
bool rule_combine_word(t_token_build *builder, char *original);
|
||||
bool rule_new_word(t_token_build *builder, char *original);
|
||||
|
||||
t_wordlist *minishell_wordsplit(char *original);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,12 +5,13 @@
|
|||
/* +:+ +:+ +:+ */
|
||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/19 18:40/48 by khais #+# #+# */
|
||||
/* Updated: 2025/02/19 18:40:48 by khais ### ########.fr */
|
||||
/* Created: 2025/02/20 11:51/27 by khais #+# #+# */
|
||||
/* Updated: 2025/02/20 11:51:27 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "wordsplit.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
void delimit(t_token_build *token_build)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue