~yadi/squid/parser-ng-icap-pt2

« back to all changes in this revision

Viewing changes to src/SBuf.cc

  • Committer: Amos Jeffries
  • Date: 2015-08-22 14:11:43 UTC
  • mfrom: (13957.1.280 trunk)
  • Revision ID: squid3@treenet.co.nz-20150822141143-r5cvm5u5mx6n8ciu
Merged from trunk rev.14237

Show diffs side-by-side

added added

removed removed

Lines of Context:
802
802
    return npos;
803
803
}
804
804
 
 
805
SBuf::size_type
 
806
SBuf::findLastOf(const CharacterSet &set, size_type endPos) const
 
807
{
 
808
    ++stats.find;
 
809
 
 
810
    if (isEmpty())
 
811
        return npos;
 
812
 
 
813
    if (endPos == npos || endPos >= length())
 
814
        endPos = length() - 1;
 
815
 
 
816
    debugs(24, 7, "last of characterset " << set.name << " in id " << id);
 
817
    const char *start = buf();
 
818
    for (const char *cur = start + endPos; cur >= start; --cur) {
 
819
        if (set[*cur])
 
820
            return cur - start;
 
821
    }
 
822
    debugs(24, 7, "not found");
 
823
    return npos;
 
824
}
 
825
 
 
826
SBuf::size_type
 
827
SBuf::findLastNotOf(const CharacterSet &set, size_type endPos) const
 
828
{
 
829
    ++stats.find;
 
830
 
 
831
    if (isEmpty())
 
832
        return npos;
 
833
 
 
834
    if (endPos == npos || endPos >= length())
 
835
        endPos = length() - 1;
 
836
 
 
837
    debugs(24, 7, "last not of characterset " << set.name << " in id " << id);
 
838
    const char *start = buf();
 
839
    for (const char *cur = start + endPos; cur >= start; --cur) {
 
840
        if (!set[*cur])
 
841
            return cur - start;
 
842
    }
 
843
    debugs(24, 7, "not found");
 
844
    return npos;
 
845
}
 
846
 
805
847
/*
806
848
 * TODO: borrow a sscanf implementation from Linux or similar?
807
849
 * we'd really need a vsnscanf(3)... ? As an alternative, a