libupdate

This commit is contained in:
djonker 2023-03-07 04:33:27 +01:00
parent 5da295673c
commit ffee823f3e
3 changed files with 21 additions and 21 deletions

View File

@ -33,10 +33,10 @@ int findnewline(struct s_gnl *strct);
int newline(struct s_gnl *strct, char **line);
int blimit(int l, struct s_gnl *strct, char **line, char *t);;
int nonewline(int l, struct s_gnl *strct, char **line);
char *ft_substr(char const *s, unsigned int start, size_t len);
void *ft_memcpy(void *dst, const void *src, size_t n);
size_t ft_strlen(char *str);
void ft_bzero(void *s, size_t n);
char *ft_strjoin(char const *s1, char const *s2);
char *gnl_substr(char const *s, unsigned int start, size_t len);
void *gnl_memcpy(void *dst, const void *src, size_t n);
size_t gnl_strlen(char *str);
void gnl_bzero(void *s, size_t n);
char *gnl_strjoin(char const *s1, char const *s2);
#endif

View File

@ -32,17 +32,17 @@ int newline(struct s_gnl *strct, char **line)
char *t;
l = findnewline(strct);
line[0] = ft_substr((const char *)strct->b, 0, l - 1);
line[0] = gnl_substr((const char *)strct->b, 0, l - 1);
if (line[0] == NULL)
return (-1);
t = ft_substr((const char *)strct->b, l, BUFFER_SIZE - l);
t = gnl_substr((const char *)strct->b, l, BUFFER_SIZE - l);
if (t == NULL)
{
free(line[0]);
return (-1);
}
ft_memcpy(strct->b, t, ft_strlen(t));
ft_bzero(&strct->b[ft_strlen(t)], BUFFER_SIZE - ft_strlen(t));
gnl_memcpy(strct->b, t, gnl_strlen(t));
gnl_bzero(&strct->b[gnl_strlen(t)], BUFFER_SIZE - gnl_strlen(t));
free(t);
return (1);
}
@ -55,7 +55,7 @@ int blimit(int l, struct s_gnl *strct, char **line, char *t)
if (l == 1 || l == 0)
{
f = line[0];
line[0] = ft_strjoin(t, line[0]);
line[0] = gnl_strjoin(t, line[0]);
free (f);
}
free(t);
@ -68,8 +68,8 @@ int nonewline(int l, struct s_gnl *strct, char **line)
{
char *t;
t = ft_substr((const char *)strct->b, 0, ft_strlen(strct->b));
ft_bzero(&strct->b[0], BUFFER_SIZE);
t = gnl_substr((const char *)strct->b, 0, gnl_strlen(strct->b));
gnl_bzero(&strct->b[0], BUFFER_SIZE);
l = read(strct->fd, strct->b, BUFFER_SIZE);
if (l == -1 || t == NULL)
{
@ -78,8 +78,8 @@ int nonewline(int l, struct s_gnl *strct, char **line)
}
if (l == BUFFER_SIZE || findnewline(strct) > -1)
return (blimit(l, strct, line, t));
line[0] = ft_strjoin(t, strct->b);
ft_bzero(&strct->b, BUFFER_SIZE);
line[0] = gnl_strjoin(t, strct->b);
gnl_bzero(&strct->b, BUFFER_SIZE);
free(t);
if (line[0] == NULL)
return (-1);

View File

@ -12,7 +12,7 @@
#include "../get_next_line.h"
size_t ft_strlen(char *str)
size_t gnl_strlen(char *str)
{
size_t a;
@ -25,7 +25,7 @@ size_t ft_strlen(char *str)
return (a);
}
void ft_bzero(void *s, size_t n)
void gnl_bzero(void *s, size_t n)
{
char *p;
@ -38,7 +38,7 @@ void ft_bzero(void *s, size_t n)
}
}
void *ft_memcpy(void *dst, const void *src, size_t n)
void *gnl_memcpy(void *dst, const void *src, size_t n)
{
char *d;
const char *s;
@ -55,7 +55,7 @@ void *ft_memcpy(void *dst, const void *src, size_t n)
return (dst);
}
char *ft_strjoin(char const *s1, char const *s2)
char *gnl_strjoin(char const *s1, char const *s2)
{
int c1;
int c2;
@ -65,8 +65,8 @@ char *ft_strjoin(char const *s1, char const *s2)
c1 = 0;
c2 = 0;
l1 = ft_strlen((char *)s1);
l2 = ft_strlen((char *)s2);
l1 = gnl_strlen((char *)s1);
l2 = gnl_strlen((char *)s2);
r = malloc(l1 + l2 + 1);
if (r == NULL)
return (r);
@ -84,7 +84,7 @@ char *ft_strjoin(char const *s1, char const *s2)
return (r);
}
char *ft_substr(char const *s, unsigned int start, size_t len)
char *gnl_substr(char const *s, unsigned int start, size_t len)
{
char *r;
long unsigned int i;