projects
/
org.ibex.core.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8246cec
)
2003/08/10 06:30:03
author
megacz
<megacz@xwt.org>
Fri, 30 Jan 2004 07:04:19 +0000
(07:04 +0000)
committer
megacz
<megacz@xwt.org>
Fri, 30 Jan 2004 07:04:19 +0000
(07:04 +0000)
darcs-hash:
20040130070419
-2ba56-
39242c40961cd01c623e8353eb3c2bf8bd4253a2
.gz
src/org/xwt/util/Preprocessor.java
patch
|
blob
|
history
diff --git
a/src/org/xwt/util/Preprocessor.java
b/src/org/xwt/util/Preprocessor.java
index
b653c46
..
7fc1502
100644
(file)
--- a/
src/org/xwt/util/Preprocessor.java
+++ b/
src/org/xwt/util/Preprocessor.java
@@
-21,7
+21,7
@@
import java.io.*;
public class Preprocessor {
static Hashtable replace = new Hashtable();
public class Preprocessor {
static Hashtable replace = new Hashtable();
- static Hashtable savereplace = replace;
+ static Hashtable repeatreplace = null;
static Vector sinceLastRepeat = null;
public static void main(String[] args) throws IOException {
static Vector sinceLastRepeat = null;
public static void main(String[] args) throws IOException {
@@
-36,34
+36,38
@@
public class Preprocessor {
String key = trimmed.substring(0, trimmed.indexOf(' '));
String val = trimmed.substring(trimmed.indexOf(' ')).trim();
replace.put(key, val);
String key = trimmed.substring(0, trimmed.indexOf(' '));
String val = trimmed.substring(trimmed.indexOf(' ')).trim();
replace.put(key, val);
+ System.out.println(); // preserve line numbers
} else if (trimmed.startsWith("//#repeat ")) {
StringTokenizer st = new StringTokenizer(trimmed.substring(9), " ");
} else if (trimmed.startsWith("//#repeat ")) {
StringTokenizer st = new StringTokenizer(trimmed.substring(9), " ");
- savereplace = replace;
- replace = (Hashtable)replace.clone();
+ repeatreplace = (Hashtable)replace.clone();
while (st.hasMoreTokens()) {
String tok = st.nextToken().trim();
String key = tok.substring(0, tok.indexOf('/'));
String val = tok.substring(tok.indexOf('/') + 1);
while (st.hasMoreTokens()) {
String tok = st.nextToken().trim();
String key = tok.substring(0, tok.indexOf('/'));
String val = tok.substring(tok.indexOf('/') + 1);
- replace.put(key, val);
+ repeatreplace.put(key, val);
}
sinceLastRepeat = new Vector();
}
sinceLastRepeat = new Vector();
+ System.out.println(); // preserve line numbers
} else if (trimmed.startsWith("//#end")) {
} else if (trimmed.startsWith("//#end")) {
- replace = savereplace;
+ Hashtable save = replace;
+ replace = repeatreplace;
System.out.println();
System.out.println();
- for(int i=0; i<sinceLastRepeat.size(); i++) processLine((String)sinceLastRepeat.elementAt(i));
+ for(int i=0; i<sinceLastRepeat.size() - 1; i++) processLine((String)sinceLastRepeat.elementAt(i), true);
sinceLastRepeat = null;
sinceLastRepeat = null;
+ replace = save;
} else {
} else {
- processLine(s);
+ processLine(s, false);
}
}
}
}
}
}
- static void processLine(String s) throws IOException {
+ static void processLine(String s, boolean deleteLineEndings) throws IOException {
+ if (deleteLineEndings && s.indexOf("//") != -1) s = s.substring(0, s.indexOf("//"));
for(int i=0; i<s.length(); i++) {
char c = s.charAt(i);
if (!Character.isLetter(c) && !Character.isDigit(c) && c != '_') {
for(int i=0; i<s.length(); i++) {
char c = s.charAt(i);
if (!Character.isLetter(c) && !Character.isDigit(c) && c != '_') {
@@
-81,7
+85,7
@@
public class Preprocessor {
else System.out.print(tok);
i = j - 1;
}
else System.out.print(tok);
i = j - 1;
}
- System.out.println();
+ if (!deleteLineEndings) System.out.println();
}
}
}
}