summaryrefslogtreecommitdiffstats
path: root/src/u_parse.c
blob: b49e6bae6bc6e57847e2ff0dcc40bfaee5f73b20 (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   u_parse.c                                          :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/02/14 17:19:27 by rbousset          #+#    #+#             */
/*   Updated: 2020/02/14 17:19:29 by rbousset         ###   ########lyon.fr   */
/*                                                                            */
/* ************************************************************************** */

#include <libft.h>

#include "u_utils.h"
#include "d_define.h"

t_quote_mode
	u_meet_dquote(const char *head, char *ptr, t_quote_mode mode)
{
	if (mode == Q_NONE)
	{
		if (u_is_not_escaped(head, ptr) == TRUE)
		{
			return (Q_DOUBLE);
		}
		else
		{
			return (Q_NONE);
		}
	}
	else if (mode == Q_DOUBLE && u_is_not_escaped(head, ptr) == TRUE)
	{
		return (Q_NONE);
	}
	return (mode);
}

t_quote_mode
	u_meet_squote(const char *head, char *ptr, t_quote_mode mode)
{
	if (mode == Q_NONE)
	{
		if (u_is_not_escaped(head, ptr) == TRUE)
		{
			return (Q_SINGLE);
		}
		else
		{
			return (Q_NONE);
		}
	}
	else if (mode == Q_SINGLE)
	{
		return (Q_NONE);
	}
	return (mode);
}