diff options
Diffstat (limited to 'Build/source/texk/tex4htk/java/xtpipes')
7 files changed, 108 insertions, 43 deletions
diff --git a/Build/source/texk/tex4htk/java/xtpipes/FileInfo.java b/Build/source/texk/tex4htk/java/xtpipes/FileInfo.java index f951ec3bdb8..001b273dce1 100644 --- a/Build/source/texk/tex4htk/java/xtpipes/FileInfo.java +++ b/Build/source/texk/tex4htk/java/xtpipes/FileInfo.java @@ -1,6 +1,6 @@ package xtpipes; /* -FileInfo.java (2008-01-26-00:38) +FileInfo.java (2009-01-27-22:19) */ import java.io.File; import java.io.PrintWriter; diff --git a/Build/source/texk/tex4htk/java/xtpipes/InputObject.java b/Build/source/texk/tex4htk/java/xtpipes/InputObject.java index 3fc4edbd68c..43dde6d4d0e 100644 --- a/Build/source/texk/tex4htk/java/xtpipes/InputObject.java +++ b/Build/source/texk/tex4htk/java/xtpipes/InputObject.java @@ -1,6 +1,6 @@ package xtpipes; /* -InputObject.java (2008-01-26-00:38) +InputObject.java (2009-01-27-22:19) */ import java.io.PrintWriter; import java.net.URL; @@ -113,7 +113,7 @@ public InputObject( byte [] bytes, PrintWriter log ){ public void buildProfile( boolean trace ){ if( trace ){ log.println( - "xtpipes (2008-01-26-00:38)" + "xtpipes (2009-01-27-22:19)" + "\n java.version: " + System.getProperty("java.version") + "\n java.class.path: " + System.getProperty("java.class.path") + "\n os.name: " + System.getProperty("os.name") diff --git a/Build/source/texk/tex4htk/java/xtpipes/Xtpipes.java b/Build/source/texk/tex4htk/java/xtpipes/Xtpipes.java index 3efc2344c34..e1a037b5405 100644 --- a/Build/source/texk/tex4htk/java/xtpipes/Xtpipes.java +++ b/Build/source/texk/tex4htk/java/xtpipes/Xtpipes.java @@ -1,6 +1,6 @@ package xtpipes; /* -Xtpipes.java (2008-01-26-00:38) +Xtpipes.java (2009-01-27-22:19) */ // import xtpipes.util.InputObject; // import xtpipes.util.FileInfo; @@ -20,25 +20,6 @@ import java.net.URL; import java.lang.reflect.Constructor; import java.util.ArrayList; -class XtpipesPrintWriter extends PrintWriter { - public XtpipesPrintWriter() { - super(System.out, true); - } - public XtpipesPrintWriter (PrintStream ps, boolean b){ - super(ps, b); - } - public XtpipesPrintWriter (OutputStream ps, boolean b){ - super(ps, b); - } - public XtpipesPrintWriter (FileWriter fw){ - super(fw); - } - public void print(String str) { - super.print( XtpipesUni.toUni(str, "") ); - } - public void println(String str) { - super.println( XtpipesUni.toUni(str, "") ); -} } public class Xtpipes { private static HashMap <String,Object> map; @@ -116,6 +97,60 @@ trace = false; outPrintWriter.flush(); } + public static void xtpipes(String [] args, + OutputStreamWriter out, + PrintWriter log) + throws Exception { + map = new HashMap <String,Object> (); +needScript = true; +returnDom = false; +result = null; +inFile = null; +inData = null; +exceptionErrs = false; +messages = false; +outFileName = null; +outPrintWriter = null; +scriptFile = null; +i_scriptDir = null; +scriptMap = null; +saxReaderStack = new Stack <XMLReader> (); +rootName = null; +trace = false; + + outPrintWriter = new XtpipesPrintWriter( out ); + logWriter = (log==null)? (new PrintWriter( System.err )) : log; + mainMethod(args); + outPrintWriter.flush(); +} + + public static void xtpipes(String [] args, + XtpipesPrintWriter out, + PrintWriter log) + throws Exception { + map = new HashMap <String,Object> (); +needScript = true; +returnDom = false; +result = null; +inFile = null; +inData = null; +exceptionErrs = false; +messages = false; +outFileName = null; +outPrintWriter = null; +scriptFile = null; +i_scriptDir = null; +scriptMap = null; +saxReaderStack = new Stack <XMLReader> (); +rootName = null; +trace = false; + + outPrintWriter = out; + logWriter = (log==null)? (new PrintWriter( System.err )) : log; + mainMethod(args); + outPrintWriter.flush(); +} + public static Document getDOM(String args[]) throws Exception { map = new HashMap <String,Object> (); @@ -247,7 +282,7 @@ public static Document getDOM(String s, String args[], PrintWriter log) private static void mainMethod(String args[]) throws Exception { try{ String xtpipes_call = - " xtpipes (2008-01-26-00:38)" + " xtpipes (2009-01-27-22:19)" + "\n Command line options: " + "\n java xtpipes [-trace] [-help] [-m] [-E] [-s script_file]" + " [-S script_map]" @@ -267,7 +302,7 @@ else if( args[n].charAt(0)!='-' ){ inFile = args[n]; } else if( args[n].equals("-m") ){ messages = true; logWriter.println( - "xtpipes (2008-01-26-00:38)" + "xtpipes (2009-01-27-22:19)" + "\n java.version: " + System.getProperty("java.version") + "\n java.class.path: " + System.getProperty("java.class.path") + "\n os.name: " + System.getProperty("os.name") @@ -1293,8 +1328,9 @@ if( Xtpipes.ml2xml != null ){ } catch ( java.lang.reflect.InvocationTargetException e ){ instructionErr( node, errMsg + ": " + e.getCause(), 23 ); } catch ( Exception e ){ -// e.printStackTrace(); - instructionErr( node, errMsg + e.toString(), 29 ); + Xtpipes.logWriter.flush(); + e.printStackTrace(); + instructionErr( node, errMsg + ": " + e.toString(), 29 ); } } else { diff --git a/Build/source/texk/tex4htk/java/xtpipes/XtpipesPrintWriter.java b/Build/source/texk/tex4htk/java/xtpipes/XtpipesPrintWriter.java new file mode 100755 index 00000000000..28eff6c12b3 --- /dev/null +++ b/Build/source/texk/tex4htk/java/xtpipes/XtpipesPrintWriter.java @@ -0,0 +1,28 @@ +package xtpipes; +/* +XtpipesPrintWriter.java (2009-01-27-22:19) +*/ +import java.io.*; +public class XtpipesPrintWriter extends PrintWriter { + public XtpipesPrintWriter() { + super(System.out, true); + } + public XtpipesPrintWriter (PrintStream ps, boolean b){ + super(ps, b); + } + public XtpipesPrintWriter (OutputStream ps, boolean b){ + super(ps, b); + } + public XtpipesPrintWriter (FileWriter fw){ + super(fw); + } + public XtpipesPrintWriter (Writer wr){ + super(wr); + } + public void print(String str) { + super.print( XtpipesUni.toUni(str, "") ); + } + public void println(String str) { + super.println( XtpipesUni.toUni(str, "") ); +} } + diff --git a/Build/source/texk/tex4htk/java/xtpipes/XtpipesUni.java b/Build/source/texk/tex4htk/java/xtpipes/XtpipesUni.java index 7050d590d17..c11bbf9255f 100644 --- a/Build/source/texk/tex4htk/java/xtpipes/XtpipesUni.java +++ b/Build/source/texk/tex4htk/java/xtpipes/XtpipesUni.java @@ -1,4 +1,4 @@ -// 2008-01-26-00:38 +// 2009-01-27-22:19 package xtpipes; public class XtpipesUni{ private static int D800 = Integer.parseInt("D800", 16); diff --git a/Build/source/texk/tex4htk/java/xtpipes/util/ScriptsManager.java b/Build/source/texk/tex4htk/java/xtpipes/util/ScriptsManager.java index 2d2c06a715f..dff6f3184e0 100644 --- a/Build/source/texk/tex4htk/java/xtpipes/util/ScriptsManager.java +++ b/Build/source/texk/tex4htk/java/xtpipes/util/ScriptsManager.java @@ -1,16 +1,14 @@ -// 2008-01-26-00:38 +// 2009-01-27-22:19 package xtpipes.util; -import java.util.ArrayList; -import java.util.HashSet; -import xtpipes.XtpipesUni; - - import org.xml.sax.helpers.DefaultHandler; import org.xml.sax.*; import java.io.*; import java.lang.reflect.*; import java.util.HashMap; import java.util.Stack; +import java.util.ArrayList; +import java.util.HashSet; +import xtpipes.XtpipesUni; public class ScriptsManager extends DefaultHandler { boolean inBody = false; @@ -25,7 +23,8 @@ Stack<Integer> nsStack = new Stack<Integer>(); String code="", match = null; Stack<Object[]> stack = new Stack<Object[]>(); public ScriptsManager( PrintWriter out, - HashMap<String,Object> scripts, Method method, + HashMap<String,Object> scripts, + Method method, PrintWriter log, boolean trace ){ this.out = out; this.log = (log==null)? new PrintWriter( System.err ) : log; @@ -128,7 +127,8 @@ for(int i=nsName.size(); i>top; ){ nsValue.remove(i); } - int m = s.indexOf('>'); + if( !s.equals("") ){ + int m = s.indexOf('>'); char [] attrs = s.substring(0,m).toCharArray(); int result = qName.length()+1, mark = result, @@ -137,7 +137,6 @@ int result = qName.length()+1, ; char delimiter = ' '; String name=""; - for(int i=result; i<m; i++ ){ attrs[result++] = attrs[i]; switch( control ){ @@ -147,7 +146,7 @@ for(int i=result; i<m; i++ ){ control = 13 ; } - break; } + break; } case 13 : { if( (attrs[i] == '"') || (attrs[i] == '\'') ){ delimiter = attrs[i]; @@ -155,7 +154,7 @@ for(int i=result; i<m; i++ ){ ; from = result; } - break; } + break; } case 14 : { if( attrs[i] == delimiter ){ if( name.startsWith("xmlns") @@ -177,9 +176,11 @@ for(int k=nsName.size(); k>0; ){ } break; } } } -s = (new String(attrs,0,result)) + s.substring(m); +s = (new String(attrs,0, Math.min(result,attrs.length))) + + s.substring(m); - add( s ); + add( s ); + } } else { int top = ((Integer) nsStack.pop()) . intValue(); for(int i=nsName.size(); i>top; ){ i--; @@ -189,7 +190,7 @@ for(int i=nsName.size(); i>top; ){ } } - void add(String s){ + protected void add(String s){ if( savemode ){ code+=s; } else { out.print(s); } } } diff --git a/Build/source/texk/tex4htk/java/xtpipes/util/ScriptsManagerLH.java b/Build/source/texk/tex4htk/java/xtpipes/util/ScriptsManagerLH.java index b5fe3526208..17726d441c3 100644 --- a/Build/source/texk/tex4htk/java/xtpipes/util/ScriptsManagerLH.java +++ b/Build/source/texk/tex4htk/java/xtpipes/util/ScriptsManagerLH.java @@ -1,4 +1,4 @@ -// 2008-01-26-00:38 +// 2009-01-27-22:19 package xtpipes.util; import org.xml.sax.ext.LexicalHandler; // import org.xml.sax.ContentHandler; |