author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 35253 | jdk/make/src/classes/build/tools/spp/Spp.java@ed92ce9fac46 |
child 53110 | 50677f43ac3d |
child 57074 | 12615de8335e |
permissions | -rw-r--r-- |
898
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
1 |
/* |
35253
ed92ce9fac46
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
23010
diff
changeset
|
2 |
* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. |
898
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
4 |
* |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
898
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
898
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
10 |
* |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
15 |
* accompanied this code). |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
16 |
* |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
20 |
* |
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
898
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
24 |
*/ |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
25 |
|
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
26 |
package build.tools.spp; |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
27 |
|
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
28 |
import java.util.*; |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
29 |
import java.util.regex.*; |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
30 |
|
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
31 |
/* |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
32 |
* Spp: A simple regex-based stream preprocessor based on Mark Reinhold's |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
33 |
* sed-based spp.sh |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
34 |
* |
35253
ed92ce9fac46
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
23010
diff
changeset
|
35 |
* Usage: java build.tools.spp.Spp [-be] [-nel] [-Kkey] -Dvar=value ... <in >out |
898
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
36 |
* |
35253
ed92ce9fac46
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
23010
diff
changeset
|
37 |
* If -nel is declared then empty lines will not be substituted for lines of |
ed92ce9fac46
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
23010
diff
changeset
|
38 |
* text in the template that do not appear in the output. |
898
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
39 |
* |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
40 |
* Meaningful only at beginning of line, works with any number of keys: |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
41 |
* |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
42 |
* #if[key] Includes text between #if/#end if -Kkey specified, |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
43 |
* #else[key] otherwise changes text to blank lines; key test |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
44 |
* #end[key] may be negated by prefixing !, e.g., #if[!key] |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
45 |
* |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
46 |
* #begin If -be is specified then lines up to and including |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
47 |
* #end #begin, and from #end to EOF, are deleted |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
48 |
* |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
49 |
* #warn Changed into warning that file is generated |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
50 |
* |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
51 |
* // ## Changed into blank line |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
52 |
* |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
53 |
* Meaningful anywhere in line |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
54 |
* |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
55 |
* {#if[key]?yes} Expands to yes if -Kkey specified |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
56 |
* {#if[key]?yes:no} Expands to yes if -Kkey, otherwise no |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
57 |
* {#if[!key]?yes} Expands to yes if -Kother |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
58 |
* {#if[!key]?yes:no} Expands to yes if -Kother, otherwise no |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
59 |
* $var$ Expands to value if -Dvar=value given |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
60 |
* |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
61 |
* yes, no must not contain whitespace |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
62 |
* |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
63 |
* @author Xueming Shen |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
64 |
*/ |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
65 |
|
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
66 |
public class Spp { |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
67 |
public static void main(String args[]) throws Exception { |
35253
ed92ce9fac46
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
23010
diff
changeset
|
68 |
Map<String, String> vars = new HashMap<>(); |
ed92ce9fac46
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
23010
diff
changeset
|
69 |
Set<String> keys = new HashSet<>(); |
898
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
70 |
boolean be = false; |
35253
ed92ce9fac46
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
23010
diff
changeset
|
71 |
boolean el = true; |
898
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
72 |
|
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
73 |
for (String arg:args) { |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
74 |
if (arg.startsWith("-D")) { |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
75 |
int i = arg.indexOf('='); |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
76 |
vars.put(arg.substring(2, i),arg.substring(i+1)); |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
77 |
} else if (arg.startsWith("-K")) { |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
78 |
keys.add(arg.substring(2)); |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
79 |
} else if ("-be".equals(arg)) { |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
80 |
be = true; |
35253
ed92ce9fac46
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
23010
diff
changeset
|
81 |
} else if ("-nel".equals(arg)) { |
ed92ce9fac46
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
23010
diff
changeset
|
82 |
el = false; |
898
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
83 |
} else { |
35253
ed92ce9fac46
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
23010
diff
changeset
|
84 |
System.err.println("Usage: java build.tools.spp.Spp [-be] [-nel] [-Kkey] -Dvar=value ... <in >out"); |
898
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
85 |
System.exit(-1); |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
86 |
} |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
87 |
} |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
88 |
|
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
89 |
StringBuffer out = new StringBuffer(); |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
90 |
new Spp().spp(new Scanner(System.in), |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
91 |
out, "", |
35253
ed92ce9fac46
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
23010
diff
changeset
|
92 |
keys, vars, be, el, |
898
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
93 |
false); |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
94 |
System.out.print(out.toString()); |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
95 |
} |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
96 |
|
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
97 |
static final String LNSEP = System.getProperty("line.separator"); |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
98 |
static final String KEY = "([a-zA-Z0-9]+)"; |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
99 |
static final String VAR = "([a-zA-Z0-9_\\-]+)"; |
35253
ed92ce9fac46
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
23010
diff
changeset
|
100 |
static final String TEXT = "([a-zA-Z0-9&;,.<>/#() \\?\\[\\]\\$]+)"; // $ -- hack embedded $var$ |
898
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
101 |
|
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
102 |
static final int GN_NOT = 1; |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
103 |
static final int GN_KEY = 2; |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
104 |
static final int GN_YES = 3; |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
105 |
static final int GN_NO = 5; |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
106 |
static final int GN_VAR = 6; |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
107 |
|
35253
ed92ce9fac46
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
23010
diff
changeset
|
108 |
final Matcher ifkey = Pattern.compile("^#if\\[(!)?" + KEY + "\\]").matcher(""); |
ed92ce9fac46
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
23010
diff
changeset
|
109 |
final Matcher elsekey = Pattern.compile("^#else\\[(!)?" + KEY + "\\]").matcher(""); |
ed92ce9fac46
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
23010
diff
changeset
|
110 |
final Matcher endkey = Pattern.compile("^#end\\[(!)?" + KEY + "\\]").matcher(""); |
ed92ce9fac46
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
23010
diff
changeset
|
111 |
final Matcher vardef = Pattern.compile("\\{#if\\[(!)?" + KEY + "\\]\\?" + TEXT + "(:"+ TEXT + ")?\\}|\\$" + VAR + "\\$").matcher(""); |
ed92ce9fac46
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
23010
diff
changeset
|
112 |
final Matcher vardef2 = Pattern.compile("\\$" + VAR + "\\$").matcher(""); |
898
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
113 |
|
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
114 |
void append(StringBuffer buf, String ln, |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
115 |
Set<String> keys, Map<String, String> vars) { |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
116 |
vardef.reset(ln); |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
117 |
while (vardef.find()) { |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
118 |
String repl = ""; |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
119 |
if (vardef.group(GN_VAR) != null) |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
120 |
repl = vars.get(vardef.group(GN_VAR)); |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
121 |
else { |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
122 |
boolean test = keys.contains(vardef.group(GN_KEY)); |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
123 |
if (vardef.group(GN_NOT) != null) |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
124 |
test = !test; |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
125 |
repl = test?vardef.group(GN_YES):vardef.group(GN_NO); |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
126 |
if (repl == null) |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
127 |
repl = ""; |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
128 |
else { // embedded $var$ |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
129 |
while (vardef2.reset(repl).find()) { |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
130 |
repl = vardef2.replaceFirst(vars.get(vardef2.group(1))); |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
131 |
} |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
132 |
} |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
133 |
} |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
134 |
vardef.appendReplacement(buf, repl); |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
135 |
} |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
136 |
vardef.appendTail(buf); |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
137 |
} |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
138 |
|
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
139 |
// return true if #end[key], #end or EOF reached |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
140 |
boolean spp(Scanner in, StringBuffer buf, String key, |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
141 |
Set<String> keys, Map<String, String> vars, |
35253
ed92ce9fac46
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
23010
diff
changeset
|
142 |
boolean be, boolean el, boolean skip) { |
898
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
143 |
while (in.hasNextLine()) { |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
144 |
String ln = in.nextLine(); |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
145 |
if (be) { |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
146 |
if (ln.startsWith("#begin")) { |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
147 |
buf.setLength(0); //clean up to this line |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
148 |
continue; |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
149 |
} |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
150 |
if (ln.equals("#end")) { |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
151 |
while (in.hasNextLine()) |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
152 |
in.nextLine(); |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
153 |
return true; //discard the rest to EOF |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
154 |
} |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
155 |
} |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
156 |
if (ifkey.reset(ln).find()) { |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
157 |
String k = ifkey.group(GN_KEY); |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
158 |
boolean test = keys.contains(k); |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
159 |
if (ifkey.group(GN_NOT) != null) |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
160 |
test = !test; |
35253
ed92ce9fac46
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
23010
diff
changeset
|
161 |
if (el) buf.append(LNSEP); |
ed92ce9fac46
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
23010
diff
changeset
|
162 |
if (!spp(in, buf, k, keys, vars, be, el, skip || !test)) { |
ed92ce9fac46
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
23010
diff
changeset
|
163 |
spp(in, buf, k, keys, vars, be, el, skip || test); |
898
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
164 |
} |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
165 |
continue; |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
166 |
} |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
167 |
if (elsekey.reset(ln).find()) { |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
168 |
if (!key.equals(elsekey.group(GN_KEY))) { |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
169 |
throw new Error("Mis-matched #if-else-end at line <" + ln + ">"); |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
170 |
} |
35253
ed92ce9fac46
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
23010
diff
changeset
|
171 |
if (el) buf.append(LNSEP); |
898
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
172 |
return false; |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
173 |
} |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
174 |
if (endkey.reset(ln).find()) { |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
175 |
if (!key.equals(endkey.group(GN_KEY))) { |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
176 |
throw new Error("Mis-matched #if-else-end at line <" + ln + ">"); |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
177 |
} |
35253
ed92ce9fac46
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
23010
diff
changeset
|
178 |
if (el) buf.append(LNSEP); |
898
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
179 |
return true; |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
180 |
} |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
181 |
if (ln.startsWith("#warn")) { |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
182 |
ln = "// -- This file was mechanically generated: Do not edit! -- //"; |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
183 |
} else if (ln.trim().startsWith("// ##")) { |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
184 |
ln = ""; |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
185 |
} |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
186 |
if (!skip) { |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
187 |
append(buf, ln, keys, vars); |
35253
ed92ce9fac46
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
23010
diff
changeset
|
188 |
if (!el) buf.append(LNSEP); |
898
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
189 |
} |
35253
ed92ce9fac46
8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables
psandoz
parents:
23010
diff
changeset
|
190 |
if (el) buf.append(LNSEP); |
898
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
191 |
} |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
192 |
return true; |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
193 |
} |
1c4e95595472
6681798: (build) CharsetEncoder.java fails to compile in openjdk6 on ubutu 8.04
sherman
parents:
diff
changeset
|
194 |
} |