File: chartabconstruct.c

package info (click to toggle)
yodl 4.05.02-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,724 kB
  • sloc: ansic: 7,803; perl: 683; cpp: 570; sh: 411; xml: 190; makefile: 163
file content (75 lines) | stat: -rw-r--r-- 2,504 bytes parent folder | download | duplicates (11)
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
#include "chartab.ih"

/*
    The regular expression of chartab-elements consists of the following
parts:

                "[[:space:]]*"          - start with optional whitespace
            "'((\\\\)?.)'"              - followed by one character between
                                            single quotes, optionally preceded
                                            by a backslash
                "[[:space:]]*"          - followed by optional white space
            "="                         - and an '=' sign
                "[[:space:]]*"          - followed by optional white space
            "\"(((\\\\.)|[^\"])*)\""    - followed by any series of chars,
                                          each optionally preceded by a \,
                                          enclosed in double string quotes

    d_regex_oct is identical to d_regex, but has the character expression
            "'\\\\([0-7]{3})'"          - three octal digits preceded by a \,
                                          surrounded by single quotes.
                                          Example: '\123'

    d_regex_hex is identical to d_regex, but has the character expression
            "'0x([0-9a-fA-F]{2})'"      - 0x followed by 2 hex digits,
                                          surrounded by single quotes.
                                          Example: '0xab'
*/

void chartab_construct() {
    if
    (
        regcomp
        (
            &chartab.d_regex,
                "[[:space:]]*"
            "'((\\\\)?.)'"
                "[[:space:]]*"
            "="
                "[[:space:]]*"
            "\"(((\\\\.)|[^\"])*)\""
            ,
            REG_EXTENDED | REG_NEWLINE
        )
        ||
        regcomp
        (
            &chartab.d_regex_oct,
                "[[:space:]]*"
            "'\\\\([0-7]{3})'"
                "[[:space:]]*"
            "="
                "[[:space:]]*"
            "\"(((\\\\.)|[^\"])*)\""
            ,
            REG_EXTENDED | REG_NEWLINE
        )
        ||
        regcomp
        (
            &chartab.d_regex_hex,
                "[[:space:]]*"
            "'0x([0-9a-fA-F]{2})'"
                "[[:space:]]*"
            "="
                "[[:space:]]*"
            "\"(((\\\\.)|[^\"])*)\""
            ,
            REG_EXTENDED | REG_NEWLINE
        )
    )
        if (message_show(MSG_EMERG))
            message("Chartab_construct(): regcomp() failed");

    stack_construct(&chartab.d_chartab_st, NULL);
}