/* By: ljiriste <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/02 13:22:57 by ljiriste #+# #+# */
-/* Updated: 2024/08/22 14:25:59 by ljiriste ### ########.fr */
+/* Updated: 2024/08/23 16:15:16 by ljiriste ### ########.fr */
/* */
/* ************************************************************************** */
void handle_input(char **line, t_execution_env *env);
void unquote_field(char *field);
-int add_word(t_vec *exp_str, const char *word, const t_execution_env *env);
+int add_word(t_vec *exp_str, const char *word, const t_execution_env *env, int quote);
int add_conformant(t_vec *expanded, t_wildcard_info *info, char quote);
int expand_dir(t_vec *expanded, t_wildcard_info *info);
/* By: lnikolov <lnikolov@student.42prague.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/21 08:57:54 by ljiriste #+# #+# */
-/* Updated: 2024/08/23 15:45:57 by ljiriste ### ########.fr */
+/* Updated: 2024/08/23 16:17:56 by ljiriste ### ########.fr */
/* */
/* ************************************************************************** */
return ;
}
-int add_word(t_vec *exp_str, const char *word, const t_execution_env *env);
+int add_word(t_vec *exp_str, const char *word, const t_execution_env *env, int quote);
int add_assignment(t_vec *assignments, const char *assignment, const t_execution_env *env)
{
if (ft_vec_init(&advanced_copy, sizeof(char)) != success)
return (1);
- if (add_word(&advanced_copy, assignment, env))
+ if (add_word(&advanced_copy, assignment, env, 0))
return (1);
*(char *)ft_vec_access(&advanced_copy, advanced_copy.size - 1) = '\0';
copy = advanced_copy.vec;
static const char space = ' ';
-int add_word(t_vec *exp_str, const char *word, const t_execution_env *env)
+int add_word(t_vec *exp_str, const char *word, const t_execution_env *env, int quote)
{
size_t i;
char *var;
char *value;
const char *const_val;
int single_quoted;
+ int error;
+ error = 0;
single_quoted = 0;
i = 0;
while (word[i])
continue;
value = ft_strdup(const_val);
}
- if (!value || ft_vec_append(exp_str, "'") != success
- || ft_vec_append_range(exp_str, value, ft_strlen(value)) != success
- || ft_vec_append(exp_str, "'") != success)
- {
- free(value);
+ if (!value)
return (1);
- }
+ if (quote)
+ error = error || ft_vec_append(exp_str, "'") != success;
+ error = error || ft_vec_append_range(exp_str, value, ft_strlen(value)) != success;
+ if (quote)
+ error = error || ft_vec_append(exp_str, "'") != success;
free(value);
+ if (error)
+ return (1);
}
else
if (ft_vec_append(exp_str, word + (i++)) != success)
return (1);
}
else if (is_token_type(subnode, "WORD"))
- if (add_word(exp_str, subnode->token.str, env))
+ if (add_word(exp_str, subnode->token.str, env, 0))
return (1);
++i;
}
/* By: ljiriste <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/08 10:50:26 by ljiriste #+# #+# */
-/* Updated: 2024/08/23 14:03:58 by ljiriste ### ########.fr */
+/* Updated: 2024/08/23 16:15:58 by ljiriste ### ########.fr */
/* */
/* ************************************************************************** */
if (ft_vec_init(&expanded, sizeof(char)) != success)
return (1);
- if (add_word(&expanded, *str, env))
+ if (add_word(&expanded, *str, env, 1))
{
ft_vec_free(&expanded, NULL);
return (1);