Expansion: fixed the algo for star expansion.

This commit is contained in:
Jérôme Guélen 2025-03-20 16:57:05 +01:00
parent 41c9548934
commit 00f27ae05c
No known key found for this signature in database
3 changed files with 14 additions and 59 deletions

View file

@ -3,10 +3,10 @@
/* ::: :::::::: */
/* wildcard_exp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* By: jguelen <jguelen@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/20 15:01/38 by khais #+# #+# */
/* Updated: 2025/03/20 15:01:38 by khais ### ########.fr */
/* Created: 2025/03/20 15:01:38 by jguelen #+# #+# */
/* Updated: 2025/03/20 16:53:31 by jguelen ### ########.fr */
/* */
/* ************************************************************************** */
@ -96,7 +96,6 @@ static t_wordlist *expand_star_core(t_worddesc *file_pattern)
new = readdir(current_dir);
while (new)
{
ft_printf("[dbg] read dir entry: %s\n", new->d_name);
if (fits_pattern(new->d_name, file_pattern))
{
if (add_file_to_list(&file_wordlist, new->d_name) == NULL)
@ -128,8 +127,8 @@ char fits_pattern(char *str, t_worddesc *pattern)
size_t i;
char ret;
if (ft_strcmp(".", str) == 0)
ft_printf("[dbg] currently matching .\n");
if (str && str[0] == '.' && pattern->word[0] != '.')
return (0);
pattern_len = ft_strlen(pattern->word);
str_len = ft_strlen(str);
pattern_check = ft_calloc(str_len + 1, sizeof(char *));