You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2006/06/23 14:55:41 UTC
svn commit: r416709 -
/cocoon/trunk/core/cocoon-bootstrap/src/main/java/org/apache/cocoon/classloader/WildcardMatcherHelper.java
Author: cziegeler
Date: Fri Jun 23 05:55:41 2006
New Revision: 416709
URL: http://svn.apache.org/viewvc?rev=416709&view=rev
Log:
Merge with latest changes
Modified:
cocoon/trunk/core/cocoon-bootstrap/src/main/java/org/apache/cocoon/classloader/WildcardMatcherHelper.java
Modified: cocoon/trunk/core/cocoon-bootstrap/src/main/java/org/apache/cocoon/classloader/WildcardMatcherHelper.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-bootstrap/src/main/java/org/apache/cocoon/classloader/WildcardMatcherHelper.java?rev=416709&r1=416708&r2=416709&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-bootstrap/src/main/java/org/apache/cocoon/classloader/WildcardMatcherHelper.java (original)
+++ cocoon/trunk/core/cocoon-bootstrap/src/main/java/org/apache/cocoon/classloader/WildcardMatcherHelper.java Fri Jun 23 05:55:41 2006
@@ -216,16 +216,7 @@
// if we reached the end of the pattern just do a string compare with the corresponding part from
// the end of the string
if(ipat >= lpat) {
- // if the remaining length of the string isn't the same as that found in the pattern
- // we do not match
- if(strncmp(apat, sipat, astr, lstr - (lpat - sipat), lpat - sipat)) {
- add(new String(astr, istr, lstr - (lpat - sipat) - istr));
-
- return true;
- }
-
- // otherwise we do not match
- return false;
+ return checkEnds(sipat);
}
// Now we need to check whether the litteral substring of the pattern
@@ -239,8 +230,7 @@
add(new String(astr, sistr, istr - sistr));
istr += l;
- } else // if it is a single star pattern
- {
+ } else {// if it is a single star pattern
// skip the star
++ipat;
@@ -271,17 +261,10 @@
ipat++;
}
- // if we reached the end of the pattern just do a String compare with the corresponding part from
+ // if we reached the end of the pattern just do a string compare with the corresponding part from
// the end of the string
if(ipat >= lpat) {
- if(strncmp(apat, sipat, astr, lstr - (ipat - sipat), ipat - sipat)) {
- add(new String(astr, istr, lstr - (ipat - sipat) - istr)); // TODO: this is wrong
-
- return true;
- }
-
- // otherwise we do not match
- return false;
+ return checkEnds(sipat);
}
// Now we need to check whether the litteral substring of the pattern
@@ -308,7 +291,7 @@
/**
* Scan a possible common suffix
*/
- private void scanLiteralPrefix() {
+ private final void scanLiteralPrefix() {
// scan a common literal suffix
while(ipat < lpat &&
istr < lstr &&
@@ -331,19 +314,32 @@
*
* @return Whether the all the mentioned characters match each other
*/
- private boolean strncmp(final char[] a1,
+ private final boolean strncmp(final char[] a1,
final int o1,
final char[] a2,
final int o2,
final int l) {
- if ( o2 < 0 ) {
- return false;
- }
int i = 0;
- for(i = 0; i < l && o1 + i < a1.length && o2 + i < a2.length && a1[o1 + i] == a2[o2 + i]; i++);
+ while(i < l && o1 + i < a1.length && o2 + i < a2.length && a1[o1 + i] == a2[o2 + i]) i++;
return i == l;
+ }
+
+ private final boolean checkEnds(final int sipat)
+ {
+ // if the remaining length of the string isn't the same as that found in the pattern
+ // we do not match
+ final int l = lpat - sipat; // calculate length of comparison
+ final int ostr = lstr - l; // calculate offset into string
+ if(ostr >= 0 && strncmp(apat, sipat, astr, ostr, l)) {
+ add(new String(astr, istr, ostr - istr));
+
+ return true;
+ }
+
+ // otherwise we do not match
+ return false;
}
}
}