diff options
author | Karl Berry <karl@freefriends.org> | 2009-04-20 23:02:43 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2009-04-20 23:02:43 +0000 |
commit | 3ea86bef2e63ca77c8fbfe4e3b4617804de11855 (patch) | |
tree | 1e0e750a74f9564e0c70869bcb018ee010518e50 /Build/source/texk | |
parent | ee53eac199e12fb91859fd18a43dd506ff75e3a9 (diff) |
tex4ht-1.0.2009_04_18_1145
git-svn-id: svn://tug.org/texlive/trunk@12767 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk')
-rwxr-xr-x | Build/source/texk/tex4htk/java/DbUtilities.java | 152 | ||||
-rw-r--r-- | Build/source/texk/tex4htk/java/OoFilter.java | 249 | ||||
-rw-r--r-- | Build/source/texk/tex4htk/java/OoUtilities.java | 113 | ||||
-rw-r--r-- | Build/source/texk/tex4htk/java/OomFilter.java | 4 | ||||
-rw-r--r-- | Build/source/texk/tex4htk/java/xtpipes.java | 2 | ||||
-rw-r--r-- | Build/source/texk/tex4htk/java/xtpipes/FileInfo.java | 2 | ||||
-rw-r--r-- | Build/source/texk/tex4htk/java/xtpipes/InputObject.java | 4 | ||||
-rw-r--r-- | Build/source/texk/tex4htk/java/xtpipes/Xtpipes.java | 84 | ||||
-rwxr-xr-x | Build/source/texk/tex4htk/java/xtpipes/XtpipesPrintWriter.java | 28 | ||||
-rw-r--r-- | Build/source/texk/tex4htk/java/xtpipes/XtpipesUni.java | 2 | ||||
-rw-r--r-- | Build/source/texk/tex4htk/java/xtpipes/util/ScriptsManager.java | 29 | ||||
-rw-r--r-- | Build/source/texk/tex4htk/java/xtpipes/util/ScriptsManagerLH.java | 2 | ||||
-rw-r--r-- | Build/source/texk/tex4htk/t4ht.c | 22 | ||||
-rw-r--r-- | Build/source/texk/tex4htk/tex4ht.c | 62 |
14 files changed, 607 insertions, 148 deletions
diff --git a/Build/source/texk/tex4htk/java/DbUtilities.java b/Build/source/texk/tex4htk/java/DbUtilities.java new file mode 100755 index 00000000000..887d22b16be --- /dev/null +++ b/Build/source/texk/tex4htk/java/DbUtilities.java @@ -0,0 +1,152 @@ +package tex4ht; +/**********************************************************/ +/* DbUtilities.java 2008-11-14-02:41 */ +/* Copyright (C) 2008 Eitan M. Gurari */ +/* */ +/* This work may be distributed and/or modified under the */ +/* conditions of the LaTeX Project Public License, either */ +/* version 1.3 of this license or (at your option) any */ +/* later version. The latest version of this license is */ +/* in */ +/* http://www.latex-project.org/lppl.txt */ +/* and version 1.3 or later is part of all distributions */ +/* of LaTeX version 2003/12/01 or later. */ +/* */ +/* This work has the LPPL maintenance status "maintained".*/ +/* */ +/* This Current Maintainer of this work */ +/* is Eitan M. Gurari. */ +/* */ +/* gurari@cse.ohio-state.edu */ +/* http://www.cse.ohio-state.edu/~gurari */ +/**********************************************************/ + + +import org.w3c.dom.*; +public class DbUtilities { + public static void cline(Node dom) { + Node row, entry, para, nextrow; + Node node = dom.getFirstChild(); + if( node != null ){ + row = node.getLastChild(); +while( (row != null) + && ( (entry = row.getLastChild()) != null) + && ( (para = entry.getFirstChild()) != null) + && ( para.getNextSibling() == null) + && ( para.getFirstChild() == null) +){ + node.removeChild(row); + row = node.getLastChild(); +} + + row = node.getFirstChild(); +while( row != null ){ + if( (row.getNodeType() == Node.ELEMENT_NODE) + && ((Element) row).getAttribute("rowsep").equals("") + && !((Element) row).getAttribute("role" ).equals("cline") + && ((nextrow = row.getNextSibling()) != null) + && (nextrow.getNodeType() == Node.ELEMENT_NODE) + && ((Element) nextrow).getAttribute("role" ).equals("cline") + ){ + boolean compatible = true; +Node entry1 = row.getFirstChild(); +Node entry2 = nextrow.getFirstChild(); +while( true ){ + if( (entry1 == null) || (entry2 == null) ){ break; } + int range; + try{ + range = + Integer.parseInt( ((Element) entry1).getAttribute("nameend") ) + - + Integer.parseInt( ((Element) entry1).getAttribute("namest") ) + + + 1; + } catch( Exception e){ range = 1;} + if( range > 1 ){ + String rowsep = ((Element) entry2).getAttribute("rowsep"); + while( --range > 0 ){ + entry2 = entry2.getNextSibling(); + if( entry2 == null ){ + compatible = false; + break; + } + String value = ((Element) entry2).getAttribute("rowsep"); + if( !value.equals( rowsep ) ){ + compatible = false; + break; + } + } + } + if( !compatible ){ break; } + entry1 = entry1.getNextSibling(); + entry2 = entry2.getNextSibling(); +} + + if( compatible ){ + entry1 = row.getFirstChild(); +entry2 = nextrow.getFirstChild(); +while( true ){ + if( (entry1 == null) || (entry2 == null) ){ break; } + int range; + try{ + range = + Integer.parseInt( ((Element) entry1).getAttribute("nameend") ) + - + Integer.parseInt( ((Element) entry1).getAttribute("namest") ) + + + 1; + } catch( Exception e){ range = 1;} + ((Element) entry1).setAttribute( + "rowsep", + ((Element) entry2).getAttribute("rowsep") ); + while( --range > 0 ){ + entry2 = entry2.getNextSibling(); + } + entry1 = entry1.getNextSibling(); + entry2 = entry2.getNextSibling(); +} + + node.removeChild(nextrow); + } + } + row = row.getNextSibling(); +} + + } +} + + public static void para(Node dom) { + Node pNode = dom.getFirstChild(); + if( pNode.hasChildNodes() ){ + Node child = pNode.getFirstChild(); + if( child != null ){ + if( (child.getNodeType() == Node.TEXT_NODE) + && + ((Text) child).getWholeText().trim().equals("") + ){ + pNode.removeChild( child ); + } } } + if( pNode.hasChildNodes() ){ + Node child = pNode.getLastChild(); + if( child != null ){ + if( (child.getNodeType() == Node.TEXT_NODE) + && + ((Text) child).getWholeText().trim().equals("") + ){ + pNode.removeChild( child ); + } } } + if( pNode.hasChildNodes() ){ + Node child = pNode.getFirstChild(); + if( (child != null) + && (child.getNextSibling() == null) + && (child.getNodeType() == Node.TEXT_NODE) + ){ + String txt = ((Text) child).getWholeText(); + String trm = txt.trim(); + if( !trm.equals(txt) ){ + ((Text)child).replaceWholeText(trm); + } } } +} + +} + diff --git a/Build/source/texk/tex4htk/java/OoFilter.java b/Build/source/texk/tex4htk/java/OoFilter.java index 976518eaff4..a4d4a0f01c6 100644 --- a/Build/source/texk/tex4htk/java/OoFilter.java +++ b/Build/source/texk/tex4htk/java/OoFilter.java @@ -1,7 +1,7 @@ package tex4ht; /**********************************************************/ -/* OoFilterImpl.java 2008-02-20-10:22 */ -/* Copyright (C) 2006--2008 Eitan M. Gurari */ +/* OoFilterImpl.java 2009-03-11-03:09 */ +/* Copyright (C) 2006--2009 Eitan M. Gurari */ /* */ /* This work may be distributed and/or modified under the */ /* conditions of the LaTeX Project Public License, either */ @@ -21,10 +21,12 @@ package tex4ht; /* http://www.cse.ohio-state.edu/~gurari */ /**********************************************************/ - +import java.util.*; import org.xml.sax.helpers.*; import org.xml.sax.*; import java.io.PrintWriter; +import java.io.BufferedReader; +import java.io.FileReader; public class OoFilter extends XMLFilterImpl { PrintWriter out = null; @@ -36,25 +38,232 @@ public class OoFilter extends XMLFilterImpl { String qName, Attributes attr) { if( qName.equals( "draw:frame" ) ){ String name = attr.getValue("draw:name"); - if( (name != null) - && (attr.getValue("svg:width") == null) - && (attr.getValue("svg:hieght") == null) - ){ - java.awt.Image image = new javax.swing.ImageIcon(name).getImage(); - int width = image.getWidth(null); - int height = image.getHeight(null); - if( (width>0) && (height>0) ){ - org.xml.sax.helpers.AttributesImpl attrs = - new org.xml.sax.helpers.AttributesImpl( attr ); - attrs.addAttribute(null, "svg:width", "svg:width", - "String", (width * 72 / 110) + "pt"); - attrs.addAttribute(null, "svg:width", "svg:height", - "String", (height * 72 / 110) + "pt"); - attr = attrs; - } } } +if( (name != null) + && (attr.getValue("svg:width") == null) + && (attr.getValue("svg:hieght") == null) +){ + java.awt.Image image = new javax.swing.ImageIcon(name).getImage(); + int width = image.getWidth(null); + int height = image.getHeight(null); + if( (width>0) && (height>0) ){ + org.xml.sax.helpers.AttributesImpl attrs = + new org.xml.sax.helpers.AttributesImpl( attr ); + attrs.addAttribute(null, "svg:width", "svg:width", + "String", (width * 72 / 110) + "pt"); + attrs.addAttribute(null, "svg:width", "svg:height", + "String", (height * 72 / 110) + "pt"); + attr = attrs; +} } + + } try{ super.startElement(ns, sName, qName, attr); } catch( Exception e ){ System.err.println( "--- OoFilter Error 1 --- " + e); -} } } + } } + public void processingInstruction(String target, String fileName) { + if( target.equals("tex4ht-lg") ){ + fileName = fileName.trim(); + if( fileName.replaceAll(" ","").startsWith("file=") ){ + HashMap <String,HashMap <String,String>> map + = new HashMap<String,HashMap <String,String>>(); +String [] font_css_base = {"" , "-", ""}; +String [] font_css_mag = {"x-x-", ""}; +int base_font_size = 10; +int second; + + int length = fileName.length(); +int loc = fileName.indexOf(fileName.charAt(length-1)); +fileName = fileName.substring(loc+1,length-1); +try{ + String s = ""; + FileReader fr = new FileReader( fileName ); + BufferedReader in = new BufferedReader( fr ); + try{ + String key = "", body = ""; + while( (s=in.readLine()) != null ){ + if( s.startsWith("htfcss: ") ){ + s = s.substring(8); + int idx = s.indexOf(' '); + if( idx == 0 ){ + body += s; + } else { + body = body.trim(); +if( body.startsWith( "@media " ) ){ + body = body.substring(7).trim(); + if( body.startsWith("print ") ){ + body = body.substring(6).trim(); + } else { key = ""; } +} +if( !key.equals("") ){ + String [] property = body.split(";"); + for( int i=0; i<property.length; i++ ){ + if( !property[i].trim().equals("") ){ + int indx = property[i].indexOf(":"); + if( indx != -1 ){ + String name = property[i].substring(0,indx).trim(); + String value = (property[i]+' ').substring(indx+1).trim(); + if( !name.equals("") && !value.equals("") ){ + if( map.containsKey(key) ){ + HashMap <String,String> entry = map.get(key); + entry.put(name,value); +} +else +{ + HashMap <String,String> entry = new HashMap <String,String>(); + entry.put(name,value); + map.put(key,entry); +} + +} } } } } + + if( idx == -1 ){ + key = s; body = ""; + } else { + key = s.substring(0,idx); + body = s.substring(idx); + } } } } + body = body.trim(); +if( body.startsWith( "@media " ) ){ + body = body.substring(7).trim(); + if( body.startsWith("print ") ){ + body = body.substring(6).trim(); + } else { key = ""; } +} +if( !key.equals("") ){ + String [] property = body.split(";"); + for( int i=0; i<property.length; i++ ){ + if( !property[i].trim().equals("") ){ + int indx = property[i].indexOf(":"); + if( indx != -1 ){ + String name = property[i].substring(0,indx).trim(); + String value = (property[i]+' ').substring(indx+1).trim(); + if( !name.equals("") && !value.equals("") ){ + if( map.containsKey(key) ){ + HashMap <String,String> entry = map.get(key); + entry.put(name,value); +} +else +{ + HashMap <String,String> entry = new HashMap <String,String>(); + entry.put(name,value); + map.put(key,entry); +} + +} } } } } + +} catch(java.lang.NumberFormatException e){ + System.err.println( "--- OoFilter Error 3 --- Improper record: " + s); +} + + in.close(); +fr = new FileReader( fileName ); +in = new BufferedReader( fr ); + + in.close(); +fr = new FileReader( fileName ); +in = new BufferedReader( fr ); + try{ + while( (s=in.readLine()) != null ){ + if( s.startsWith("Font_css_base: ") ){ + int idx = s.indexOf("Font_css_mag: "); + if( idx != -1 ){ + String [] pattern = s.substring(15,idx).trim().split("%s"); + if( pattern.length == 3 ){ font_css_base = pattern; } + pattern = (s+' ').substring(idx).trim().split("%s"); + if( pattern.length == 2 ){ font_css_mag = pattern; } + } } } +} catch(Exception e){ + System.err.println( "--- OoFilter Error 4 --- Improper record: " + s); +} + + in.close(); +fr = new FileReader( fileName ); +in = new BufferedReader( fr ); + try{ + while( (s=in.readLine()) != null ){ + if( s.startsWith("Font_Size:") ){ + base_font_size = Integer.parseInt( s.substring(10).trim() ); + } } +} catch(java.lang.NumberFormatException e){ + System.err.println( "--- OoFilter Error 5 --- Improper record: " + s); +} + + in.close(); +fr = new FileReader( fileName ); +in = new BufferedReader( fr ); + try{ + while( (s=in.readLine()) != null ){ + if( s.startsWith("Font(") ){ + String [] match = s.split("\""); + match[1] = match[1].trim(); + match[2] = match[3].trim(); + match[3] = match[5].trim(); + match[4] = match[7].trim(); + { + if( match[3].replaceAll("[0-9]","").equals("") ){ + second = (int) + ( Integer.parseInt( match[3] ) + * Long.parseLong( match[4] ) + / base_font_size + ); + while( second > 700 ){ second /= 10; } + } else { second = 100; } + if( (int) ( Double.parseDouble(match[2]) + / Long.parseLong(match[4]) + + 0.5 + ) + == base_font_size +){ + second = 100; +}; + +} + + HashMap <String,String> entry = map.get(match[1]); +if( (entry != null) || (second < 98) || (second > 102) ){ + String styleName = font_css_base[0] + match[1] + + font_css_base[1] + match[2] + + font_css_base[2]; + if( !match[4].equals("100") ){ + styleName += font_css_mag[0] + match[4] + font_css_mag[1]; + } + org.xml.sax.helpers.AttributesImpl attr = + new org.xml.sax.helpers.AttributesImpl(); +attr.addAttribute("", "style:name", "style:name", "String", styleName); +attr.addAttribute("", "style:family", "style:family", "String", "text"); + + super.startElement(null, "style:style", "style:style", attr); + attr = new org.xml.sax.helpers.AttributesImpl(); +if( entry != null ){ + Object [] name = entry.keySet().toArray(); + for(int i=0; i < name.length; i++){ + String value = entry.get(name[i]); + attr.addAttribute("", "fo:" + (String) name[i], + "fo:" + (String) name[i], + "String", value); +} } +if( (second < 98) || (second > 102) ){ + attr.addAttribute("", "fo:font-size", "fo:font-size", + "String", (second / 10.0) + "pt"); +} + + super.startElement(null, "style:text-properties", + "style:text-properties", attr); + super.endElement(null, "style:text-properties", + "style:text-properties"); + super.endElement(null, "style:style", "style:style"); +} + + } } +} catch(Exception e){ + System.err.println( "--- OoFilter Error 6 --- Improper record: " + s); +} + +} catch(Exception e){ + System.err.println( "--- OoFilter Error 2 --- " + e); +} + + } } } +} diff --git a/Build/source/texk/tex4htk/java/OoUtilities.java b/Build/source/texk/tex4htk/java/OoUtilities.java index 63fa8195ccb..db8dbd0012b 100644 --- a/Build/source/texk/tex4htk/java/OoUtilities.java +++ b/Build/source/texk/tex4htk/java/OoUtilities.java @@ -1,7 +1,7 @@ package tex4ht; /**********************************************************/ -/* OoUtilities.java 2008-02-20-10:22 */ -/* Copyright (C) 2006--2008 Eitan M. Gurari */ +/* OoUtilities.java 2009-03-11-03:09 */ +/* Copyright (C) 2006--2009 Eitan M. Gurari */ /* */ /* This work may be distributed and/or modified under the */ /* conditions of the LaTeX Project Public License, either */ @@ -132,24 +132,26 @@ if( remove ){ } public static void table(Node dom) { - Node mtr, mtd, d; + Node tblRow, tblCell, d; // int cols = 0; Node node = dom.getFirstChild(); - mtr = node.getLastChild(); -while( (mtr != null) - && (mtr.getNodeType() == Node.TEXT_NODE) - && mtr.getNodeValue().trim().equals("") ){ - node.removeChild(mtr); - mtr = node.getLastChild(); + tblRow = node.getLastChild(); +while( (tblRow != null) +// && (tblRow.getNodeType() == Node.TEXT_NODE) +// && tblRow.getNodeValue().trim().equals("") + && tblRow.getTextContent().trim().equals("") +){ + node.removeChild(tblRow); + tblRow = node.getLastChild(); } - if( (mtr != null) && (mtr.getPreviousSibling() != null) ){ + if( (tblRow != null) && (tblRow.getPreviousSibling() != null) ){ boolean bool = false; -if( mtr.getNodeName().equals("table:table-row") - && mtr.hasAttributes() +if( tblRow.getNodeName().equals("table:table-row") + && tblRow.hasAttributes() ){ - NamedNodeMap attributes = mtr.getAttributes(); + NamedNodeMap attributes = tblRow.getAttributes(); Node styleAttr = attributes.getNamedItem( "table:style-name" ); String style = (styleAttr==null)? null : styleAttr.getNodeValue(); @@ -162,60 +164,91 @@ if( mtr.getNodeName().equals("table:table-row") } } if( !bool ){ - mtd = mtr.getFirstChild(); -while( mtd != null){ - d = mtd.getNextSibling(); - if( justSpace(mtd) ){ mtr.removeChild(mtd); } - mtd = d; + tblCell = tblRow.getFirstChild(); +while( tblCell != null){ + d = tblCell.getNextSibling(); + if( justSpace(tblCell) ){ tblRow.removeChild(tblCell); } + tblCell = d; } - mtd = mtr.getFirstChild(); - if( (mtd != null) - && (mtd.getNextSibling() == null) - && justSpace(mtd) + tblCell = tblRow.getFirstChild(); + if( (tblCell != null) + && (tblCell.getNextSibling() == null) + && justSpace(tblCell) ){ - node.removeChild(mtr); + node.removeChild(tblRow); } } } int n = 0; -mtr = node.getFirstChild(); -while( mtr != null ){ +tblRow = node.getFirstChild(); +while( tblRow != null ){ if( - (mtr.getNodeType() == Node.ELEMENT_NODE) + (tblRow.getNodeType() == Node.ELEMENT_NODE) && - mtr.getNodeName().equals("table:table-row") + tblRow.getNodeName().equals("table:table-row") ){ int m = 0; -mtd = mtr.getFirstChild(); -while( mtd != null ){ +tblCell = tblRow.getFirstChild(); +while( tblCell != null ){ if( - (mtd.getNodeType() == Node.ELEMENT_NODE) + (tblCell.getNodeType() == Node.ELEMENT_NODE) && - mtd.getNodeName().equals("table:table-cell") + tblCell.getNodeName().equals("table:table-cell") ){ m++; + Node child = tblCell.getLastChild(); +while( child != null ){ + Node prevChild = child.getPreviousSibling(); + if( + (child.getNodeType() == Node.ELEMENT_NODE) + && + child.getNodeName().equals("text:p") + ){ + Node sibling = child.getPreviousSibling(); + while( (sibling != null) + && + (sibling.getNodeType() != Node.ELEMENT_NODE) + ){ + sibling = sibling.getPreviousSibling(); + } + if( sibling == null ){ + sibling = child.getNextSibling(); + while( (sibling != null) + && + (sibling.getNodeType() != Node.ELEMENT_NODE) + ){ + sibling = sibling.getNextSibling(); + } } + if( (sibling != null) + && child.getTextContent().trim().equals("") + ){ + tblCell.removeChild(child); + } } + child = prevChild; +} + } - mtd = mtd.getNextSibling(); + tblCell = tblCell.getNextSibling(); } if( m > n ){ n = m; } } - mtr = mtr.getNextSibling(); + tblRow = tblRow.getNextSibling(); } - mtr = node.getFirstChild(); -while( mtr != null ){ - d = mtr.getNextSibling(); + tblRow = node.getFirstChild(); +while( tblRow != null ){ + d = tblRow.getNextSibling(); if( - (mtr.getNodeType() == Node.ELEMENT_NODE) + (tblRow.getNodeType() == Node.ELEMENT_NODE) && - mtr.getNodeName().equals("table:table-column") + tblRow.getNodeName().equals("table:table-column") ){ n--; if( n < 0 ){ - mtr.getParentNode().removeChild(mtr); + tblRow.getParentNode().removeChild(tblRow); } } - mtr = d; + tblRow = d; } } diff --git a/Build/source/texk/tex4htk/java/OomFilter.java b/Build/source/texk/tex4htk/java/OomFilter.java index 4af1c72e61e..d6ab78100bc 100644 --- a/Build/source/texk/tex4htk/java/OomFilter.java +++ b/Build/source/texk/tex4htk/java/OomFilter.java @@ -1,7 +1,7 @@ package tex4ht; /**********************************************************/ -/* OomFilterImpl.java 2008-02-20-10:22 */ -/* Copyright (C) 2006--2008 Eitan M. Gurari */ +/* OomFilterImpl.java 2009-03-11-03:09 */ +/* Copyright (C) 2006--2009 Eitan M. Gurari */ /* */ /* This work may be distributed and/or modified under the */ /* conditions of the LaTeX Project Public License, either */ diff --git a/Build/source/texk/tex4htk/java/xtpipes.java b/Build/source/texk/tex4htk/java/xtpipes.java index 6b37e160027..28ef7887436 100644 --- a/Build/source/texk/tex4htk/java/xtpipes.java +++ b/Build/source/texk/tex4htk/java/xtpipes.java @@ -1,4 +1,4 @@ -// 2008-01-26-00:38 +// 2009-01-27-22:19 import xtpipes.*; public class xtpipes { public static void main(String [] args) throws Exception { 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; diff --git a/Build/source/texk/tex4htk/t4ht.c b/Build/source/texk/tex4htk/t4ht.c index 31b91e37582..f6fe13c00e6 100644 --- a/Build/source/texk/tex4htk/t4ht.c +++ b/Build/source/texk/tex4htk/t4ht.c @@ -1,7 +1,7 @@ /**********************************************************/ -/* t4ht.c 2008-02-25-18:56 */ -/* Copyright (C) 1998--2008 Eitan M. Gurari */ +/* t4ht.c 2009-01-31-07:34 */ +/* Copyright (C) 1998--2009 Eitan M. Gurari */ /* */ /* This work may be distributed and/or modified under the */ /* conditions of the LaTeX Project Public License, either */ @@ -1049,7 +1049,7 @@ static void err_i #undef SEP #endif { (IGNORED) fprintf(stderr,"--- error --- "); - (IGNORED) fprintf(stderr, warn_err_mssg[n]); + (IGNORED) fprintf(stderr, "%s", warn_err_mssg[n]); exit(EXIT_FAILURE); } @@ -1070,7 +1070,7 @@ static void err_arg #undef SEP #endif { (IGNORED) fprintf(stderr,"--- error --- "); - (IGNORED) fprintf(stderr, warn_err_mssg[n]); + (IGNORED) fprintf(stderr, "%s", warn_err_mssg[n]); exit(EXIT_FAILURE); } @@ -1458,15 +1458,15 @@ SetConsoleCtrlHandler((PHANDLER_ROUTINE)sigint_handler, TRUE); (IGNORED) printf("----------------------------\n"); #ifndef KPATHSEA #ifdef PLATFORM - (IGNORED) printf("t4ht.c (2008-02-25-18:56 %s)\n",PLATFORM); + (IGNORED) printf("t4ht.c (2009-01-31-07:34 %s)\n",PLATFORM); #else - (IGNORED) printf("t4ht.c (2008-02-25-18:56)\n"); + (IGNORED) printf("t4ht.c (2009-01-31-07:34)\n"); #endif #else #ifdef PLATFORM - (IGNORED) printf("t4ht.c (2008-02-25-18:56 %s kpathsea)\n",PLATFORM); + (IGNORED) printf("t4ht.c (2009-01-31-07:34 %s kpathsea)\n",PLATFORM); #else - (IGNORED) printf("t4ht.c (2008-02-25-18:56 kpathsea)\n"); + (IGNORED) printf("t4ht.c (2009-01-31-07:34 kpathsea)\n"); #endif #endif @@ -2804,7 +2804,7 @@ if( (second < 98) || (second > 102) ){ (IGNORED) fprintf(css_file, "font-size:%d%c;", second, '%'); } if( font_sty ) { - (IGNORED) fprintf(css_file, font_sty->body); + (IGNORED) fprintf(css_file, "%s", font_sty->body); } (IGNORED) fprintf(css_file, "}\n"); @@ -2823,7 +2823,7 @@ if( !eq_str(match[4],"100") ){ } (IGNORED) fprintf(css_file, "{"); if( font_sty ) { - (IGNORED) fprintf(css_file, font_sty->body); + (IGNORED) fprintf(css_file, "%s", font_sty->body); } (IGNORED) fprintf(css_file, "}}\n"); @@ -2846,7 +2846,7 @@ if( (second < 98) || (second > 102) ){ (IGNORED) fprintf(css_file, "font-size:%d%c;", second, '%'); } if( font_sty ) { - (IGNORED) fprintf(css_file, font_sty->body); + (IGNORED) fprintf(css_file, "%s", font_sty->body); } (IGNORED) fprintf(css_file, "}\n"); diff --git a/Build/source/texk/tex4htk/tex4ht.c b/Build/source/texk/tex4htk/tex4ht.c index 71af448e73b..48ccacb7ea5 100644 --- a/Build/source/texk/tex4htk/tex4ht.c +++ b/Build/source/texk/tex4htk/tex4ht.c @@ -1,7 +1,7 @@ /**********************************************************/ -/* tex4ht.c 2007-11-07-16:08 */ -/* Copyright (C) 1996--2007 Eitan M. Gurari */ +/* tex4ht.c 2009-01-31-07:33 */ +/* Copyright (C) 1996--2009 Eitan M. Gurari */ /* */ /* This work may be distributed and/or modified under the */ /* conditions of the LaTeX Project Public License, either */ @@ -1051,7 +1051,7 @@ static U_CHAR *warn_err_mssg[]={ " [-t<tfm-font-dir>]\n" " [-u10] base 10 for unicode characters\n" " [-utf8] utf-8 encoding for unicode characters\n" -" [-v<idv version>] replacement forthe given dvi version\n" +" [-v<idv version>] replacement for the given dvi version\n" " [-xs] ms-dos file names for automatically generated gifs\n" , @@ -1628,11 +1628,11 @@ if( span_on && in_span_ch ){ if( no_root_file ){ open_o_file(); } - (IGNORED) fprintf(cur_o_file, end_span[0]); + (IGNORED) fprintf(cur_o_file, "%s", end_span[0]); } } - (IGNORED) fprintf(cur_o_file, t_accent_fifth); + (IGNORED) fprintf(cur_o_file, "%s", t_accent_fifth); needs_end_accent = FALSE; needs_accented_sym--; @@ -1662,11 +1662,11 @@ if( span_on && in_span_ch ){ if( no_root_file ){ open_o_file(); } - (IGNORED) fprintf(cur_o_file, end_span[0]); + (IGNORED) fprintf(cur_o_file, "%s", end_span[0]); } } - (IGNORED) fprintf(cur_o_file, t_accent_fifth); + (IGNORED) fprintf(cur_o_file, "%s", t_accent_fifth); needs_end_accent = FALSE; needs_accented_sym--; @@ -1810,11 +1810,11 @@ if( span_on && in_span_ch ){ if( no_root_file ){ open_o_file(); } - (IGNORED) fprintf(cur_o_file, end_span[0]); + (IGNORED) fprintf(cur_o_file, "%s", end_span[0]); } } - (IGNORED) fprintf(cur_o_file, t_accent_fifth); + (IGNORED) fprintf(cur_o_file, "%s", t_accent_fifth); needs_end_accent = FALSE; needs_accented_sym--; @@ -2979,7 +2979,7 @@ if( ( name == new_font_name ) && (n == 19) && (ch=='.') ){ if( i != bound ){ (IGNORED) fprintf(stderr,"--- warning --- "); -(IGNORED) fprintf(stderr,warn_err_mssg[22] +(IGNORED) fprintf(stderr, warn_err_mssg[22] , new_font_name, i, bound); show_err_context(); diff = diff * 1000 + i - bound; } @@ -4573,11 +4573,11 @@ if( span_on && in_span_ch ){ if( no_root_file ){ open_o_file(); } - (IGNORED) fprintf(cur_o_file, end_span[0]); + (IGNORED) fprintf(cur_o_file, "%s", end_span[0]); } } - (IGNORED) fprintf(cur_o_file, t_accent_fifth); + (IGNORED) fprintf(cur_o_file, "%s", t_accent_fifth); needs_end_accent = FALSE; needs_accented_sym--; @@ -4597,7 +4597,7 @@ if( no_root_file ){ open_o_file(); } if( span_open[0] ) if( *span_open[0] ) - (IGNORED) fprintf(cur_o_file, span_open[0]); + (IGNORED) fprintf(cur_o_file, "%s", span_open[0]); if( span_name[0] ) if( *span_name[0] ) (IGNORED) fprintf(cur_o_file, span_name[0], font_tbl[cur_fnt].family_name); @@ -4609,7 +4609,7 @@ if( no_root_file ){ open_o_file(); } (IGNORED) fprintf(cur_o_file, span_mag[0], font_tbl[cur_fnt].mag); if( span_ch[0] ) if( *span_ch[0] ) - (IGNORED) fprintf(cur_o_file, span_ch[0]); + (IGNORED) fprintf(cur_o_file, "%s", span_ch[0]); } start_span = FALSE; } @@ -5335,7 +5335,7 @@ if( end_span[gif_flag] ) } if( a_accent_template && needs_accented_sym ){ - (IGNORED) fprintf(cur_o_file, a_accent_fifth); + (IGNORED) fprintf(cur_o_file, "%s", a_accent_fifth); } @@ -5395,11 +5395,11 @@ if( span_on && in_span_ch ){ if( no_root_file ){ open_o_file(); } - (IGNORED) fprintf(cur_o_file, end_span[0]); + (IGNORED) fprintf(cur_o_file, "%s", end_span[0]); } } - (IGNORED) fprintf(cur_o_file, t_accent_fifth); + (IGNORED) fprintf(cur_o_file, "%s", t_accent_fifth); needs_end_accent = FALSE; needs_accented_sym--; @@ -5657,7 +5657,7 @@ static void warn_i #undef SEP #endif { (IGNORED) fprintf(stderr,"--- warning --- "); - (IGNORED) fprintf(stderr,warn_err_mssg[n]); + (IGNORED) fprintf(stderr, "%s", warn_err_mssg[n]); show_err_context(); } @@ -5773,7 +5773,7 @@ static void err_i #undef SEP #endif { (IGNORED) fprintf(stderr,"--- error --- "); - (IGNORED) fprintf(stderr, warn_err_mssg[n]); + (IGNORED) fprintf(stderr, "%s", warn_err_mssg[n]); show_err_context(); exit(EXIT_FAILURE); } @@ -5931,15 +5931,15 @@ SetConsoleCtrlHandler((PHANDLER_ROUTINE)sigint_handler, TRUE); (IGNORED) printf("----------------------------\n"); #ifndef KPATHSEA #ifdef PLATFORM - (IGNORED) printf("tex4ht.c (2007-11-07-16:08 %s)\n",PLATFORM); + (IGNORED) printf("tex4ht.c (2009-01-31-07:33 %s)\n",PLATFORM); #else - (IGNORED) printf("tex4ht.c (2007-11-07-16:08)\n"); + (IGNORED) printf("tex4ht.c (2009-01-31-07:33)\n"); #endif #else #ifdef PLATFORM - (IGNORED) printf("tex4ht.c (2007-11-07-16:08 %s kpathsea)\n",PLATFORM); + (IGNORED) printf("tex4ht.c (2009-01-31-07:33 %s kpathsea)\n",PLATFORM); #else - (IGNORED) printf("tex4ht.c (2007-11-07-16:08 kpathsea)\n"); + (IGNORED) printf("tex4ht.c (2009-01-31-07:33 kpathsea)\n"); #endif #endif for(i=0; i<argc; i++){ @@ -6295,7 +6295,7 @@ if( (dvi_file = fopen(job_name, READ_BIN_FLAGS)) == NULL ) break; } } if( (dvi_file = fopen(job_name, READ_BIN_FLAGS)) == NULL ){ - warn_i(9); bad_in_file(job_name); + warn_i_str(1, job_name); bad_in_file(job_name); } } } @@ -8762,7 +8762,7 @@ else if ( in_span_ch ){ if( no_root_file ){ open_o_file(); } - (IGNORED) fprintf(cur_o_file, end_span[0]); + (IGNORED) fprintf(cur_o_file, "%s", end_span[0]); } } } @@ -8772,7 +8772,7 @@ if( in_accenting ){ long int width; if( i_accent_template ){ - (IGNORED) fprintf(cur_o_file, i_accent_second); } + (IGNORED) fprintf(cur_o_file, "%s", i_accent_second); } needs_end_accent = (needs_accent_sym == 2 * TRUE); if( needs_end_accent && t_accent_template ) { @@ -8825,7 +8825,7 @@ needs_accent_sym && (ch < 128) m_accent_fourth); } if( i_accent_template ){ - (IGNORED) fprintf(cur_o_file, i_accent_first); } + (IGNORED) fprintf(cur_o_file, "%s", i_accent_first); } in_accenting = TRUE; } } @@ -9149,11 +9149,11 @@ if( span_on && in_span_ch ){ if( no_root_file ){ open_o_file(); } - (IGNORED) fprintf(cur_o_file, end_span[0]); + (IGNORED) fprintf(cur_o_file, "%s", end_span[0]); } } - (IGNORED) fprintf(cur_o_file, t_accent_fifth); + (IGNORED) fprintf(cur_o_file, "%s", t_accent_fifth); needs_end_accent = FALSE; needs_accented_sym--; @@ -10397,7 +10397,7 @@ case 'D': { dim = pos_y_C * (max_pos_y - min_pos_y) + pos_y_D; } p++; if( dim_on ){ (IGNORED) fprintf(cur_o_file, p, dim); } - else { (IGNORED) fprintf(cur_o_file, p); } + else { (IGNORED) fprintf(cur_o_file, "%s", p); } while( * (p++) ); } } @@ -12232,7 +12232,7 @@ if( errCode > 0 ){ { int ch, i, mag; U_CHAR str[256]; - (IGNORED) fprintf(log_file, begin_char_gif); + (IGNORED) fprintf(log_file, "%s", begin_char_gif); dvi_flag = TRUE; for( cur_fnt = font_tbl_size; cur_fnt--; ){ |