remis les line dans les printf du main
This commit is contained in:
@@ -1,43 +1,21 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* get_next_line.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2019/12/31 17:05:53 by hulamy #+# #+# */
|
||||||
|
/* Updated: 2019/12/31 17:28:00 by hulamy ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "get_next_line.h"
|
#include "get_next_line.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** //:set noendofline binary
|
|
||||||
** //https://github.com/lgrellie/gnl_tester
|
|
||||||
** //https://github.com/Mazoise/42TESTERS-GNL
|
|
||||||
** //https://github.com/charMstr/GNL_lover
|
|
||||||
** //https://github.com/mrjvs/42cursus_gnl_tests
|
|
||||||
** //https://github.com/Sherchryst/gnlkiller
|
|
||||||
** //https://github.com/Hellio404/Get_Next_Line_Tester
|
|
||||||
** //https://github.com/TinfoilPancakes/get-next-line-testing-tools
|
|
||||||
**
|
|
||||||
** #include <stdio.h> //for printf
|
** #include <stdio.h> //for printf
|
||||||
** #include <fcntl.h> //for open
|
** #include <fcntl.h> //for open
|
||||||
**
|
**
|
||||||
** void ft_putchar(char c){
|
|
||||||
** write(1, &c, 1);
|
|
||||||
** }
|
|
||||||
**
|
|
||||||
** void ft_putstr(char *s)
|
|
||||||
** {
|
|
||||||
** while (s && *s)
|
|
||||||
** ft_putchar(*s++);
|
|
||||||
** }
|
|
||||||
**
|
|
||||||
** void ft_putnbr(int n)
|
|
||||||
** {
|
|
||||||
** long l;
|
|
||||||
**
|
|
||||||
** l = n;
|
|
||||||
** if (l < 0)
|
|
||||||
** {
|
|
||||||
** ft_putchar('-');
|
|
||||||
** l *= -1;
|
|
||||||
** }
|
|
||||||
** if (l >= 10)
|
|
||||||
** ft_putnbr(l / 10);
|
|
||||||
** ft_putchar((l % 10) + '0');
|
|
||||||
** }
|
|
||||||
**
|
|
||||||
** int main(int ac, char **av)
|
** int main(int ac, char **av)
|
||||||
** {
|
** {
|
||||||
** int *fd;
|
** int *fd;
|
||||||
@@ -54,7 +32,7 @@
|
|||||||
** {
|
** {
|
||||||
** if ((ret = get_next_line(fd[i], &line)) > 0)
|
** if ((ret = get_next_line(fd[i], &line)) > 0)
|
||||||
** {
|
** {
|
||||||
** printf(" [fd%i-%i] \n", fd[i], ret );
|
** printf(" [fd%i-%i] %s\n", fd[i], ret, line);
|
||||||
** free(line);
|
** free(line);
|
||||||
** j = 0;
|
** j = 0;
|
||||||
** }
|
** }
|
||||||
@@ -65,10 +43,10 @@
|
|||||||
** j++;
|
** j++;
|
||||||
** }
|
** }
|
||||||
** else if (*line != '\0')
|
** else if (*line != '\0')
|
||||||
** printf(" [fd%i-%i] \n", fd[i], ret);
|
** printf(" [fd%i-%i] %s\n", fd[i], ret, line);
|
||||||
** else
|
** else
|
||||||
** {
|
** {
|
||||||
** printf("[fd%i-%i]*FINI*\n", fd[i], ret);
|
** printf("[fd%i-%i] %s *FINI*\n", fd[i], ret, line);
|
||||||
** free(line);
|
** free(line);
|
||||||
** j++;
|
** j++;
|
||||||
** }
|
** }
|
||||||
@@ -86,12 +64,10 @@ int free_lst(t_gnlist **lst, int ret)
|
|||||||
{
|
{
|
||||||
t_gnlist *tmp;
|
t_gnlist *tmp;
|
||||||
|
|
||||||
tmp = *lst; // t_gnlist *tmp2;/*ft_putstr("\n");*/ft_putstr("(");
|
tmp = *lst;
|
||||||
while (tmp->next != *lst)
|
while (tmp->next != *lst)
|
||||||
{ // ft_putnbr(tmp->lfd);ft_putstr("-");
|
|
||||||
tmp = tmp->next;
|
tmp = tmp->next;
|
||||||
} // ft_putnbr(tmp->lfd);ft_putstr("-(");ft_putnbr(tmp->next->lfd);ft_putstr("))");
|
tmp->next = (*lst)->next;
|
||||||
tmp->next = (*lst)->next; // ft_putstr("->(");ft_putnbr(tmp->lfd);ft_putstr("-");ft_putnbr(tmp->next->lfd);ft_putstr(")");
|
|
||||||
free((*lst)->str);
|
free((*lst)->str);
|
||||||
if (*lst == (*lst)->next)
|
if (*lst == (*lst)->next)
|
||||||
{
|
{
|
||||||
@@ -102,7 +78,7 @@ int free_lst(t_gnlist **lst, int ret)
|
|||||||
{
|
{
|
||||||
free(*lst);
|
free(*lst);
|
||||||
*lst = tmp;
|
*lst = tmp;
|
||||||
} // tmp2=tmp;ft_putstr("(");while(tmp2->next!=tmp){ft_putnbr(tmp2->lfd);ft_putstr("-");tmp2=tmp2->next;}ft_putnbr(tmp2->lfd);ft_putstr("-(");ft_putnbr(tmp2->next->lfd);ft_putstr("))");
|
}
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,13 +86,13 @@ int multi_fd(int fd, t_gnlist **lst)
|
|||||||
{
|
{
|
||||||
t_gnlist *tmp;
|
t_gnlist *tmp;
|
||||||
|
|
||||||
tmp = *lst; // t_gnlist *tmp2;ft_putstr(" multi(fd:");ft_putnbr(fd);ft_putstr("-(check:");tmp2=tmp;while(tmp2 && tmp2->next!=tmp){ft_putnbr(tmp2->lfd);ft_putstr("-");tmp2=tmp2->next;}if(tmp2)ft_putnbr(tmp2->lfd);ft_putstr(")-(start:");
|
tmp = *lst;
|
||||||
while (*lst && (*lst)->lfd != fd && (*lst)->next != tmp)
|
while (*lst && (*lst)->lfd != fd && (*lst)->next != tmp)
|
||||||
{ // ft_putnbr((*lst)->lfd);ft_putstr("-");
|
{
|
||||||
*lst = (*lst)->next;
|
*lst = (*lst)->next;
|
||||||
} // if(*lst)ft_putnbr((*lst)->lfd);ft_putstr(")-(");
|
}
|
||||||
if (!tmp || ((*lst)->next == tmp && (*lst)->lfd != fd))
|
if (!tmp || ((*lst)->next == tmp && (*lst)->lfd != fd))
|
||||||
{ // ft_putstr("create ");
|
{
|
||||||
if (!(tmp = (t_gnlist*)malloc(sizeof(*tmp))))
|
if (!(tmp = (t_gnlist*)malloc(sizeof(*tmp))))
|
||||||
return (0);
|
return (0);
|
||||||
tmp->lfd = fd;
|
tmp->lfd = fd;
|
||||||
@@ -130,7 +106,7 @@ int multi_fd(int fd, t_gnlist **lst)
|
|||||||
else
|
else
|
||||||
tmp->next = tmp;
|
tmp->next = tmp;
|
||||||
*lst = tmp;
|
*lst = tmp;
|
||||||
} // ft_putstr("lfd:");ft_putnbr((*lst)->lfd);ft_putstr(")-(");tmp2=*lst;while(tmp2->next!=*lst){ft_putnbr(tmp2->lfd);ft_putstr("-");tmp2=tmp2->next;}ft_putnbr(tmp2->lfd);ft_putstr("-(");ft_putnbr(tmp2->next->lfd);ft_putstr("))");
|
}
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,43 +1,21 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* get_next_line.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2019/12/31 17:05:53 by hulamy #+# #+# */
|
||||||
|
/* Updated: 2019/12/31 17:25:31 by hulamy ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "get_next_line_bonus.h"
|
#include "get_next_line_bonus.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** //:set noendofline binary
|
|
||||||
** //https://github.com/lgrellie/gnl_tester
|
|
||||||
** //https://github.com/Mazoise/42TESTERS-GNL
|
|
||||||
** //https://github.com/charMstr/GNL_lover
|
|
||||||
** //https://github.com/mrjvs/42cursus_gnl_tests
|
|
||||||
** //https://github.com/Sherchryst/gnlkiller
|
|
||||||
** //https://github.com/Hellio404/Get_Next_Line_Tester
|
|
||||||
** //https://github.com/TinfoilPancakes/get-next-line-testing-tools
|
|
||||||
**
|
|
||||||
** #include <stdio.h> //for printf
|
** #include <stdio.h> //for printf
|
||||||
** #include <fcntl.h> //for open
|
** #include <fcntl.h> //for open
|
||||||
**
|
**
|
||||||
** void ft_putchar(char c){
|
|
||||||
** write(1, &c, 1);
|
|
||||||
** }
|
|
||||||
**
|
|
||||||
** void ft_putstr(char *s)
|
|
||||||
** {
|
|
||||||
** while (s && *s)
|
|
||||||
** ft_putchar(*s++);
|
|
||||||
** }
|
|
||||||
**
|
|
||||||
** void ft_putnbr(int n)
|
|
||||||
** {
|
|
||||||
** long l;
|
|
||||||
**
|
|
||||||
** l = n;
|
|
||||||
** if (l < 0)
|
|
||||||
** {
|
|
||||||
** ft_putchar('-');
|
|
||||||
** l *= -1;
|
|
||||||
** }
|
|
||||||
** if (l >= 10)
|
|
||||||
** ft_putnbr(l / 10);
|
|
||||||
** ft_putchar((l % 10) + '0');
|
|
||||||
** }
|
|
||||||
**
|
|
||||||
** int main(int ac, char **av)
|
** int main(int ac, char **av)
|
||||||
** {
|
** {
|
||||||
** int *fd;
|
** int *fd;
|
||||||
@@ -86,12 +64,10 @@ int free_lst(t_gnlist **lst, int ret)
|
|||||||
{
|
{
|
||||||
t_gnlist *tmp;
|
t_gnlist *tmp;
|
||||||
|
|
||||||
tmp = *lst; // t_gnlist *tmp2;/*ft_putstr("\n");*/ft_putstr("(");
|
tmp = *lst;
|
||||||
while (tmp->next != *lst)
|
while (tmp->next != *lst)
|
||||||
{ // ft_putnbr(tmp->lfd);ft_putstr("-");
|
|
||||||
tmp = tmp->next;
|
tmp = tmp->next;
|
||||||
} // ft_putnbr(tmp->lfd);ft_putstr("-(");ft_putnbr(tmp->next->lfd);ft_putstr("))");
|
tmp->next = (*lst)->next;
|
||||||
tmp->next = (*lst)->next; // ft_putstr("->(");ft_putnbr(tmp->lfd);ft_putstr("-");ft_putnbr(tmp->next->lfd);ft_putstr(")");
|
|
||||||
free((*lst)->str);
|
free((*lst)->str);
|
||||||
if (*lst == (*lst)->next)
|
if (*lst == (*lst)->next)
|
||||||
{
|
{
|
||||||
@@ -102,7 +78,7 @@ int free_lst(t_gnlist **lst, int ret)
|
|||||||
{
|
{
|
||||||
free(*lst);
|
free(*lst);
|
||||||
*lst = tmp;
|
*lst = tmp;
|
||||||
} // tmp2=tmp;ft_putstr("(");while(tmp2->next!=tmp){ft_putnbr(tmp2->lfd);ft_putstr("-");tmp2=tmp2->next;}ft_putnbr(tmp2->lfd);ft_putstr("-(");ft_putnbr(tmp2->next->lfd);ft_putstr("))");
|
}
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,13 +86,13 @@ int multi_fd(int fd, t_gnlist **lst)
|
|||||||
{
|
{
|
||||||
t_gnlist *tmp;
|
t_gnlist *tmp;
|
||||||
|
|
||||||
tmp = *lst; // t_gnlist *tmp2;ft_putstr(" multi(fd:");ft_putnbr(fd);ft_putstr("-(check:");tmp2=tmp;while(tmp2 && tmp2->next!=tmp){ft_putnbr(tmp2->lfd);ft_putstr("-");tmp2=tmp2->next;}if(tmp2)ft_putnbr(tmp2->lfd);ft_putstr(")-(start:");
|
tmp = *lst;
|
||||||
while (*lst && (*lst)->lfd != fd && (*lst)->next != tmp)
|
while (*lst && (*lst)->lfd != fd && (*lst)->next != tmp)
|
||||||
{ // ft_putnbr((*lst)->lfd);ft_putstr("-");
|
{
|
||||||
*lst = (*lst)->next;
|
*lst = (*lst)->next;
|
||||||
} // if(*lst)ft_putnbr((*lst)->lfd);ft_putstr(")-(");
|
}
|
||||||
if (!tmp || ((*lst)->next == tmp && (*lst)->lfd != fd))
|
if (!tmp || ((*lst)->next == tmp && (*lst)->lfd != fd))
|
||||||
{ // ft_putstr("create ");
|
{
|
||||||
if (!(tmp = (t_gnlist*)malloc(sizeof(*tmp))))
|
if (!(tmp = (t_gnlist*)malloc(sizeof(*tmp))))
|
||||||
return (0);
|
return (0);
|
||||||
tmp->lfd = fd;
|
tmp->lfd = fd;
|
||||||
@@ -130,7 +106,7 @@ int multi_fd(int fd, t_gnlist **lst)
|
|||||||
else
|
else
|
||||||
tmp->next = tmp;
|
tmp->next = tmp;
|
||||||
*lst = tmp;
|
*lst = tmp;
|
||||||
} // ft_putstr("lfd:");ft_putnbr((*lst)->lfd);ft_putstr(")-(");tmp2=*lst;while(tmp2->next!=*lst){ft_putnbr(tmp2->lfd);ft_putstr("-");tmp2=tmp2->next;}ft_putnbr(tmp2->lfd);ft_putstr("-(");ft_putnbr(tmp2->next->lfd);ft_putstr("))");
|
}
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,12 +6,12 @@
|
|||||||
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2019/01/29 10:19:37 by hulamy #+# #+# */
|
/* Created: 2019/01/29 10:19:37 by hulamy #+# #+# */
|
||||||
/* Updated: 2019/12/19 19:38:39 by hulamy ### ########.fr */
|
/* Updated: 2019/12/31 17:28:33 by hulamy ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#ifndef GET_NEXT_LINE_H
|
#ifndef GET_NEXT_LINE_BONUS_H
|
||||||
# define GET_NEXT_LINE_H
|
# define GET_NEXT_LINE_BONUS_H
|
||||||
|
|
||||||
# include <string.h>
|
# include <string.h>
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2019/12/11 00:26:54 by hulamy #+# #+# */
|
/* Created: 2019/12/11 00:26:54 by hulamy #+# #+# */
|
||||||
/* Updated: 2019/12/29 18:07:58 by hulamy ### ########.fr */
|
/* Updated: 2019/12/31 17:23:54 by hulamy ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user