-
Notifications
You must be signed in to change notification settings - Fork 0
/
data.c
executable file
·81 lines (74 loc) · 2.66 KB
/
data.c
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
** data.c
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "data.h"
#include "memory.h"
#include "silist.h"
gg data_constructor (void)
{
/* set defaults */
gg newgg = (gg) check_malloc (sizeof(global_glob));
newgg->progname = NULL;
newgg->max_word_length = 8;
newgg->universe = char_set_g_constructor();
newgg->regex = char_set_g_constructor();
newgg->last_class = char_set_g_constructor();
newgg->debug_code = 1;
newgg->max_universe_num = ((int) pow(2, K_NUM_UNIVERSE_SETS)) - 1;
newgg->num_alternation_strings = 0;
newgg->num_groups_started = 0;
newgg->num_groups_completed = 0;
newgg->group_start_g_pos = silist_constructor();
newgg->last_group_started = silist_constructor();
newgg->finished_groups = silist_constructor();
newgg->char_class_start = -1;
newgg->num_char_classes_started = 0;
newgg->last_chartype_parsed = CT_UNDEFINED;
newgg->last_value_parsed = 0;
newgg->last_value_parsed_extra = 0;
newgg->parse_regex_mark = -1;
newgg->current_atom_start_pos = 0;
newgg->universe_check_code = 3;
newgg->stop_code = '\0';
newgg->num_words_output = -1;
newgg->readable_output = 0;
newgg->parsing_alt_list = silist_constructor();
newgg->parsing_alt_pos_list = silist_constructor();
newgg->tnodes = 0;
/* Set the default universe to the letters A-Z, a-z, and numbers
** 0-9.
** Change the first number to the desired default universe
** number. The meanings of the numbers can be found inside
** the function being called. */
char_set_g_add_universe(newgg->universe, 7);
newgg->progname = NULL;
return (newgg);
}
void data_somehow_copy (gg dest, gg src)
{
silist_free(dest->group_start_g_pos);
silist_free(dest->last_group_started);
silist_free(dest->finished_groups);
dest->num_groups_started = src->num_groups_started;
dest->num_groups_completed = src->num_groups_completed;
dest->group_start_g_pos = silist_copy_deep(src->group_start_g_pos);
dest->last_group_started = silist_copy_deep(src->last_group_started);
dest->finished_groups = silist_copy_deep(src->finished_groups);
dest->num_char_classes_started = src->num_char_classes_started;
dest->char_class_start = src->char_class_start;
dest->last_chartype_parsed = src->last_chartype_parsed;
dest->last_value_parsed = src->last_value_parsed;
dest->last_value_parsed_extra = src->last_value_parsed_extra;
dest->current_atom_start_pos = src->current_atom_start_pos;
}
void data_free (gg g)
{
free(g->progname);
char_set_g_free(g->universe);
char_set_g_free(g->regex);
silist_free(g->group_start_g_pos);
free(g);
}