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/04/02 08:39:09 by mndhlovu #+# #+# */
/* Updated: 2019/04/11 12:48:13 by mndhlovu ### ########.fr */
/* Updated: 2019/04/20 13:18:54 by mndhlovu ### ########.fr */
/* */
/* ************************************************************************** */
@@ -25,6 +25,24 @@ int lm_check_room_before(char **tab, t_syntax *synt)
return (1);
}
int lm_check_forbiden_chars(char *line, int flag)
{
char *hash;
char *dash;
dash = ft_strchr(line, '-');
hash = ft_strchr(line, '#');
if (flag == 0 && dash == NULL && hash == NULL)
return (1);
if (flag = 1 && dash == NULL && hash != NULL)
return (1);
if (flag == 2 && dash == NULL && (hash == NULL || (hash != NULL && line[1] != '#')))
return (1);
if (flag == 3 && dash != NULL && (hash == NULL || (hash != NULL && line[1] != '#')))
return (1);
return (0);
}
void lm_clear_unv(t_holder *holder)
{
t_temp *data;
@@ -50,4 +68,4 @@ int lm_verify_cmd(t_syntax *synt, t_holder *holder, t_lmdata *data)
return (1);
lm_clear_unv(holder);
return (0);
}
}