Adding more protection to the parser, leaving it at this state for now whilst i branch out to work on a new parser

This commit is contained in:
Mthandazo Ndhlovu
2019-04-20 13:38:13 +02:00
parent 4a5c798b25
commit bfb125f503
5 changed files with 34 additions and 20 deletions

View File

@@ -6,7 +6,7 @@
/* By: mndhlovu <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/03/25 06:30:51 by mndhlovu #+# #+# */
/* Updated: 2019/04/11 09:51:29 by tmaze ### ########.fr */
/* Updated: 2019/04/20 13:08:01 by mndhlovu ### ########.fr */
/* */
/* ************************************************************************** */
@@ -14,10 +14,12 @@
void lm_locate_cd(int index, t_syntax *synt, char *line)
{
char *tmp;
char *tmp;
tmp = ft_strchr(line, '#');
if ((!synt->s_cmd || !synt->e_cmd) && (tmp != NULL && line[1] == '#'))
if ((!synt->s_cmd || !synt->e_cmd)
&& (tmp != NULL && line[1] == '#'
&& lm_check_forbiden_chars(line, 1)))
{
if (!synt->s_cmd)
{
@@ -42,7 +44,7 @@ int lm_get_ant_(int counter, t_lmdata *ldata, t_syntax *synt, ch
{
int value;
if (counter == 0)
if (counter == 0 && lm_check_forbiden_chars(line, 0))
{
value = lm_get_value(line);
if (value != -1)
@@ -82,13 +84,13 @@ int lm_parser(t_syntax *synt, t_lmdata *ldata,
if (!(lm_get_ant_(index, ldata, synt, raw)) && index == 0)
{
ft_strdel(&raw);
return (0);
return (0);
}
lm_locate_cd(index, synt, raw);
if (!(lm_get_vertices(index, synt, ldata, holder, raw)))
{
ft_strdel(&raw);
return (0);
return (0);
}
ft_strdel(&raw);
index++;