-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxlseq.h
78 lines (72 loc) · 1.81 KB
/
xlseq.h
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
/* See LICENSE for copyright and license details. */
struct long_short {
const wchar_t *l, *s;
};
struct full_sample {
char **samples;
size_t len;
};
union sample_space {
struct {
const char *last;
const char *middle;
const char *first; /* may be NULL if not enough samples */
} ordered;
const char *samples[3];
};
struct buffered_matcher_state {
wchar_t buf[BUFSIZ];
long bufpos;
};
int buffered_pattern_match(const wchar_t rune,
struct buffered_matcher_state *state,
const struct long_short *dataset,
size_t datalen);
void buffered_pattern_run(union sample_space samples, unsigned long count,
const struct long_short *dataset,
size_t datalen);
/* string pattern */
struct string_pattern_state {
int common_check;
const char *common_end; /* NULL if no common section discovered */
};
int string_pattern_match();
void string_pattern_run(union sample_space samples, unsigned long count);
/* number pattern */
int number_pattern_match(const wchar_t rune);
void number_pattern_run(struct full_sample samples, unsigned long count);
/* date pattern */
static const char *datefmt[] = {
"%T",
"%H:%M",
"%I:%M %p",
"%r",
"%F",
};
int date_pattern_match(const char *in);
void date_pattern_run(union sample_space samples, unsigned long count);
/* days pattern */
static const struct long_short days[] = {
{L"monday", L"mon"},
{L"tuesday", L"tue"},
{L"wednesday", L"wed"},
{L"thursday", L"thur"},
{L"friday", L"fri"},
{L"saturday", L"sat"},
{L"sunday", L"sun"}
};
/* months pattern */
static const struct long_short months[] = {
{L"january", L"jan"},
{L"february", L"feb"},
{L"march", L"mar"},
{L"april", L"apr"},
{L"may", L"may"},
{L"june", L"jun"},
{L"july", L"jul"},
{L"august", L"aug"},
{L"september", L"sept"},
{L"october", L"oct"},
{L"november", L"nov"},
{L"december", L"dec"}
};