Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Benoit
minishell
Commits
07f02763
Commit
07f02763
authored
Jan 21, 2021
by
abenoit
Browse files
append flag added
parent
79ab7950
Changes
2
Hide whitespace changes
Inline
Side-by-side
inc/parsing.h
View file @
07f02763
...
...
@@ -9,8 +9,10 @@
# define S_BACKSL 0x02
# define S_QUOTE 0x04
# define S_DQUOTE 0x08
# define S_REDIR 0x10
# define S_CMDSEP 0x20
# define S_R_REDIR 0x10
# define S_L_REDIR 0x20
# define S_APPEND 0x40
# define S_CMDSEP 0x80
enum
e_state
{
...
...
src/parsing/check_syntax.c
View file @
07f02763
...
...
@@ -22,8 +22,10 @@ void check_others(t_byte *flags, char c)
{
if
(
!
(
ft_isspace
(
c
)))
{
if
(
*
flags
&
S_REDIR
)
*
flags
-=
S_REDIR
;
if
(
*
flags
&
S_R_REDIR
)
*
flags
-=
S_R_REDIR
;
if
(
*
flags
&
S_L_REDIR
)
*
flags
-=
S_L_REDIR
;
if
(
*
flags
&
S_EMPTY
)
*
flags
-=
S_EMPTY
;
if
(
*
flags
&
S_CMDSEP
)
...
...
@@ -33,10 +35,22 @@ void check_others(t_byte *flags, char c)
int
check_redirs_and_cmdsep
(
t_byte
*
flags
,
char
c
)
{
if
(
c
==
'>'
||
c
==
'<'
)
if
(
c
==
'>'
)
{
if
(
!
(
*
flags
&
S_REDIR
))
*
flags
+=
S_REDIR
;
if
((
*
flags
&
S_R_REDIR
))
{
*
flags
+=
S_APPEND
;
*
flags
-=
S_R_REDIR
;
}
else
if
(
!
(
*
flags
&
S_R_REDIR
)
&&
!
(
*
flags
&
S_L_REDIR
))
*
flags
+=
S_R_REDIR
;
else
return
(
REDIR_PATH_MISSING
);
}
else
if
(
c
==
'<'
)
{
if
(
!
(
*
flags
&
S_L_REDIR
)
&&
!
(
*
flags
&
S_R_REDIR
))
*
flags
+=
S_L_REDIR
;
else
return
(
REDIR_PATH_MISSING
);
}
...
...
@@ -46,7 +60,7 @@ int check_redirs_and_cmdsep(t_byte *flags, char c)
*
flags
+=
S_CMDSEP
;
else
return
(
EMPTY_CMD
);
if
(
*
flags
&
S_REDIR
)
if
(
*
flags
&
S_
R_REDIR
||
*
flags
&
S_L_
REDIR
)
return
(
REDIR_PATH_MISSING
);
if
(
*
flags
&
S_EMPTY
)
return
(
EMPTY_CMD
);
...
...
@@ -88,7 +102,11 @@ int final_checks(int flags)
{
if
(
flags
&
S_BACKSL
)
return
(
parsing_error
(
ESCAPE_NL
));
if
(
flags
&
S_REDIR
)
if
(
flags
&
S_APPEND
)
return
(
parsing_error
(
REDIR_PATH_MISSING
));
if
(
flags
&
S_R_REDIR
)
return
(
parsing_error
(
REDIR_PATH_MISSING
));
if
(
flags
&
S_L_REDIR
)
return
(
parsing_error
(
REDIR_PATH_MISSING
));
if
(
flags
&
S_QUOTE
)
return
(
parsing_error
(
SQUOTE_MISSING
));
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment