aboutsummaryrefslogtreecommitdiffstats
path: root/src/proguard/WordReader.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/proguard/WordReader.java')
-rw-r--r--src/proguard/WordReader.java127
1 files changed, 33 insertions, 94 deletions
diff --git a/src/proguard/WordReader.java b/src/proguard/WordReader.java
index 4e7a511..d73505a 100644
--- a/src/proguard/WordReader.java
+++ b/src/proguard/WordReader.java
@@ -2,7 +2,7 @@
* ProGuard -- shrinking, optimization, obfuscation, and preverification
* of Java bytecode.
*
- * Copyright (c) 2002-2011 Eric Lafortune (eric@graphics.cornell.edu)
+ * Copyright (c) 2002-2009 Eric Lafortune (eric@graphics.cornell.edu)
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
@@ -105,11 +105,9 @@ public abstract class WordReader
* Reads a word from this WordReader, or from one of its active included
* WordReader objects.
*
- * @param isFileName return a complete line (or argument), if the word
- * isn't an option (it doesn't start with '-').
* @return the read word.
*/
- public String nextWord(boolean isFileName) throws IOException
+ public String nextWord() throws IOException
{
currentWord = null;
@@ -117,7 +115,7 @@ public abstract class WordReader
if (includeWordReader != null)
{
// Does the included word reader still produce a word?
- currentWord = includeWordReader.nextWord(isFileName);
+ currentWord = includeWordReader.nextWord();
if (currentWord != null)
{
// Return it if so.
@@ -131,22 +129,12 @@ public abstract class WordReader
// Get a word from this reader.
- // Skip any whitespace and comments left on the current line.
- if (currentLine != null)
+ // Skip leading whitespace.
+ while (currentLine != null &&
+ currentIndex < currentLineLength &&
+ Character.isWhitespace(currentLine.charAt(currentIndex)))
{
- // Skip any leading whitespace.
- while (currentIndex < currentLineLength &&
- Character.isWhitespace(currentLine.charAt(currentIndex)))
- {
- currentIndex++;
- }
-
- // Skip any comments.
- if (currentIndex < currentLineLength &&
- isComment(currentLine.charAt(currentIndex)))
- {
- currentIndex = currentLineLength;
- }
+ currentIndex++;
}
// Make sure we have a non-blank line.
@@ -158,28 +146,29 @@ public abstract class WordReader
return null;
}
- currentLineLength = currentLine.length();
-
- // Skip any leading whitespace.
- currentIndex = 0;
- while (currentIndex < currentLineLength &&
- Character.isWhitespace(currentLine.charAt(currentIndex)))
+ // Trim off any comments.
+ int comments_start = currentLine.indexOf(COMMENT_CHARACTER);
+ if (comments_start >= 0)
{
- currentIndex++;
- }
+ currentLineLength = comments_start;
- // Remember any leading comments.
- if (currentIndex < currentLineLength &&
- isComment(currentLine.charAt(currentIndex)))
- {
// Remember the comments.
- String comment = currentLine.substring(currentIndex + 1);
+ String comment = currentLine.substring(comments_start + 1);
currentComments = currentComments == null ?
comment :
currentComments + '\n' + comment;
+ }
+ else
+ {
+ currentLineLength = currentLine.length();
+ }
- // Skip the comments.
- currentIndex = currentLineLength;
+ // Skip leading whitespace.
+ currentIndex = 0;
+ while (currentIndex < currentLineLength &&
+ Character.isWhitespace(currentLine.charAt(currentIndex)))
+ {
+ currentIndex++;
}
}
@@ -189,7 +178,12 @@ public abstract class WordReader
char startChar = currentLine.charAt(startIndex);
- if (isQuote(startChar))
+ if (isDelimiter(startChar))
+ {
+ // The next word is a single delimiting character.
+ endIndex = ++currentIndex;
+ }
+ else if (isQuote(startChar))
{
// The next word is starting with a quote character.
// Skip the opening quote.
@@ -211,39 +205,6 @@ public abstract class WordReader
endIndex = currentIndex++;
}
- else if (isFileName &&
- !isOption(startChar))
- {
- // The next word is a (possibly optional) file name.
- // Find the end of the line, the first path separator, the first
- // option, or the first comment.
- while (currentIndex < currentLineLength)
- {
- char currentCharacter = currentLine.charAt(currentIndex);
- if (isFileDelimiter(currentCharacter) ||
- (isOption(currentCharacter) ||
- isComment(currentCharacter)) &&
- Character.isWhitespace(currentLine.charAt(currentIndex-1))) {
- break;
- }
-
- currentIndex++;
- }
-
- endIndex = currentIndex;
-
- // Trim any trailing whitespace.
- while (endIndex > startIndex &&
- Character.isWhitespace(currentLine.charAt(endIndex-1)))
- {
- endIndex--;
- }
- }
- else if (isDelimiter(startChar))
- {
- // The next word is a single delimiting character.
- endIndex = ++currentIndex;
- }
else
{
// The next word is a simple character string.
@@ -252,9 +213,9 @@ public abstract class WordReader
while (currentIndex < currentLineLength)
{
char currentCharacter = currentLine.charAt(currentIndex);
- if (isDelimiter(currentCharacter) ||
- Character.isWhitespace(currentCharacter) ||
- isComment(currentCharacter)) {
+ if (isDelimiter(currentCharacter) ||
+ Character.isWhitespace(currentCharacter))
+ {
break;
}
@@ -344,18 +305,6 @@ public abstract class WordReader
// Small utility methods.
- private boolean isOption(char character)
- {
- return character == '-';
- }
-
-
- private boolean isComment(char character)
- {
- return character == COMMENT_CHARACTER;
- }
-
-
private boolean isDelimiter(char character)
{
return character == '@' ||
@@ -369,16 +318,6 @@ public abstract class WordReader
}
- private boolean isFileDelimiter(char character)
- {
- return character == '(' ||
- character == ')' ||
- character == ',' ||
- character == ';' ||
- character == File.pathSeparatorChar;
- }
-
-
private boolean isQuote(char character)
{
return character == '\'' ||