Merge branch 'develop' into feature/JAL-3551Pymol
[jalview.git] / src / com / stevesoft / pat / Group.java
index 4f73114..22d9f81 100755 (executable)
@@ -1,42 +1,77 @@
-//\r
-// This software is now distributed according to\r
-// the Lesser Gnu Public License.  Please see\r
-// http://www.gnu.org/copyleft/lesser.txt for\r
-// the details.\r
-//    -- Happy Computing!\r
-//\r
-package com.stevesoft.pat;\r
-import java.util.Hashtable;\r
-\r
-/** This class implements the (?@<>) syntax that matches\r
- a balanced parenthesis.  Not in perl 5. */\r
-class Group extends Pattern {\r
-    char op,cl;\r
-    Group(char opi,char cli) {\r
-        op = opi;\r
-        cl = cli;\r
-    }\r
-    public int matchInternal(int pos,Pthings pt) {\r
-        int i,count=1;\r
-        if(pos < pt.src.length())\r
-            if(!Masked(pos,pt) && pt.src.charAt(pos) != op)\r
-                return -1;\r
-        for(i=pos+1;i<pt.src.length();i++) {\r
-            char c = pt.src.charAt(i);\r
-            boolean b = !Masked(i,pt);\r
-            if(b && c == ESC) {\r
-                i++;\r
-            } else {\r
-                if(b && c == cl) count--;\r
-                if(count == 0) return nextMatch(i+1,pt);\r
-                if(b && c == op) count++;\r
-            }\r
-        }\r
-        return -1;\r
-    }\r
-    public String toString() {\r
-        return "(?@"+op+cl+")"+nextString();\r
-    }\r
-    public patInt minChars() { return new patInt(2); }\r
-    Pattern clone1(Hashtable h) { return new Group(op,cl); }\r
-};\r
+//
+// 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.Hashtable;
+
+/**
+ * This class implements the (?@<>) syntax that matches a balanced parenthesis.
+ * Not in perl 5.
+ */
+class Group extends Pattern
+{
+  char op, cl;
+
+  Group(char opi, char cli)
+  {
+    op = opi;
+    cl = cli;
+  }
+
+  public int matchInternal(int pos, Pthings pt)
+  {
+    int i, count = 1;
+    if (pos < pt.src.length())
+    {
+      if (!Masked(pos, pt) && pt.src.charAt(pos) != op)
+      {
+        return -1;
+      }
+    }
+    for (i = pos + 1; i < pt.src.length(); i++)
+    {
+      char c = pt.src.charAt(i);
+      boolean b = !Masked(i, pt);
+      if (b && c == ESC)
+      {
+        i++;
+      }
+      else
+      {
+        if (b && c == cl)
+        {
+          count--;
+        }
+        if (count == 0)
+        {
+          return nextMatch(i + 1, pt);
+        }
+        if (b && c == op)
+        {
+          count++;
+        }
+      }
+    }
+    return -1;
+  }
+
+  public String toString()
+  {
+    return "(?@" + op + cl + ")" + nextString();
+  }
+
+  public patInt minChars()
+  {
+    return new patInt(2);
+  }
+
+  Pattern clone1(Hashtable h)
+  {
+    return new Group(op, cl);
+  }
+};