Closed multitudes closed 4 months ago
THis would be the function in scanner:
bool str_is_pathname(const char *str)
{
if (((ft_strchr(str, '/') && (!ft_strchr(str, '~'))) || peek(str, ".", \
false) || peek(str, "./", FUZZY) || peek(str, "../", FUZZY) || peek(str, \
"~/", FUZZY) || peek(str, "~+/", FUZZY) || peek(str, "~+", EXACT) || \
peek(str, "~-/", FUZZY) || peek(str, "~-", EXACT)) && !ft_strchr(str, '*'))
{
while (*str)
{
if (!char_is_in_pathname(*str))
return (false);
str++;
}
return (true);
}
return (false);
}
Mayeb if you have sggestions to improve this? here I try to get the pathname type whjih includes all of the valid tilde cases (I tried)
Since you will be working on this function again:
Some suggestions:
extract_string()
andexpand_string
. I mean how would somebody looking at the code understand what they are doing? Maybe something like expand_single_quotes and expand_double_quotes?strchr()
for a tilde, and if it is not a type coming from the expansion of single code or double quotes, then pass it to be expanded together according to the flags, first tilde? has a equal sign been there?PS after looking at the function recognizing if PATHNAME, I did a lot of checks trying to get a mostly correct check for paths, but if I put tilde in here then this
-w-+}[]=w{~or^%ld-
becomes a pathname which makes me cringe a bit...