aboutsummaryrefslogtreecommitdiff
path: root/src/lexer/lexer_count_nb_element.c
blob: 1455d5e1384a42a78bedb8df50535e3a876eb016 (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

#include "lexer.h"

int             lexer_count_nb_element(char *input)
{
    int         i;
    int         j;

    i = 0;
    j = 1;
    while(input[i] != '\0')
    {
        if (lexer_sep(input[i]) || input[i] == '"' || input[i] == '\'')
        {
            if (input[i] == '"' || input[i] == '\'')
            {
                i = lexer_verif_entre_cote(input,i);
                j++;
            }
            if (lexer_sep(input[i]))
                {
                    while (lexer_sep(input[i]) || input[i] == ' ')
                        ++i;
                    j++;
                }
            j++;
        }
        i++;
    }
    return (j);
}