~ubuntu-branches/ubuntu/vivid/emscripten/vivid

« back to all changes in this revision

Viewing changes to system/include/libcxx/regex

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-09-20 22:44:35 UTC
  • mfrom: (4.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20130920224435-apuwj4fsl3fqv1a6
Tags: 1.5.6~20130920~6010666-1
* New snapshot release
* Update the list of supported architectures to the same as libv8
  (Closes: #723129)
* emlibtool has been removed from upstream.
* Fix warning syntax-error-in-dep5-copyright
* Refresh of the patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
2769
2769
    void __push_end_marked_subexpression(unsigned);
2770
2770
    void __push_empty();
2771
2771
    void __push_word_boundary(bool);
2772
 
    void __push_lookahead(const basic_regex&, bool);
 
2772
    void __push_lookahead(const basic_regex&, bool, unsigned);
2773
2773
 
2774
2774
    template <class _Allocator>
2775
2775
        bool
2843
2843
                 const basic_regex<_Cp, _Tp>& __e,
2844
2844
                 regex_constants::match_flag_type __flags);
2845
2845
 
 
2846
    template <class _Iter, class _Ap, class _Cp, class _Tp>
 
2847
    friend
 
2848
    bool
 
2849
    regex_search(__wrap_iter<_Iter> __first,
 
2850
                 __wrap_iter<_Iter> __last,
 
2851
                 match_results<__wrap_iter<_Iter>, _Ap>& __m,
 
2852
                 const basic_regex<_Cp, _Tp>& __e,
 
2853
                 regex_constants::match_flag_type __flags);
 
2854
 
2846
2855
    template <class, class> friend class __lookahead;
2847
2856
};
2848
2857
 
2898
2907
    typedef __owns_one_state<_CharT> base;
2899
2908
 
2900
2909
    basic_regex<_CharT, _Traits> __exp_;
 
2910
    unsigned __mexp_;
2901
2911
    bool __invert_;
2902
2912
 
2903
2913
    __lookahead(const __lookahead&);
2906
2916
    typedef _VSTD::__state<_CharT> __state;
2907
2917
 
2908
2918
    _LIBCPP_INLINE_VISIBILITY
2909
 
    __lookahead(const basic_regex<_CharT, _Traits>& __exp, bool __invert, __node<_CharT>* __s)
2910
 
        : base(__s), __exp_(__exp), __invert_(__invert) {}
 
2919
    __lookahead(const basic_regex<_CharT, _Traits>& __exp, bool __invert, __node<_CharT>* __s, unsigned __mexp)
 
2920
        : base(__s), __exp_(__exp), __invert_(__invert), __mexp_(__mexp) {}
2911
2921
 
2912
2922
    virtual void __exec(__state&) const;
2913
2923
};
2921
2931
    bool __matched = __exp_.__match_at_start_ecma(__s.__current_, __s.__last_,
2922
2932
                                                  __m,
2923
2933
                                                  __s.__flags_ | regex_constants::match_continuous,
2924
 
                                                  true);
 
2934
                                                  __s.__at_first_ && __s.__current_ == __s.__first_);
2925
2935
    if (__matched != __invert_)
2926
2936
    {
2927
2937
        __s.__do_ = __state::__accept_but_not_consume;
2928
2938
        __s.__node_ = this->first();
 
2939
        for (unsigned __i = 1; __i < __m.size(); ++__i) {
 
2940
            __s.__sub_matches_[__mexp_ + __i - 1] = __m.__matches_[__i];
 
2941
        }
2929
2942
    }
2930
2943
    else
2931
2944
    {
3420
3433
                case '+':
3421
3434
                case '?':
3422
3435
                case '{':
 
3436
                case '}':
3423
3437
                    __push_char(*__temp);
3424
3438
                    __first = ++__temp;
3425
3439
                    break;
3903
3917
        {
3904
3918
            __val = 8 * __val + *__first - '0';
3905
3919
            if (++__first != __last && ('0' <= *__first && *__first <= '7'))
3906
 
                __val = 8 * __val + *__first - '0';
 
3920
                __val = 8 * __val + *__first++ - '0';
3907
3921
        }
3908
3922
        if (__str)
3909
3923
            *__str = _CharT(__val);
4158
4172
                                basic_regex __exp;
4159
4173
                                __exp.__flags_ = __flags_;
4160
4174
                                __temp = __exp.__parse(++__temp, __last);
4161
 
                                __push_lookahead(_VSTD::move(__exp), false);
 
4175
                                unsigned __mexp = __exp.__marked_count_;
 
4176
                                __push_lookahead(_VSTD::move(__exp), false, __marked_count_);
 
4177
                                __marked_count_ += __mexp;
4162
4178
#ifndef _LIBCPP_NO_EXCEPTIONS
4163
4179
                                if (__temp == __last || *__temp != ')')
4164
4180
                                    throw regex_error(regex_constants::error_paren);
4171
4187
                                basic_regex __exp;
4172
4188
                                __exp.__flags_ = __flags_;
4173
4189
                                __temp = __exp.__parse(++__temp, __last);
4174
 
                                __push_lookahead(_VSTD::move(__exp), true);
 
4190
                                unsigned __mexp = __exp.__marked_count_;
 
4191
                                __push_lookahead(_VSTD::move(__exp), true, __marked_count_);
 
4192
                                __marked_count_ += __mexp;
4175
4193
#ifndef _LIBCPP_NO_EXCEPTIONS
4176
4194
                                if (__temp == __last || *__temp != ')')
4177
4195
                                    throw regex_error(regex_constants::error_paren);
4408
4426
        case 'c':
4409
4427
            if ((__t = _VSTD::next(__first)) != __last)
4410
4428
            {
4411
 
                if ('A' <= *__t <= 'Z' || 'a' <= *__t <= 'z')
 
4429
                if (('A' <= *__t && *__t <= 'Z') || 
 
4430
                    ('a' <= *__t && *__t <= 'z'))
4412
4431
                {
4413
4432
                    if (__str)
4414
4433
                        *__str = _CharT(*__t % 32);
4416
4435
                        __push_char(_CharT(*__t % 32));
4417
4436
                    __first = ++__t;
4418
4437
                }
 
4438
#ifndef _LIBCPP_NO_EXCEPTIONS
 
4439
                else 
 
4440
                    throw regex_error(regex_constants::error_escape);
 
4441
#endif  // _LIBCPP_NO_EXCEPTIONS
4419
4442
            }
 
4443
#ifndef _LIBCPP_NO_EXCEPTIONS
 
4444
            else
 
4445
                throw regex_error(regex_constants::error_escape);
 
4446
#endif  // _LIBCPP_NO_EXCEPTIONS
4420
4447
            break;
4421
4448
        case 'u':
4422
4449
            ++__first;
4481
4508
                ++__first;
4482
4509
            }
4483
4510
#ifndef _LIBCPP_NO_EXCEPTIONS
4484
 
            else if (__str)
 
4511
            else
4485
4512
                throw regex_error(regex_constants::error_escape);
4486
4513
#endif  // _LIBCPP_NO_EXCEPTIONS
4487
4514
            break;
4740
4767
template <class _CharT, class _Traits>
4741
4768
void
4742
4769
basic_regex<_CharT, _Traits>::__push_lookahead(const basic_regex& __exp,
4743
 
                                               bool __invert)
 
4770
                                               bool __invert,
 
4771
                                               unsigned __mexp)
4744
4772
{
4745
4773
    __end_->first() = new __lookahead<_CharT, _Traits>(__exp, __invert,
4746
 
                                                           __end_->first());
 
4774
                                                           __end_->first(), __mexp);
4747
4775
    __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4748
4776
}
4749
4777
 
5763
5791
{
5764
5792
    __m.__init(1 + mark_count(), __first, __last,
5765
5793
                                    __flags & regex_constants::__no_update_pos);
5766
 
    if (__match_at_start(__first, __last, __m, __flags, true))
 
5794
    if (__match_at_start(__first, __last, __m, __flags, 
 
5795
                                    !(__flags & regex_constants::__no_update_pos)))
5767
5796
    {
5768
5797
        __m.__prefix_.second = __m[0].first;
5769
5798
        __m.__prefix_.matched = __m.__prefix_.first != __m.__prefix_.second;
5800
5829
             const basic_regex<_CharT, _Traits>& __e,
5801
5830
             regex_constants::match_flag_type __flags = regex_constants::match_default)
5802
5831
{
5803
 
    basic_string<_CharT> __s(__first, __last);
5804
 
    match_results<const _CharT*> __mc;
5805
 
    bool __r = __e.__search(__s.data(), __s.data() + __s.size(), __mc, __flags);
 
5832
    int __offset = (__flags & regex_constants::match_prev_avail) ? 1 : 0;
 
5833
    basic_string<_CharT> __s(_VSTD::prev(__first, __offset), __last);
 
5834
    match_results<const _CharT*> __mc;
 
5835
    bool __r = __e.__search(__s.data() + __offset, __s.data() + __s.size(), __mc, __flags);
 
5836
    __m.__assign(__first, __last, __mc, __flags & regex_constants::__no_update_pos);
 
5837
    return __r;
 
5838
}
 
5839
 
 
5840
template <class _Iter, class _Allocator, class _CharT, class _Traits>
 
5841
inline _LIBCPP_INLINE_VISIBILITY
 
5842
bool
 
5843
regex_search(__wrap_iter<_Iter> __first,
 
5844
             __wrap_iter<_Iter> __last,
 
5845
             match_results<__wrap_iter<_Iter>, _Allocator>& __m,
 
5846
             const basic_regex<_CharT, _Traits>& __e,
 
5847
             regex_constants::match_flag_type __flags = regex_constants::match_default)
 
5848
{
 
5849
    match_results<const _CharT*> __mc;
 
5850
    bool __r = __e.__search(__first.base(), __last.base(), __mc, __flags);
5806
5851
    __m.__assign(__first, __last, __mc, __flags & regex_constants::__no_update_pos);
5807
5852
    return __r;
5808
5853
}
6044
6089
{
6045
6090
    __flags_ |= regex_constants::__no_update_pos;
6046
6091
    _BidirectionalIterator __start = __match_[0].second;
6047
 
    if (__match_.length() == 0)
 
6092
    if (__match_.empty())
6048
6093
    {
6049
6094
        if (__start == __end_)
6050
6095
        {