bug found

found bug in parser that made link adding impossible
This commit is contained in:
Tanguy MAZE 2019-04-24 09:54:24 +02:00
parent c35deace58
commit fe1c85371f
8 changed files with 37 additions and 27 deletions

View File

@ -6,7 +6,7 @@
/* By: mndhlovu <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/03/25 06:31:05 by mndhlovu #+# #+# */
/* Updated: 2019/04/22 15:37:45 by mndhlovu ### ########.fr */
/* Updated: 2019/04/24 09:44:41 by tmaze ### ########.fr */
/* */
/* ************************************************************************** */
@ -58,13 +58,16 @@ static int lem_in(t_syntax *synt, t_holder *holder,
{
if (!(lm_parser(synt, lmdata, holder)))
return (0);
ft_printf("start verify\n");
if (!(lm_verify_cmd(synt, holder, lmdata)))
return (0);
ft_printf("Number of nodes %d\n", lmdata->nb_nodes);
if (!lst_indinit(lmdata))
return (0);
ft_printf("plap\n");
if (!(lm_adj_parser(lmdata, holder)))
return (0);
ft_printf("plop\n");
lm_clear_unv(holder);
get_nb_paths_max(lmdata, get_node_role(lmdata, 's')->ind
, get_node_role(lmdata, 'e')->ind);
@ -95,7 +98,10 @@ int main(int ac, char **av)
{
lm_init_data(&synt, &holder, &ldata);
if (!(lem_in(&synt, &holder, &ldata, &ret)))
{
lm_clean_data(&ldata);
return (lm_error_exit());
}
lm_clean_data(&ldata);
return (0);
}

View File

@ -6,7 +6,7 @@
/* By: mndhlovu <mndhlovu@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/22 08:55:30 by mndhlovu #+# #+# */
/* Updated: 2019/04/22 12:43:44 by mndhlovu ### ########.fr */
/* Updated: 2019/04/24 09:49:38 by tmaze ### ########.fr */
/* */
/* ************************************************************************** */
@ -44,7 +44,7 @@ int lm_check_forbiden_chars(char *line, int flag)
&& (hash == NULL || (hash != NULL && line[1] != '#')))
return (1);
if (flag == 3 && dash != NULL
&& (hash == NULL || (hash != NULL && line[1] != '#')))
&& hash == NULL)
return (1);
}
return (0);

View File

@ -6,7 +6,7 @@
/* By: mndhlovu <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/05 06:35:40 by mndhlovu #+# #+# */
/* Updated: 2019/04/22 15:31:10 by mndhlovu ### ########.fr */
/* Updated: 2019/04/23 11:01:37 by tmaze ### ########.fr */
/* */
/* ************************************************************************** */
@ -51,7 +51,8 @@ void lm_clean_data(t_lmdata *data)
i = 0;
while (i < data->nb_nodes)
{
lst_inddel(&(data->adj[i]));
if (data->adj && data->adj[i])
lst_inddel(&(data->adj[i]));
i++;
}
ft_memdel((void**)&(data->adj));

View File

@ -6,7 +6,7 @@
/* By: mndhlovu <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/03/29 07:17:06 by mndhlovu #+# #+# */
/* Updated: 2019/04/22 14:28:24 by mndhlovu ### ########.fr */
/* Updated: 2019/04/24 09:43:02 by tmaze ### ########.fr */
/* */
/* ************************************************************************** */
@ -32,13 +32,16 @@ int lm_adj_parser(t_lmdata *lmdata, t_holder *holder)
{
t_temp *data;
ft_printf("=== lm_adj_parser ===\nholder: %p\n\n", holder);
if (holder != NULL)
{
data = holder->data;
ft_printf("data: %p\n\n", data);
if (data != NULL)
{
while (data)
{
ft_printf("=== link ===\nis_lin_in: %d\n\n", is_link_in(lmdata, data->src_ind, data->dest_ind));
if (!is_link_in(lmdata, data->src_ind, data->dest_ind))
lst_indadd_link(lmdata, data->src_ind, data->dest_ind);
data = data->next;

View File

@ -6,7 +6,7 @@
/* By: mndhlovu <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/03/25 06:31:37 by mndhlovu #+# #+# */
/* Updated: 2019/04/22 12:52:48 by mndhlovu ### ########.fr */
/* Updated: 2019/04/24 09:51:14 by tmaze ### ########.fr */
/* */
/* ************************************************************************** */
@ -37,7 +37,7 @@ void lm_init_data(t_syntax *synt, t_holder *holder, t_lmdata *ldata)
static void lm_add_vertex_sub(t_lmdata *ldata, t_node *new)
{
t_node *tmp;
t_node *tmp;
if (ldata->nodes_data == NULL)
ldata->nodes_data = new;
@ -112,7 +112,6 @@ int lm_ext_conn(t_holder *holder, t_lmdata *data, char *raw)
dest = lm_find_index(data, tab[1]);
if (src == -1 || dest == -1)
{
ft_printf("Bingo :%s\n", raw);
ft_del_words_tables(&tab);
return 0;
}

View File

@ -6,18 +6,18 @@
/* By: mndhlovu <mndhlovu@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/20 15:24:51 by mndhlovu #+# #+# */
/* Updated: 2019/04/22 15:31:03 by mndhlovu ### ########.fr */
/* Updated: 2019/04/24 09:45:04 by tmaze ### ########.fr */
/* */
/* ************************************************************************** */
#include "lem_in.h"
void lm_locate_cd(int index, t_syntax *synt, char *line)
void lm_locate_cd(int index, t_syntax *synt, char *line)
{
char *tmp;
char *tmp;
tmp = ft_strchr(line, '#');
ft_printf("Bingo 1\n");
ft_printf("Bingo 1\n");
if ((!synt->s_cmd || !synt->e_cmd)
&& (tmp != NULL && line[1] == '#'
&& lm_check_forbiden_chars(line, 1)))
@ -26,7 +26,7 @@ void lm_locate_cd(int index, t_syntax *synt, char *line)
{
if (ft_strcmp(line, "##start") == 0)
{
ft_printf("Bingo 2\n");
ft_printf("Bingo 2\n");
synt->s_cmd = 1;
synt->s_pos = index;
}
@ -35,7 +35,7 @@ void lm_locate_cd(int index, t_syntax *synt, char *line)
{
if (ft_strcmp(line, "##end") == 0)
{
ft_printf("Bingo 3\n");
ft_printf("Bingo 3\n");
synt->e_cmd = 1;
synt->e_pos = index;
}
@ -43,16 +43,16 @@ void lm_locate_cd(int index, t_syntax *synt, char *line)
}
}
int lm_get_ant_(int counter, t_lmdata *ldata, t_syntax *synt, char *line)
int lm_get_ant_(int counter, t_lmdata *ldata, t_syntax *synt, char *line)
{
int value;
int value;
if (counter == 0 && lm_check_forbiden_chars(line, 0))
{
value = lm_get_value(line);
if (value != -1)
{
ft_printf("Bingo 4 %d\n", value);
ft_printf("Bingo 4 %d\n", value);
ldata->nbants = value;
synt->nb_state = 1;
return (1);
@ -62,14 +62,14 @@ int lm_get_ant_(int counter, t_lmdata *ldata, t_syntax *synt, ch
return (0);
}
static int lm_get_vertices(int count, t_syntax *synt,
static int lm_get_vertices(int count, t_syntax *synt,
t_lmdata *data, t_holder *holder, char *line)
{
ft_printf("Bingo 5\n");
ft_printf("Bingo 5\n");
lm_get_cmd_vert(count, synt, data, line);
if (!synt->s_error && !synt->e_error)
{
ft_printf("Bingo 6 %s\n", line);
ft_printf("Bingo 6 %s\n", line);
lm_get_vert_link(count, synt, data, holder, line);
if (!synt->v_error && !synt->l_error)
return (1);
@ -77,11 +77,11 @@ static int lm_get_vertices(int count, t_syntax *synt,
return (0);
}
int lm_parser(t_syntax *synt, t_lmdata *ldata,
int lm_parser(t_syntax *synt, t_lmdata *ldata,
t_holder *holder)
{
char *raw;
int index;
char *raw;
int index;
index = 0;
while (ft_getline(&raw) > 0)
@ -89,6 +89,7 @@ int lm_parser(t_syntax *synt, t_lmdata *ldata,
ft_printf("%s\n", raw);
if (!(lm_get_ant_(index, ldata, synt, raw)) && index == 0)
{
ft_printf("banane\n");
ft_strdel(&raw);
return (0);
}

View File

@ -6,7 +6,7 @@
/* By: mndhlovu <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/04 09:24:45 by mndhlovu #+# #+# */
/* Updated: 2019/04/22 15:30:39 by mndhlovu ### ########.fr */
/* Updated: 2019/04/24 09:47:29 by tmaze ### ########.fr */
/* */
/* ************************************************************************** */
@ -73,7 +73,7 @@ void lm_get_vert_link(int count, t_syntax *synt, t_lmdata *ldata
synt->v_error = 1;
}
}
if (lm_check_forbiden_chars(line, 0))
if (lm_check_forbiden_chars(line, 3))
{
if (!(lm_ext_conn(holder, ldata, line)))
{

View File

@ -6,7 +6,7 @@
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/03/27 14:56:55 by tmaze #+# #+# */
/* Updated: 2019/04/22 15:30:24 by mndhlovu ### ########.fr */
/* Updated: 2019/04/24 09:51:38 by tmaze ### ########.fr */
/* */
/* ************************************************************************** */