Fix issues with patterns of form /*/
authorLukas Jiriste <ljiriste@student.42prague.com>
Thu, 22 Aug 2024 15:05:41 +0000 (17:05 +0200)
committerLukas Jiriste <ljiriste@student.42prague.com>
Thu, 22 Aug 2024 15:05:41 +0000 (17:05 +0200)
When introducing the handling of multiple slashed one after another
(eg. "///*") the handling of "/*/" patterns stopped working because the
asterisk could be assumed to be 0 symbols resulting in // which was
simplified to / effectively skipping a layer of dirs.

src/wildcards.c

index f653db6af91a30e8bf12e33c054922f294458a55..a7ad6f3bf4c4b091c264831c28c7a1046ccc0baf 100644 (file)
@@ -6,7 +6,7 @@
 /*   By: ljiriste <marvin@42.fr>                    +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   Created: 2024/08/08 10:50:26 by ljiriste          #+#    #+#             */
-/*   Updated: 2024/08/22 15:21:35 by ljiriste         ###   ########.fr       */
+/*   Updated: 2024/08/22 16:15:32 by ljiriste         ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
@@ -37,9 +37,12 @@ int  branch_at_star(t_vec *expanded, t_wildcard_info *info)
        t_wildcard_info info_dup;
 
        info_dup = *info;
-       ++info->current_expand_char;
-       if (add_conformant(expanded, info, '\0'))
-               return (1);
+       if (!(*(info->current_expand_char + 1) == '/' && info->current_entry_char == info->entry))
+       {
+               ++info->current_expand_char;
+               if (add_conformant(expanded, info, '\0'))
+                       return (1);
+       }
        if (start_size != expanded->size || *info->current_entry_char == '\0')
                return (0);
        ++info_dup.current_entry_char;