463691 {
463697 const uint8_t* resetp = NULL;
463698 if (!run_forward) {
463699 using std::swap;
463701 }
463702
463703 const uint8_t* bytemap = prog_->bytemap();
463704 const uint8_t* lastmatch = NULL;
463705 bool matched = false;
463706
463708
463709 if (s->IsMatch()) {
463710 matched = true;
463711 lastmatch = p;
463712 if (
params->matches != NULL && kind_ == Prog::kManyMatch) {
463713 for (int i = s->ninst_ - 1; i >= 0; i--) {
463714 int id = s->inst_[i];
463715 if (id == MatchSep)
463716 break;
463717 params->matches->insert(
id);
463718 }
463719 }
463720 if (want_earliest_match) {
463721 params->ep =
reinterpret_cast<const char*
>(lastmatch);
463722 return true;
463723 }
463724 }
463725
463726 while (p != ep) {
463727
463728 if (can_prefix_accel && s == start) {
463729
463730
463731
463732 p = BytePtr(prog_->PrefixAccel(p, ep - p));
463733 if (p == NULL) {
463734 p = ep;
463735 break;
463736 }
463737 }
463738
463739 int c;
463740 if (run_forward)
463741 c = *p++;
463742 else
463743 c = *--p;
463744
463745
463746
463747
463748
463749
463750
463751
463752
463753
463754
463755
463756
463757
463758
463759
463760
463761
463762
463763 State* ns = s->next_[bytemap[c]].load(std::memory_order_acquire);
463764 if (ns == NULL) {
463765 ns = RunStateOnByteUnlocked(s, c);
463766 if (ns == NULL) {
463767
463768
463769
463770
463771
463772
463773
463774
463775
463776 if (dfa_should_bail_when_slow && resetp != NULL &&
463777 static_cast<size_t>(p - resetp) < 10*state_cache_.size() &&
463778 kind_ != Prog::kManyMatch) {
463780 return false;
463781 }
463782 resetp = p;
463783
463784
463787
463788
463789 ResetCache(
params->cache_lock);
463790
463791
463792 if ((start = save_start.Restore()) == NULL ||
463793 (s = save_s.Restore()) == NULL) {
463794
463796 return false;
463797 }
463798 ns = RunStateOnByteUnlocked(s, c);
463799 if (ns == NULL) {
463800 LOG(DFATAL) << "RunStateOnByteUnlocked failed after ResetCache";
463802 return false;
463803 }
463804 }
463805 }
463806 if (ns <= SpecialStateMax) {
463807 if (ns == DeadState) {
463808 params->ep =
reinterpret_cast<const char*
>(lastmatch);
463809 return matched;
463810 }
463811
463812 params->ep =
reinterpret_cast<const char*
>(ep);
463813 return true;
463814 }
463815
463816 s = ns;
463817 if (s->IsMatch()) {
463818 matched = true;
463819
463820
463821 if (run_forward)
463822 lastmatch = p - 1;
463823 else
463824 lastmatch = p + 1;
463825 if (
params->matches != NULL && kind_ == Prog::kManyMatch) {
463826 for (int i = s->ninst_ - 1; i >= 0; i--) {
463827 int id = s->inst_[i];
463828 if (id == MatchSep)
463829 break;
463830 params->matches->insert(
id);
463831 }
463832 }
463833 if (want_earliest_match) {
463834 params->ep =
reinterpret_cast<const char*
>(lastmatch);
463835 return true;
463836 }
463837 }
463838 }
463839
463840
463841
463842
463843 int lastbyte;
463844 if (run_forward) {
463846 lastbyte = kByteEndText;
463847 else
463848 lastbyte = EndPtr(
params->text)[0] & 0xFF;
463849 } else {
463850 if (BeginPtr(
params->text) == BeginPtr(
params->context))
463851 lastbyte = kByteEndText;
463852 else
463853 lastbyte = BeginPtr(
params->text)[-1] & 0xFF;
463854 }
463855
463856 State* ns = s->next_[ByteMap(lastbyte)].load(std::memory_order_acquire);
463857 if (ns == NULL) {
463858 ns = RunStateOnByteUnlocked(s, lastbyte);
463859 if (ns == NULL) {
463861 ResetCache(
params->cache_lock);
463862 if ((s = save_s.Restore()) == NULL) {
463864 return false;
463865 }
463866 ns = RunStateOnByteUnlocked(s, lastbyte);
463867 if (ns == NULL) {
463868 LOG(DFATAL) << "RunStateOnByteUnlocked failed after Reset";
463870 return false;
463871 }
463872 }
463873 }
463874 if (ns <= SpecialStateMax) {
463875 if (ns == DeadState) {
463876 params->ep =
reinterpret_cast<const char*
>(lastmatch);
463877 return matched;
463878 }
463879
463880 params->ep =
reinterpret_cast<const char*
>(ep);
463881 return true;
463882 }
463883
463884 s = ns;
463885 if (s->IsMatch()) {
463886 matched = true;
463887 lastmatch = p;
463888 if (
params->matches != NULL && kind_ == Prog::kManyMatch) {
463889 for (int i = s->ninst_ - 1; i >= 0; i--) {
463890 int id = s->inst_[i];
463891 if (id == MatchSep)
463892 break;
463893 params->matches->insert(
id);
463894 }
463895 }
463896 }
463897
463898 params->ep =
reinterpret_cast<const char*
>(lastmatch);
463899 return matched;
463900}
Definition duckdb.cpp:463562