Repository navigation
Expand file tree
/
Copy pathlem_lex_init.c
More file actions
67 lines (59 loc) · 1.68 KB
/
Copy pathlem_lex_init.c
File metadata and controls
67 lines (59 loc) · 1.68 KB
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
59
60
61
62
63
64
65
66
67
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* lem_lex_init.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mle-roy <mle-roy@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/03/03 18:15:23 by mle-roy #+# #+# */
/* Updated: 2014/03/05 18:05:00 by mle-roy ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
#include "lemmin.h"
#include "libft.h"
int is_valid_char_lem(char c)
{
if (c >= 33 && c <= 126)
return (1);
return (0);
}
t_lx *init_lex(void)
{
t_lx *new;
if ((new = (t_lx *)malloc(sizeof(*new))) == NULL)
return (NULL);
new->start = NULL;
new->end = NULL;
new->save = NULL;
new->save_end = NULL;
return (new);
}
t_lex *init_node(char *buf)
{
t_lex *new;
if ((new = (t_lex *)malloc(sizeof(*new))) == NULL)
return (NULL);
new->str = ft_strtrim(buf);
new->next = NULL;
new->prev = NULL;
return (new);
}
void add_to_list(t_lx *list, char *buf)
{
t_lex *node;
node = init_node(buf);
if (node == NULL)
return ;
if (list->start == NULL)
{
list->start = node;
list->end = node;
}
else
{
list->end->next = node;
node->prev = list->end;
list->end = node;
}
}