X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=unused%2Fcom%2Fstevesoft%2Fpat%2FBackMatch.java;h=4aca715d69f8fa0c73ee07673d1fbef853fab944;hb=6319110ce33faa76ee6cf9832e78faa224510fed;hp=1b166e9f194239217f8a42c763b7d9540b48c5f1;hpb=6154cb57a6eac3bb1344b8342495f5bb701ee921;p=jalviewjs.git diff --git a/unused/com/stevesoft/pat/BackMatch.java b/unused/com/stevesoft/pat/BackMatch.java index 1b166e9..4aca715 100644 --- a/unused/com/stevesoft/pat/BackMatch.java +++ b/unused/com/stevesoft/pat/BackMatch.java @@ -1,57 +1,57 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -import java.util.*; - -/** - * Provides the ability to match a backreference from within a Pattern. - */ -class BackMatch extends Pattern -{ - int id; - - BackMatch(int id) - { - this.id = id; - } - - public String toString() - { - return "\\" + (id) + nextString(); - } - - public int matchInternal(int pos, Pthings p) - { - int i1 = p.marks[id]; - int i2 = p.marks[id + p.nMarks]; - int imax = i2 - i1; - if (i1 < 0 || imax < 0 || pos + imax > p.src.length()) - { - return -1; - } - int ns = p.src.length() - pos; - if (imax < ns) - { - ns = imax; - } - for (int i = 0; i < ns; i++) - { - if (p.src.charAt(i + i1) != p.src.charAt(pos + i)) - { - return -1; - } - } - return nextMatch(pos + imax, p); - } - - Pattern clone1(Hashtable h) - { - return new BackMatch(id); - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +import java.util.*; + +/** + * Provides the ability to match a backreference from within a Pattern. + */ +class BackMatch extends Pattern +{ + int id; + + BackMatch(int id) + { + this.id = id; + } + + public String toString() + { + return "\\" + (id) + nextString(); + } + + public int matchInternal(int pos, Pthings p) + { + int i1 = p.marks[id]; + int i2 = p.marks[id + p.nMarks]; + int imax = i2 - i1; + if (i1 < 0 || imax < 0 || pos + imax > p.src.length()) + { + return -1; + } + int ns = p.src.length() - pos; + if (imax < ns) + { + ns = imax; + } + for (int i = 0; i < ns; i++) + { + if (p.src.charAt(i + i1) != p.src.charAt(pos + i)) + { + return -1; + } + } + return nextMatch(pos + imax, p); + } + + Pattern clone1(Hashtable h) + { + return new BackMatch(id); + } +}