text: /* ************************************************************************** */
  /*                                                                            */
  /*                                                        :::      ::::::::   */
  /*   ft_strlcat.c                                       :+:      :+:    :+:   */
  /*                                                    +:+ +:+         +:+     */
  /*   By: lsandor- <marvin@42.fr>                    +#+  +:+       +#+        */
  /*                                                +#+#+#+#+#+   +#+           */
  /*   Created: 2018/11/23 14:31:38 by lsandor-          #+#    #+#             */
  /*   Updated: 2018/11/30 12:24:19 by lsandor-         ###   ########.fr       */
  /*                                                                            */
  /* ************************************************************************** */
  
  #include <string.h>
  #include "libft.h"
  
  /*
  ** 	Appends src to string dst of size siz (unlike strncat, siz is the
  **	full size of dst, not space left).  At most size-1 characters
  **	will be copied.  Always NUL terminates (unless siz <= strlen(dst)).
  **	Returns strlen(src) + MIN(siz, strlen(initial dst)).
  **	If retval >= siz, truncation occurred.
  */
  
  size_t	ft_strlcat(char *dst, const char *src, size_t size)
  {
  	char		*d;
  	const char	*s;
  	size_t		n;
  	size_t		dlen;
  
  	d = dst;
  	s = src;
  	n = size;
  	while (n-- != 0 && *d != '\0')
  		d++;
  	dlen = d - dst;
  	n = size - dlen;
  	if (n == 0)
  		return (dlen + ft_strlen(s));
  	while (*s != '\0')
  	{
  		if (n != 1)
  		{
  			*d++ = *s;
  			n--;
  		}
  		s++;
  	}
  	*d = '\0';
  	return (dlen + (s - src));
  }
  