Fix up the functionMetadata.txt stuff to be end-to-end UTF8. Was assuming it before, but breaking on some systems, while now it ought to work fine everywhere

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@653831 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2008-05-06 16:38:34 +00:00
parent 7281f100ef
commit 3475425c5f
4 changed files with 67 additions and 52 deletions

View File

@ -21,6 +21,7 @@ import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
@ -58,7 +59,10 @@ final class FunctionMetadataReader {
throw new RuntimeException("resource '" + METADATA_FILE_NAME + "' not found");
}
BufferedReader br = new BufferedReader(new InputStreamReader(is));
BufferedReader br = null;
try {
br = new BufferedReader(new InputStreamReader(is,"UTF-8"));
} catch(UnsupportedEncodingException e) { /* never happens */ }
FunctionDataBuilder fdb = new FunctionDataBuilder(400);
try {
@ -153,7 +157,7 @@ final class FunctionMetadataReader {
case 'R': return Ptg.CLASS_REF;
case 'A': return Ptg.CLASS_ARRAY;
}
throw new IllegalArgumentException("Unexpected operand type code '" + code + "'");
throw new IllegalArgumentException("Unexpected operand type code '" + code + "' (" + (int)code.charAt(0) + ")");
}
/**

View File

@ -29,7 +29,7 @@
7 MAX 1 30 V R
8 ROW 0 1 V R
9 COLUMN 0 1 V R
10 NA 0 0 V
10 NA 0 0 V
11 NPV 2 30 V V R
12 STDEV 1 30 V R
13 DOLLAR 1 2 V V V
@ -38,7 +38,7 @@
16 COS 1 1 V V
17 TAN 1 1 V V
18 ARCTAN 1 1 V V
19 PI 0 0 V
19 PI 0 0 V
20 SQRT 1 1 V V
21 EXP 1 1 V V
22 LN 1 1 V V
@ -53,8 +53,8 @@
31 MID 3 3 V V V V
32 LEN 1 1 V V
33 VALUE 1 1 V V
34 TRUE 0 0 V
35 FALSE 0 0 V
34 TRUE 0 0 V
35 FALSE 0 0 V
36 AND 1 30 V R
37 OR 1 30 V R
38 NOT 1 1 V V
@ -80,7 +80,7 @@
60 RATE 3 6 V V V V V V V
61 MIRR 3 3 V R V V
62 IRR 1 2 V R V
63 RAND 0 0 V x
63 RAND 0 0 V x
64 MATCH 2 3 V V R R
65 DATE 3 3 V V V V
66 TIME 3 3 V V V V
@ -91,7 +91,7 @@
71 HOUR 1 1 V V
72 MINUTE 1 1 V V
73 SECOND 1 1 V V
74 NOW 0 0 V x
74 NOW 0 0 V x
75 AREAS 1 1 V R
76 ROWS 1 1 V R
77 COLUMNS 1 1 V R
@ -170,10 +170,10 @@
215 JIS 1 1 V V x
219 ADDRESS 2 5 V V V V V V
220 DAYS360 2 2 V V V x
221 TODAY 0 0 V x
221 TODAY 0 0 V x
222 VDB 5 7 V V V V V V V V
227 MEDIAN 1 30 V R …
228 SUMPRODUCT 1 30 V A …
227 MEDIAN 1 30 V R …
228 SUMPRODUCT 1 30 V A …
229 SINH 1 1 V V
230 COSH 1 1 V V
231 TANH 1 1 V V
@ -188,7 +188,7 @@
247 DB 4 5 V V V V V V
252 FREQUENCY 2 2 A R R
261 ERROR.TYPE 1 1 V V
269 AVEDEV 1 30 V R …
269 AVEDEV 1 30 V R …
270 BETADIST 3 5 V V V V V V
271 GAMMALN 1 1 V V
272 BETAINV 3 5 V V V V V V
@ -237,12 +237,12 @@
315 SLOPE 2 2 V A A
316 TTEST 4 4 V A A V V
317 PROB 3 4 V A A V V
318 DEVSQ 1 30 V R …
319 GEOMEAN 1 30 V R …
320 HARMEAN 1 30 V R …
321 SUMSQ 0 30 V R …
322 KURT 1 30 V R …
323 SKEW 1 30 V R …
318 DEVSQ 1 30 V R …
319 GEOMEAN 1 30 V R …
320 HARMEAN 1 30 V R …
321 SUMSQ 0 30 V R …
322 KURT 1 30 V R …
323 SKEW 1 30 V R …
324 ZTEST 2 3 V R V V
325 LARGE 2 2 V R V
326 SMALL 2 2 V R V
@ -274,10 +274,10 @@
358 GETPIVOTDATA 2 30
359 HYPERLINK 1 2 V V V
360 PHONETIC 1 1 V R
361 AVERAGEA 1 30 V R …
362 MAXA 1 30 V R …
363 MINA 1 30 V R …
364 STDEVPA 1 30 V R …
365 VARPA 1 30 V R …
366 STDEVA 1 30 V R …
367 VARA 1 30 V R …
361 AVERAGEA 1 30 V R …
362 MAXA 1 30 V R …
363 MINA 1 30 V R …
364 STDEVPA 1 30 V R …
365 VARPA 1 30 V R …
366 STDEVA 1 30 V R …
367 VARA 1 30 V R …

View File

@ -31,7 +31,7 @@
7 MAX 1 30 V R
8 ROW 0 1 V R
9 COLUMN 0 1 V R
10 NA 0 0 V
10 NA 0 0 V
11 NPV 2 30 V V R
12 STDEV 1 30 V R
13 DOLLAR 1 2 V V V
@ -40,7 +40,7 @@
16 COS 1 1 V V
17 TAN 1 1 V V
18 ATAN 1 1 V V
19 PI 0 0 V
19 PI 0 0 V
20 SQRT 1 1 V V
21 EXP 1 1 V V
22 LN 1 1 V V
@ -55,8 +55,8 @@
31 MID 3 3 V V V V
32 LEN 1 1 V V
33 VALUE 1 1 V V
34 TRUE 0 0 V
35 FALSE 0 0 V
34 TRUE 0 0 V
35 FALSE 0 0 V
36 AND 1 30 V R
37 OR 1 30 V R
38 NOT 1 1 V V
@ -82,7 +82,7 @@
60 RATE 3 6 V V V V V V V
61 MIRR 3 3 V R V V
62 IRR 1 2 V R V
63 RAND 0 0 V x
63 RAND 0 0 V x
64 MATCH 2 3 V V R R
65 DATE 3 3 V V V V
66 TIME 3 3 V V V V
@ -93,7 +93,7 @@
71 HOUR 1 1 V V
72 MINUTE 1 1 V V
73 SECOND 1 1 V V
74 NOW 0 0 V x
74 NOW 0 0 V x
75 AREAS 1 1 V R
76 ROWS 1 1 V R
77 COLUMNS 1 1 V R
@ -172,10 +172,10 @@
215 JIS 1 1 V V x
219 ADDRESS 2 5 V V V V V V
220 DAYS360 2 2 V V V x
221 TODAY 0 0 V x
221 TODAY 0 0 V x
222 VDB 5 7 V V V V V V V V
227 MEDIAN 1 30 V R …
228 SUMPRODUCT 1 30 V A …
227 MEDIAN 1 30 V R …
228 SUMPRODUCT 1 30 V A …
229 SINH 1 1 V V
230 COSH 1 1 V V
231 TANH 1 1 V V
@ -192,7 +192,7 @@
247 DB 4 5 V V V V V V
252 FREQUENCY 2 2 A R R
261 ERROR.TYPE 1 1 V V
269 AVEDEV 1 30 V R …
269 AVEDEV 1 30 V R …
270 BETADIST 3 5 V V V V V V
271 GAMMALN 1 1 V V
272 BETAINV 3 5 V V V V V V
@ -241,12 +241,12 @@
315 SLOPE 2 2 V A A
316 TTEST 4 4 V A A V V
317 PROB 3 4 V A A V V
318 DEVSQ 1 30 V R …
319 GEOMEAN 1 30 V R …
320 HARMEAN 1 30 V R …
321 SUMSQ 0 30 V R …
322 KURT 1 30 V R …
323 SKEW 1 30 V R …
318 DEVSQ 1 30 V R …
319 GEOMEAN 1 30 V R …
320 HARMEAN 1 30 V R …
321 SUMSQ 0 30 V R …
322 KURT 1 30 V R …
323 SKEW 1 30 V R …
324 ZTEST 2 3 V R V V
325 LARGE 2 2 V R V
326 SMALL 2 2 V R V
@ -278,10 +278,10 @@
358 GETPIVOTDATA 2 30
359 HYPERLINK 1 2 V V V
360 PHONETIC 1 1 V R
361 AVERAGEA 1 30 V R …
362 MAXA 1 30 V R …
363 MINA 1 30 V R …
364 STDEVPA 1 30 V R …
365 VARPA 1 30 V R …
366 STDEVA 1 30 V R …
367 VARA 1 30 V R …
361 AVERAGEA 1 30 V R …
362 MAXA 1 30 V R …
363 MINA 1 30 V R …
364 STDEVPA 1 30 V R …
365 VARPA 1 30 V R …
366 STDEVA 1 30 V R …
367 VARA 1 30 V R …

View File

@ -25,6 +25,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
@ -354,13 +355,19 @@ public final class ExcelFileFormatDocFunctionExtractor {
}
private static void extractFunctionData(FunctionDataCollector fdc, InputStream is) {
System.setProperty("org.xml.sax.driver", "org.apache.crimson.parser.XMLReaderImpl");
XMLReader xr;
try {
// First up, try the default one
xr = XMLReaderFactory.createXMLReader();
} catch (SAXException e) {
throw new RuntimeException(e);
// Try one for java 1.4
System.setProperty("org.xml.sax.driver", "org.apache.crimson.parser.XMLReaderImpl");
try {
xr = XMLReaderFactory.createXMLReader();
} catch (SAXException e2) {
throw new RuntimeException(e2);
}
}
xr.setContentHandler(new EFFDocHandler(fdc));
@ -383,7 +390,11 @@ public final class ExcelFileFormatDocFunctionExtractor {
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
PrintStream ps = new PrintStream(os);
PrintStream ps = null;
try {
ps = new PrintStream(os,true, "UTF-8");
} catch(UnsupportedEncodingException e) {}
outputLicenseHeader(ps);
Class genClass = ExcelFileFormatDocFunctionExtractor.class;
ps.println("# Created by (" + genClass.getName() + ")");