erreur en cas de mauvais nom de fichier
This commit is contained in:
@@ -1,15 +1,3 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* get_next_line.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/12/29 18:07:43 by hulamy #+# #+# */
|
||||
/* Updated: 2019/12/29 18:08:47 by hulamy ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "get_next_line.h"
|
||||
|
||||
|
||||
@@ -39,20 +27,24 @@
|
||||
i = 0;
|
||||
while (j < ac - 1)
|
||||
{
|
||||
if ((ret = get_next_line(fd[i], &line)))
|
||||
if ((ret = get_next_line(fd[i], &line)) > 0)
|
||||
{
|
||||
printf("[fd%i-%i] %s\n", fd[i], ret, line);
|
||||
free(line);
|
||||
j = 0;
|
||||
}
|
||||
else if (*line != '\0')
|
||||
else if (ret == -1)
|
||||
{
|
||||
printf("[fd%i-%i] %s\n", fd[i], ret, line);
|
||||
printf("[fd%i-%i]*ERROR*\n", fd[i], ret);
|
||||
free(line);
|
||||
j++;
|
||||
}
|
||||
else if (*line != '\0')
|
||||
printf("[fd%i-%i] %s\n", fd[i], ret, line);
|
||||
else
|
||||
{
|
||||
printf("[fd%i-%i]*FINI*\n", fd[i], ret);
|
||||
printf("[fd%i-%i]*FINI*(%s)\n", fd[i], ret, line);
|
||||
free(line);
|
||||
j++;
|
||||
}
|
||||
i++;
|
||||
@@ -70,26 +62,19 @@ int free_lst(t_gnlist **lst, int ret)
|
||||
t_gnlist *tmp;
|
||||
|
||||
tmp = *lst;
|
||||
//while (tmp->next != *lst)
|
||||
// tmp = tmp->next;
|
||||
//tmp->next = tmp->next->next;
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
int count = 1; //
|
||||
while (tmp->next != *lst) //
|
||||
{ //
|
||||
printf("-%i", tmp->lfd); //
|
||||
tmp = tmp->next; //
|
||||
count++; //
|
||||
} //
|
||||
printf("-%i-(%i)", tmp->lfd, count); //
|
||||
tmp->next = tmp->next->next; //
|
||||
printf("(%i-%i)", tmp->lfd, tmp->next->lfd); //
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
free((*lst)->str);
|
||||
free(*lst);
|
||||
*lst = NULL;
|
||||
while (tmp != NULL && tmp->next != *lst && tmp->str == '\0')
|
||||
tmp = tmp->next;
|
||||
if (ret == -1 || tmp->str == '\0')
|
||||
{
|
||||
while (tmp != NULL)
|
||||
{
|
||||
tmp = (*lst)->next;
|
||||
free((*lst)->str);
|
||||
free(*lst);
|
||||
*lst = NULL;
|
||||
*lst = tmp;
|
||||
}
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user