Blob Blame Raw
### Eclipse Workspace Patch 1.0
#P org.eclipse.jdt.core
Index: batch/org/eclipse/jdt/internal/compiler/batch/Main.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java,v
retrieving revision 1.254.4.1
diff -u -r1.254.4.1 Main.java
--- batch/org/eclipse/jdt/internal/compiler/batch/Main.java	2 Jul 2006 10:11:58 -0000	1.254.4.1
+++ batch/org/eclipse/jdt/internal/compiler/batch/Main.java	20 Oct 2006 21:45:05 -0000
@@ -28,9 +28,11 @@
 import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.LinkedList;
 import java.util.Locale;
 import java.util.Map;
 import java.util.MissingResourceException;
@@ -40,8 +42,8 @@
 
 import org.eclipse.jdt.core.compiler.CategorizedProblem;
 import org.eclipse.jdt.core.compiler.CharOperation;
-import org.eclipse.jdt.core.compiler.InvalidInputException;
 import org.eclipse.jdt.core.compiler.IProblem;
+import org.eclipse.jdt.core.compiler.InvalidInputException;
 import org.eclipse.jdt.internal.compiler.ClassFile;
 import org.eclipse.jdt.internal.compiler.CompilationResult;
 import org.eclipse.jdt.internal.compiler.Compiler;
@@ -59,9 +61,9 @@
 import org.eclipse.jdt.internal.compiler.problem.DefaultProblem;
 import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
 import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
+import org.eclipse.jdt.internal.compiler.util.HashtableOfObject;
 import org.eclipse.jdt.internal.compiler.util.Messages;
 import org.eclipse.jdt.internal.compiler.util.SuffixConstants;
-import org.eclipse.jdt.internal.compiler.util.HashtableOfObject;
 import org.eclipse.jdt.internal.compiler.util.Util;
 
 public class Main implements ProblemSeverities, SuffixConstants {
@@ -2989,56 +2991,73 @@
 	ArrayList currentRuleSpecs = new ArrayList(defaultSize);
 	StringTokenizer tokenizer = new StringTokenizer(currentPath,
 			File.pathSeparator + "[]", true); //$NON-NLS-1$
+	LinkedList list = new LinkedList(Collections.list(tokenizer));
+	
 	// state machine
-	final int start = 0; 
-	final int readyToClose = 1;
-	// 'path' 'path1[rule];path2'
-	final int readyToCloseEndingWithRules = 2;
-	// 'path[rule]' 'path1;path2[rule]'
-	final int readyToCloseOrOtherEntry = 3;
-	// 'path[rule];' 'path;' 'path1;path2;'
-	final int rulesNeedAnotherRule = 4;
-	// 'path[rule1;'
-	final int rulesStart = 5;
-	// 'path[' 'path1;path2['
-	final int rulesReadyToClose = 6;
-	// 'path[rule' 'path[rule1;rule2'
+	// process list in reverse order, start refers to end of list
+	final int start = 0;
+	final int rulesStart = 1;
+	// ']' '];path'
+	final int rulesReadyToCloseOrOtherRule = 2;
+	// 'rule]' 'rule1;rule2]'
+	final int rulesNeedAnotherRule = 3;
+	// ';rule2]' ';rule2;rule3];path'
+	final int readyForPath = 4;
+	// '[rule]' '[rule1;rule2]'
+	final int readyToCloseOrOtherEntry = 5;
+	// 'path[rule]' 'path' 'path1;path2'
+	final int readyForPathOrRules = 6;
+	// ';path[rule]' ';path'
 	final int error = 99;
 	int state = start;
+
 	String token = null;
-	while (tokenizer.hasMoreTokens()) {
-		token = tokenizer.nextToken();
+	while (!list.isEmpty()) {
+		token = (String)list.removeLast();
 		if (token.equals(File.pathSeparator)) {
 			switch (state) {
 			case start:
 				break;
-			case readyToClose:
-			case readyToCloseEndingWithRules:
 			case readyToCloseOrOtherEntry:
-				state = readyToCloseOrOtherEntry;
 				addNewEntry(paths, currentClasspathName, currentRuleSpecs, customEncoding, isSourceOnly);
 				currentRuleSpecs.clear();
+				state = readyForPathOrRules;
 				break;
-			case rulesReadyToClose:
+			case rulesReadyToCloseOrOtherRule:
 				state = rulesNeedAnotherRule;
 				break;
+			case rulesNeedAnotherRule:
+				break;
+			case readyForPathOrRules:
+				break;
 			default:
 				state = error;
 			}
 		} else if (token.equals("[")) { //$NON-NLS-1$
 			switch (state) {
-			case readyToClose:
-				state = rulesStart;
+			case start:
+			case readyForPath:
+			case readyForPathOrRules:
+				currentClasspathName = getPath(list, token);
+				state = readyToCloseOrOtherEntry;
 				break;
-			default:
+			case rulesReadyToCloseOrOtherRule:
+				state =  readyForPath;
+				break;
+			default:  
 				state = error;
 			}
 		} else if (token.equals("]")) { //$NON-NLS-1$
 			switch (state) {
-			case rulesReadyToClose:
-				state = readyToCloseEndingWithRules;
+			case start:
+			case readyForPathOrRules:
+				state = rulesStart;
 				break;
-			default:
+			case readyForPath:
+				currentClasspathName = getPath(list, token);
+				state = readyToCloseOrOtherEntry;
+				break;
+			default:  
 				state = error;
 			}
 
@@ -3046,24 +3065,25 @@
 			// regular word
 			switch (state) {
 			case start:
-			case readyToCloseOrOtherEntry:
-				state = readyToClose;
-				currentClasspathName = token;
+			case readyForPath:
+			case readyForPathOrRules:
+				currentClasspathName = getPath(list, token);
+				state = readyToCloseOrOtherEntry;
 				break;
-			case rulesNeedAnotherRule:
 			case rulesStart:
-				state = rulesReadyToClose;
+			case rulesNeedAnotherRule:
 				currentRuleSpecs.add(token);
+				state = rulesReadyToCloseOrOtherRule;
 				break;
 			default:
 				state = error;
 			}
 		}
 	}
+
 	switch(state) {
-		case readyToClose :
-		case readyToCloseEndingWithRules :
-		case readyToCloseOrOtherEntry :
+		case readyForPathOrRules:
+		case readyToCloseOrOtherEntry:
 			addNewEntry(paths, currentClasspathName, currentRuleSpecs, customEncoding, isSourceOnly);
 			break;
 		default :
@@ -3071,4 +3091,13 @@
 			this.logger.logIncorrectClasspath(currentPath);
 	}
 }
+
+private String getPath(LinkedList list, String path) {
+	while (!list.isEmpty()) {
+		if (File.pathSeparator.equalsIgnoreCase((String)list.getLast()))
+			break;
+		path = (String)list.removeLast() + path;
+	}
+	return path;
+}
 }