Michael Ea
3 years ago
9 changed files with 105 additions and 88 deletions
@ -0,0 +1,76 @@ |
|||||
|
/* ************************************************************************** */ |
||||
|
/* */ |
||||
|
/* ::: :::::::: */ |
||||
|
/* utils_3.c :+: :+: :+: */ |
||||
|
/* +:+ +:+ +:+ */ |
||||
|
/* By: mea <marvin@42.fr> +#+ +:+ +#+ */ |
||||
|
/* +#+#+#+#+#+ +#+ */ |
||||
|
/* Created: 2022/05/12 14:33:58 by mea #+# #+# */ |
||||
|
/* Updated: 2022/05/12 14:51:17 by mea ### ########.fr */ |
||||
|
/* */ |
||||
|
/* ************************************************************************** */ |
||||
|
|
||||
|
#include "minishell.h" |
||||
|
|
||||
|
|
||||
|
|
||||
|
int is_valid_identifier(char *ident) |
||||
|
{ |
||||
|
int i; |
||||
|
|
||||
|
i = 0; |
||||
|
if (ft_isalpha(ident[0]) || ident[0] == '_') |
||||
|
{ |
||||
|
while (ident[i]) |
||||
|
{ |
||||
|
if (!ft_isalpha(ident[i]) && !ft_isdigit(ident[i] |
||||
|
&& ident[i] != '_')) |
||||
|
{ |
||||
|
ft_putstr_fd("export: not an identifier: ", 2); |
||||
|
ft_putstr_fd(ident, 2); |
||||
|
ft_putchar_fd('\n', 2); |
||||
|
return (0); |
||||
|
} |
||||
|
i++; |
||||
|
} |
||||
|
return (1); |
||||
|
} |
||||
|
ft_putstr_fd("export: not an identifier: ", 2); |
||||
|
ft_putstr_fd(ident, 2); |
||||
|
ft_putchar_fd('\n', 2); |
||||
|
return (0); |
||||
|
} |
||||
|
|
||||
|
int create_wc(t_lexer *lex, char *tmp) |
||||
|
{ |
||||
|
int i; |
||||
|
int j; |
||||
|
int skip ; |
||||
|
DIR * direct; |
||||
|
struct dirent *file; |
||||
|
|
||||
|
direct = opendir("."); |
||||
|
file = (readdir(direct), readdir(direct), readdir(direct)); |
||||
|
while (file) |
||||
|
{ |
||||
|
i = 0; |
||||
|
j = 0; |
||||
|
skip = (tmp[0] != '.' && file->d_name[0] == '.'); |
||||
|
while (tmp[i] && !skip) |
||||
|
{ |
||||
|
if (tmp[i] == '*') |
||||
|
while (file->d_name[j] && file->d_name[j] != tmp[i + 1]) |
||||
|
j++; |
||||
|
if (tmp[i] != '*' && file->d_name[j] != tmp[i]) |
||||
|
skip = 1; |
||||
|
else if (++i) |
||||
|
++j; |
||||
|
} |
||||
|
if (!skip) |
||||
|
create_token(lex, file->d_name); |
||||
|
file = readdir(direct); |
||||
|
} |
||||
|
closedir(direct); |
||||
|
lex->wc = 0; |
||||
|
return (1); |
||||
|
} |
Loading…
Reference in new issue