mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
fix(expand-star): incomplete, committing to preserve
This commit is contained in:
parent
f0f19c3c0a
commit
497f442d77
3 changed files with 37 additions and 15 deletions
|
|
@ -3,10 +3,10 @@
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* subst.h :+: :+: :+: */
|
/* subst.h :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jguelen <jguelen@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/04/22 13:14/27 by khais #+# #+# */
|
/* Created: 2025/04/22 13:14:27 by khais #+# #+# */
|
||||||
/* Updated: 2025/04/22 13:14:27 by khais ### ########.fr */
|
/* Updated: 2025/04/25 18:02:13 by jguelen ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -44,5 +44,6 @@ void build_pattern_checks(char *str, t_worddesc *pattern,
|
||||||
char **checker);
|
char **checker);
|
||||||
void clean_pattern(t_worddesc *file_pattern);
|
void clean_pattern(t_worddesc *file_pattern);
|
||||||
int ispattern(t_worddesc *desc);
|
int ispattern(t_worddesc *desc);
|
||||||
|
t_worddesc *deal_with_potential_pattern_marker(t_worddesc *file_pattern);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* wildcard_exp.c :+: :+: :+: */
|
/* wildcard_exp.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jguelen <jguelen@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/03/20 15:01:38 by jguelen #+# #+# */
|
/* Created: 2025/03/20 15:01:38 by jguelen #+# #+# */
|
||||||
/* Updated: 2025/04/22 13:18:18 by khais ### ########.fr */
|
/* Updated: 2025/04/25 18:54:06 by jguelen ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -160,16 +160,18 @@ char fits_pattern(char *str, t_worddesc *pattern)
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
** Returns NULL in case of error.
|
|
||||||
** NOTE: This phase of pre-processing relies partly on processing done before
|
|
||||||
** it therefore checks more loosely (and quote removal still seems not to be
|
|
||||||
** done on string comming from a variable expansion) <-----TO RE-CHECK
|
|
||||||
*/
|
|
||||||
t_wordlist *expand_star(t_worddesc *file_pattern)
|
t_wordlist *expand_star(t_worddesc *file_pattern)
|
||||||
{
|
{
|
||||||
if (!ispattern(file_pattern))
|
t_worddesc *pattern_copy;
|
||||||
|
t_wordlist *expanded;
|
||||||
|
|
||||||
|
if (!file_pattern || !file_pattern->word)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
clean_pattern(file_pattern);
|
pattern_copy = deal_with_potential_pattern_marker(file_pattern);
|
||||||
return (expand_star_core(file_pattern));
|
if (!ispattern(pattern_copy))
|
||||||
|
return (worddesc_destroy(pattern_copy), NULL);
|
||||||
|
clean_pattern(pattern_copy);
|
||||||
|
expanded = expand_star_core(pattern_copy);
|
||||||
|
worddesc_destroy(pattern_copy);
|
||||||
|
return (expanded);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jguelen <jguelen@student.42.fr> +#+ +:+ +#+ */
|
/* By: jguelen <jguelen@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/03/15 15:09:56 by jguelen #+# #+# */
|
/* Created: 2025/03/15 15:09:56 by jguelen #+# #+# */
|
||||||
/* Updated: 2025/03/19 09:07:09 by jguelen ### ########.fr */
|
/* Updated: 2025/04/25 18:53:04 by jguelen ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -65,3 +65,22 @@ int ispattern(t_worddesc *desc)
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
t_worddesc *deal_with_potential_pattern_marker(t_worddesc *file_pattern)
|
||||||
|
{
|
||||||
|
t_worddesc *pattern_copy;
|
||||||
|
int i;
|
||||||
|
char quote;
|
||||||
|
|
||||||
|
pattern_copy = worddesc_copy(file_pattern);
|
||||||
|
if (file_pattern->flags & W_HASDOLLAR)
|
||||||
|
{
|
||||||
|
i = 0;
|
||||||
|
quote = '\0';
|
||||||
|
while (file_pattern->word[i])
|
||||||
|
{
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (pattern_copy);
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue