Skip to content

Commit 41eac75

Browse files
committed
edit: 101-wildcmp.c
1 parent 58e429a commit 41eac75

File tree

1 file changed

+3
-18
lines changed

1 file changed

+3
-18
lines changed

0x08-recursion/101-wildcmp.c

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,14 @@ int wildcmp(char *string1, char *string2)
1313
if (*string1 == '\0' && *string2 == '\0')
1414
return (1);
1515

16-
if (*string1 == '\0' && *string2 != '\0')
17-
{
18-
if (*string2 == '*')
19-
return (wildcmp(string1, string2 + 1));
20-
else
21-
return (0);
22-
}
23-
if (*string1 != '\0' && *string2 == '\0')
24-
{
25-
if (*(string2 - 1) == '*')
26-
return (1);
27-
else
28-
return (0);
29-
}
16+
if (*string1 == '\0' && *string2 == '*')
17+
return (wildcmp(string1, string2 + 1));
3018

3119
if (*string2 == '*')
32-
return (wildcmp(string1, string2 + 1));
20+
return (wildcmp(string1, string2 + 1) || wildcmp(string1 + 1, string2));
3321

3422
if (*string1 == *string2)
3523
return (wildcmp(string1 + 1, string2 + 1));
3624

37-
if (*(string2 - 1) == '*')
38-
return (wildcmp(string1 + 1, string2));
39-
4025
return (0);
4126
}

0 commit comments

Comments
 (0)