This file is indexed.

/usr/include/lexertl/string_token.hpp is in libpuma-dev 1:1.1+svn20120529-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
// string_token.hpp
// Copyright (c) 2005-2011 Ben Hanson (http://www.benhanson.net/)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file licence_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef LEXERTL_STRING_TOKEN_HPP
#define LEXERTL_STRING_TOKEN_HPP

#include "char_traits.hpp"
#include <ios> // Needed by GCC 4.4
#include <iostream>
#include <string>
#include <utility>
#include <vector>

namespace lexertl
{
template<typename ch_type>
struct basic_string_token
{
    typedef ch_type char_type;
    typedef basic_char_traits<char_type> char_traits;
    typedef typename char_traits::index_type index_type;
    typedef std::pair<index_type, index_type> range;
    typedef std::vector<range> range_vector;
    typedef std::basic_string<char_type> string;
    typedef basic_string_token<char_type> string_token;

    range_vector _ranges;

    basic_string_token ()
    {
    }

    basic_string_token (char_type ch_)
    {
        insert (range (ch_, ch_));
    }

    basic_string_token (char_type first_, char_type second_)
    {
        insert (range (first_, second_));
    }

    void clear ()
    {
        _ranges.clear ();
    }

    bool empty () const
    {
        return _ranges.empty ();
    }

    bool any () const
    {
        return _ranges.size () == 1 && _ranges.front ().first == 0 &&
            _ranges.front ().second == char_traits::max_val ();
    }

    bool operator < (const basic_string_token &rhs_) const
    {
        return _ranges < rhs_._ranges;
    }

    bool operator == (const basic_string_token &rhs_) const
    {
        return _ranges == rhs_._ranges;
    }

    bool negatable () const
    {
        std::size_t size_ = 0;
        typename range_vector::const_iterator iter_ = _ranges.begin ();
        typename range_vector::const_iterator end_ = _ranges.end ();

        for (; iter_ != end_; ++iter_)
        {
            size_ += static_cast<std::size_t>(iter_->second) + 1 -
                static_cast<std::size_t>(iter_->first);
        }

        return size_ > static_cast<std::size_t>(char_traits::max_val ()) / 2;
    }

    void swap (basic_string_token &rhs_)
    {
        _ranges.swap (rhs_._ranges);
    }

    void insert (const basic_string_token &rhs_)
    {
        typename range_vector::const_iterator iter_ = rhs_._ranges.begin ();
        typename range_vector::const_iterator end_ = rhs_._ranges.end ();

        for (; iter_ != end_; ++iter_)
        {
            insert (*iter_);
        }
    }

    // Deliberately pass by value - may modify
    typename range_vector::iterator insert (range rhs_)
    {
        bool insert_ = true;
        typename range_vector::iterator iter_ = _ranges.begin ();
        typename range_vector::const_iterator end_ = _ranges.end ();

        while (iter_ != end_)
        {
            // follows current item
            if (rhs_.first > iter_->second)
            {
                if (rhs_.first == iter_->second + 1)
                {
                    // Auto normalise
                    rhs_.first = iter_->first;
                }
                else
                {
                    // No intersection, consider next
                    ++iter_;
                    continue;
                }
            }
            // Precedes current item
            else if (rhs_.second < iter_->first)
            {
                if (rhs_.second == iter_->first - 1)
                {
                    // Auto normalise
                    rhs_.second = iter_->second;
                }
                else
                {
                    // insert here
                    break;
                }
            }
            else
            {
                // overlap (under)
                if (rhs_.first < iter_->first)
                {
                    if (rhs_.second < iter_->second)
                    {
                        rhs_.second = iter_->second;
                    }
                }
                // overlap (over)
                else if (rhs_.second > iter_->second)
                {
                    if (rhs_.first > iter_->first)
                    {
                        rhs_.first = iter_->first;
                    }
                }
                // subset
                else
                {
                    insert_ = false;
                    iter_ = _ranges.end ();
                    break;
                }
            }

            // Code minimisation: this always applies unless we have already
            // exited the loop, or "continue" executed.
            iter_ = _ranges.erase (iter_);
            end_ = _ranges.end ();
        }

        if (insert_)
        {
            iter_ = _ranges.insert(iter_, rhs_);
        }

        return iter_;
    }

    void negate ()
    {
        index_type next_ = 0;
        const index_type max_ = char_traits::max_val ();
        string_token temp_;
        typename range_vector::iterator iter_ = _ranges.begin ();
        typename range_vector::const_iterator end_ = _ranges.end ();
        bool finished_ = false;

        for (; iter_ != end_; ++iter_)
        {
            if (next_ < iter_->first)
            {
                temp_.insert (range (next_, iter_->first - 1));
            }

            if (iter_->second < max_)
            {
                next_ = iter_->second + 1;
            }
            else
            {
                finished_ = true;
                break;
            }
        }

        if (!finished_)
        {
            temp_.insert (range (next_, max_));
        }

        swap (temp_);
    }

    void intersect (basic_string_token &rhs_, basic_string_token &overlap_)
    {
        typename range_vector::iterator lhs_iter_ = _ranges.begin ();
        typename range_vector::const_iterator lhs_end_ = _ranges.end ();
        typename range_vector::iterator rhs_iter_ = rhs_._ranges.begin ();
        typename range_vector::const_iterator rhs_end_ = rhs_._ranges.end ();

        while (lhs_iter_ != lhs_end_ && rhs_iter_ != rhs_end_)
        {
            if (rhs_iter_->first > lhs_iter_->second)
            {
                ++lhs_iter_;
            }
            else if (rhs_iter_->second < lhs_iter_->first)
            {
                ++rhs_iter_;
            }
            else
            {
                range range_;

                if (rhs_iter_->first > lhs_iter_->first)
                {
                    range_.first = rhs_iter_->first;
                }
                else
                {
                    range_.first = lhs_iter_->first;
                }

                if (rhs_iter_->second < lhs_iter_->second)
                {
                    range_.second = rhs_iter_->second;
                }
                else
                {
                    range_.second = lhs_iter_->second;
                }

                adjust (range_, *this, lhs_iter_, lhs_end_);
                adjust (range_, rhs_, rhs_iter_, rhs_end_);
                overlap_.insert (range_);
            }
        }
    }

    static string escape_char (const typename char_traits::index_type ch_)
    {
        string out_;

        switch (ch_)
        {
            case '\0':
                out_ += '\\';
                out_ += '0';
                break;
            case '\a':
                out_ += '\\';
                out_ += 'a';
                break;
            case '\b':
                out_ += '\\';
                out_ += 'b';
                break;
            case 27:
                out_ += '\\';
                out_ += 'x';
                out_ += '1';
                out_ += 'b';
                break;
            case '\f':
                out_ += '\\';
                out_ += 'f';
                break;
            case '\n':
                out_ += '\\';
                out_ += 'n';
                break;
            case '\r':
                out_ += '\\';
                out_ += 'r';
                break;
            case '\t':
                out_ += '\\';
                out_ += 't';
                break;
            case '\v':
                out_ += '\\';
                out_ += 'v';
                break;
            case '\\':
                out_ += '\\';
                out_ += '\\';
                break;
            case '"':
                out_ += '\\';
                out_ += '"';
                break;
            case '\'':
                out_ += '\\';
                out_ += '\'';
                break;
            default:
            {
                if (ch_ < 32 || ch_ > 126)
                {
                    std::basic_stringstream<char_type> ss_;

                    out_ += '\\';
                    out_ += 'x';
                    ss_ << std::hex <<
                        static_cast<std::size_t> (ch_);
                    out_ += ss_.str ();
                }
                else
                {
                    out_ += ch_;
                }

                break;
            }
        }

        return out_;
    }

private:
    void adjust (const range &range_, basic_string_token &token_,
        typename range_vector::iterator &iter_,
        typename range_vector::const_iterator &end_)
    {
        if (range_.first > iter_->first)
        {
            const index_type second_ = iter_->second;

            iter_->second = range_.first - 1;

            if (range_.second < second_)
            {
                range new_range_ (range_.second + 1, second_);

                iter_ = token_.insert (new_range_);
                end_ = token_._ranges.end ();
            }
        }
        else if (range_.second < iter_->second)
        {
            iter_->first = range_.second + 1;
        }
        else
        {
            iter_ = token_._ranges.erase (iter_);
            end_ = token_._ranges.end ();
        }
    }
};
}

#endif