File: rawtext.cc

package info (click to toggle)
flexc%2B%2B 2.17.01-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,180 kB
  • sloc: cpp: 6,467; makefile: 148; sh: 130; ansic: 18
file content (36 lines) | stat: -rw-r--r-- 722 bytes parent folder | download
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
#include "fpattern.ih"

    // text without (d)quotes, accepted as-is
FPattern FPattern::rawText(States &states, std::string const &str)
{
    size_t length = str.length();

    FPattern ret;

    ret.d_length = length;

    if (length == 0)            // pathological case: string without contents
    {
        Pair pair = states.next2();
        states[pair.first] = State(EMPTY, pair.second, 0);

        ret = pair;
        return ret;
    }

    size_t *indices = states.next(length + 1);
    Pair pair = Pair(*indices, indices[length]);

    for (size_t idx = 0; idx != length; ++idx)
        states[indices[idx]] = State(str[idx], indices[idx + 1]);

    delete [] indices;

    ret = pair;
    return ret;
}