aboutsummaryrefslogtreecommitdiff
path: root/src/dstr/ft_dstrsubstitute.c
blob: 84adc2913d1babd9ebbce8d1b74dbea4efe36516 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   ft_dstrsubstitute.c                                :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: charles <charles.cabergs@gmail.com>        +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/05 00:22:55 by charles           #+#    #+#             */
/*   Updated: 2020/04/05 00:38:40 by charles          ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include "libft_dstr.h"

/*
** \brief              Substitute part of a dynamic string for an other string
** \param dstr         Dynamic string to substitute in
** \param replacement  Replacement text
** \param start        Substitution start index
** \param len          Substitution length
*/

t_ftdstr	*ft_dstrsubstitute(
	t_ftdstr *dstr,
	char *replacement,
	size_t start,
	size_t len
)
{
	ft_dstrerase(dstr, start, len);
	return (ft_dstrinsert(dstr, replacement, start));
}