Added some automated JUnit tests for TMW_RTF_TO_THDL_WYLIE.

This commit is contained in:
dchandler 2003-05-18 17:17:52 +00:00
parent e2a9720d9b
commit ec7fec695f
17 changed files with 1670 additions and 39 deletions

View file

@ -369,6 +369,12 @@
value="org/thdl/tib/text/tshegbar/LegalTshegBarTest.java"/>
</antcall>
<antcall target="our-internal-javac-task">
<param name="mybin" value="${junitbin}"/>
<param name="my.included.source.file"
value="org/thdl/tib/input/TMW_RTF_TO_THDL_WYLIETest.java"/>
</antcall>
<antcall target="create-timestamp-source-code">
<param name="mybin" value="${junitbin}"/>
</antcall>

View file

@ -44,6 +44,7 @@
<test name="org.thdl.tib.input.DuffPaneTest"/>
<test name="org.thdl.util.ThdlLazyExceptionTest"/>
<test name="org.thdl.util.TrieTest"/>
<test name="org.thdl.tib.input.TMW_RTF_TO_THDL_WYLIETest"/>
<test name="org.thdl.tib.text.tshegbar.UnicodeUtilsTest"/>
<test name="org.thdl.tib.text.tshegbar.LegalTshegBarTest"/>
<test name="org.thdl.tib.text.tshegbar.UnicodeGraphemeClusterTest"/>

View file

@ -30,7 +30,8 @@ import org.thdl.tib.text.*;
* parameters for usage information.
* @author David Chandler */
public class TMW_RTF_TO_THDL_WYLIE {
static final String rtfErrorMessage = "The Rich Text Format (RTF) file selected contains constructs that\nJskad cannot handle. If you got the RTF file from saving a Word\ndocument as RTF, try saving that same document as RTF in\nWord 2000 instead of Word XP or in Word 97 instead of\nWord 2000. Older versions of Word produce RTF that Jskad\ncan more easily deal with. OpenOffice and StarOffice may also\nproduce better-behaved RTF.";
static final String rtfErrorMessage
= "The Rich Text Format (RTF) file selected contains constructs that\nJskad cannot handle. If you got the RTF file from saving a Word\ndocument as RTF, try saving that same document as RTF in\nWord 2000 instead of Word XP or in Word 97 instead of\nWord 2000. Older versions of Word produce RTF that Jskad\ncan more easily deal with. OpenOffice and StarOffice may also\nproduce better-behaved RTF.";
static {
// No need for the TMW fonts.
@ -40,6 +41,12 @@ public class TMW_RTF_TO_THDL_WYLIE {
/**
* Runs the converter. */
public static void main(String[] args) {
System.exit(realMain(args, System.out));
}
/** Runs the converter without exiting the program.
* @return the exit code. */
public static int realMain(String[] args, PrintStream out) {
try {
boolean findSomeNonTMWMode = false;
boolean findAllNonTMWMode = false;
@ -53,30 +60,30 @@ public class TMW_RTF_TO_THDL_WYLIE {
= args[0].equals("--find-all-non-tmw"))
|| (findSomeNonTMWMode
= args[0].equals("--find-some-non-tmw"))))) {
System.out.println("TMW_RTF_TO_THDL_WYLIE [--find-all-non-tmw | --find-some-non-tmw] RTF_file |");
System.out.println("TMW_RTF_TO_THDL_WYLIE [--version | -v | --help | -h]");
System.out.println("");
System.out.println("Distributed under the terms of the THDL Open Community License Version 1.0.");
System.out.println("");
System.out.println("Usage:");
System.out.println(" -v | --version for version info");
System.out.println(" -h | --help for this message");
System.out.println(" --find-all-non-tmw to locate all characters in the input document that are");
System.out.println(" not in Tibetan Machine Web fonts, exit zero iff none found");
System.out.println(" --find-some-non-tmw to locate all distinct characters in the input document");
System.out.println(" not in Tibetan Machine Web fonts, exit zero iff none found");
System.out.println(" Otherwise, needs one argument, the name of the TibetanMachineWeb RTF file.");
System.out.println(" Writes the Wylie transliteration of that file to standard output after");
System.out.println(" dealing with the curly brace problem. Exit code is zero on success,");
System.out.println(" nonzero otherwise.");
System.out.println("");
System.out.println(" You may find it helpful to use `--find-some-non-tmw' mode before doing a");
System.out.println(" conversion so that you have confidence in the conversion's correctness.");
System.exit(77);
out.println("TMW_RTF_TO_THDL_WYLIE [--find-all-non-tmw | --find-some-non-tmw] RTF_file |");
out.println("TMW_RTF_TO_THDL_WYLIE [--version | -v | --help | -h]");
out.println("");
out.println("Distributed under the terms of the THDL Open Community License Version 1.0.");
out.println("");
out.println("Usage:");
out.println(" -v | --version for version info");
out.println(" -h | --help for this message");
out.println(" --find-all-non-tmw to locate all characters in the input document that are");
out.println(" not in Tibetan Machine Web fonts, exit zero iff none found");
out.println(" --find-some-non-tmw to locate all distinct characters in the input document");
out.println(" not in Tibetan Machine Web fonts, exit zero iff none found");
out.println(" Otherwise, needs one argument, the name of the TibetanMachineWeb RTF file.");
out.println(" Writes the Wylie transliteration of that file to standard output after");
out.println(" dealing with the curly brace problem. Exit code is zero on success,");
out.println(" nonzero otherwise.");
out.println("");
out.println(" You may find it helpful to use `--find-some-non-tmw' mode before doing a");
out.println(" conversion so that you have confidence in the conversion's correctness.");
return 77;
}
if (args[0].equals("--version") || args[0].equals("-v")) {
System.out.println("TMW_RTF_TO_THDL_WYLIE version 0.8");
System.exit(77);
out.println("TMW_RTF_TO_THDL_WYLIE version 0.8");
return 77;
}
String tmwRtfPath = args[args.length - 1];
@ -87,19 +94,19 @@ public class TMW_RTF_TO_THDL_WYLIE {
try {
dp.rtfEd.read(in, dp.getDocument(), 0);
} catch (Exception e) {
System.out.println("TMW_RTF_TO_THDL_WYLIE:\n"
out.println("TMW_RTF_TO_THDL_WYLIE:\n"
+ rtfErrorMessage);
System.exit(3);
return 3;
}
in.close();
}
if (findAllNonTMWMode) {
// 0, -1 is the entire document.
System.exit(((TibetanDocument)dp.getDocument()).findAllNonTMWCharacters(0, -1));
return ((TibetanDocument)dp.getDocument()).findAllNonTMWCharacters(0, -1, out);
} else if (findSomeNonTMWMode) {
// 0, -1 is the entire document.
System.exit(((TibetanDocument)dp.getDocument()).findSomeNonTMWCharacters(0, -1));
return ((TibetanDocument)dp.getDocument()).findSomeNonTMWCharacters(0, -1, out);
} else { // conversion mode
// Fix curly braces in the entire document:
((TibetanDocument)dp.getDocument()).replaceTahomaCurlyBracesAndBackslashes(0, -1);
@ -108,18 +115,18 @@ public class TMW_RTF_TO_THDL_WYLIE {
dp.toWylie(0, dp.getDocument().getLength());
// Write to standard output the result:
((TibetanDocument)dp.getDocument()).writeRTFOutputStream(System.out);
((TibetanDocument)dp.getDocument()).writeRTFOutputStream(out);
// Exit normally:
System.exit(0);
return 0;
}
} catch (ThdlLazyException e) {
System.out.println("TMW_RTF_TO_THDL_WYLIE has a BUG:");
e.getRealException().printStackTrace(System.out);
System.exit(1);
out.println("TMW_RTF_TO_THDL_WYLIE has a BUG:");
e.getRealException().printStackTrace(out);
return 7;
} catch (IOException e) {
e.printStackTrace();
System.exit(4);
e.printStackTrace(out);
return 4;
}
}
}

View file

@ -0,0 +1,150 @@
/*
The contents of this file are subject to the THDL Open Community License
Version 1.0 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License on the THDL web site
(http://www.thdl.org/).
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific terms governing rights and limitations under the
License.
The Initial Developer of this software is the Tibetan and Himalayan Digital
Library (THDL). Portions created by the THDL are Copyright 2003 THDL.
All Rights Reserved.
Contributor(s): ______________________________________.
*/
package org.thdl.tib.input;
import junit.framework.TestCase;
import java.io.File;
import java.io.PrintStream;
import java.io.FileOutputStream;
import java.io.FileNotFoundException;
import org.thdl.util.ThdlOptions;
import org.thdl.util.javaxdelta.Delta;
/**
* @author David Chandler
*
* Tests {@link org.thdl.tib.input.TMW_RTF_TO_THDL_WYLIE} at the unit level.
*/
public class TMW_RTF_TO_THDL_WYLIETest extends TestCase {
/**
* Plain vanilla constructor for TMW_RTF_TO_THDL_WYLIETest.
* @param arg0
*/
public TMW_RTF_TO_THDL_WYLIETest(String arg0) {
super(arg0);
}
protected void setUp() {
// We don't want to use options.txt:
ThdlOptions.forTestingOnlyInitializeWithoutDefaultOptionsFile();
// We do want debugging assertions:
ThdlOptions.setUserPreference("thdl.debug", true);
}
/** Invokes a text UI and runs all this class's tests. */
public static void main(String[] args) {
junit.textui.TestRunner.run(TMW_RTF_TO_THDL_WYLIETest.class);
}
private static void testActualAndExpected(String testName) {
// Now ensure that the expected result and the actual result
// coincide.
int rc;
String actualFile
= "bin" + File.separator
+ "for-junit" + File.separator
+ "TMW_RTF_TO_THDL_WYLIE" + testName + ".out";
String expectedFile
= "source" + File.separator
+ "org" + File.separator
+ "thdl" + File.separator
+ "tib" + File.separator
+ "input" + File.separator
+ "TMW_RTF_TO_THDL_WYLIE" + testName + ".expected";
assertTrue(new File(actualFile).exists());
assertTrue(new File(expectedFile).exists());
rc = Delta.areFilesDifferent(actualFile, expectedFile);
if (0 != rc) System.out.println("DLC NOW: rc is " + rc);
assertTrue(0 == rc);
}
/** Tests the --find-some-non-tmw mode of {@link
* org.thdl.tib.input.TMW_RTF_TO_THDL_WYLIE}. */
public void testFindSomeNonTMWMode() {
String[] args = new String[] {
"--find-some-non-tmw",
"source" + File.separator
+ "org" + File.separator
+ "thdl" + File.separator
+ "tib" + File.separator
+ "input" + File.separator
+ "TMW_RTF_TO_THDL_WYLIETest1.rtf"
};
boolean fileNotFound = false;
try {
int rc = TMW_RTF_TO_THDL_WYLIE.realMain(args, new PrintStream(new FileOutputStream("bin/for-junit/TMW_RTF_TO_THDL_WYLIETest1ResultFindSome.out")));
assertTrue(rc == 1);
} catch (FileNotFoundException e) {
fileNotFound = true;
}
assertTrue(!fileNotFound);
testActualAndExpected("Test1ResultFindSome");
}
/** Tests the --find-all-non-tmw mode of {@link
* org.thdl.tib.input.TMW_RTF_TO_THDL_WYLIE}. */
public void testFindAllNonTMWMode() {
String[] args = new String[] {
"--find-all-non-tmw",
"source" + File.separator
+ "org" + File.separator
+ "thdl" + File.separator
+ "tib" + File.separator
+ "input" + File.separator
+ "TMW_RTF_TO_THDL_WYLIETest1.rtf"
};
boolean fileNotFound = false;
try {
int rc = TMW_RTF_TO_THDL_WYLIE.realMain(args, new PrintStream(new FileOutputStream("bin/for-junit/TMW_RTF_TO_THDL_WYLIETest1ResultFindAll.out")));
assertTrue(rc == 1);
} catch (FileNotFoundException e) {
fileNotFound = true;
}
assertTrue(!fileNotFound);
testActualAndExpected("Test1ResultFindAll");
}
/** Tests the converter mode of {@link
* org.thdl.tib.input.TMW_RTF_TO_THDL_WYLIE}. */
public void testConverterMode() {
String[] args = new String[] {
"source" + File.separator
+ "org" + File.separator
+ "thdl" + File.separator
+ "tib" + File.separator
+ "input" + File.separator
+ "TMW_RTF_TO_THDL_WYLIETest1.rtf"
};
boolean fileNotFound = false;
try {
int rc = TMW_RTF_TO_THDL_WYLIE.realMain(args, new PrintStream(new FileOutputStream("bin/for-junit/TMW_RTF_TO_THDL_WYLIETest1ResultConversion.out")));
assertTrue(rc == 0);
} catch (FileNotFoundException e) {
fileNotFound = true;
}
assertTrue(!fileNotFound);
testActualAndExpected("Test1ResultConversion");
}
}

View file

@ -0,0 +1,83 @@
{\rtf1\ansi
{\fonttbl\f0\fnil Monospaced;\f1\fnil TibetanMachineWeb;\f2\fnil TibetanMachineWeb1;\f3\fnil Tahoma;\f4\fnil TibetanMachineWeb8;\f5\fnil TimesNewRoman;\f6\fnil TibetanMachineWeb7;\f7\fnil TibetanMachineWeb9;\f8\fnil TibetanMachineWeb4;\f9\fnil TibetanMachineWeb5;\f10\fnil TibetanMachineWeb6;\f11\fnil Times New Roman;}
{\stylesheet{\s1\li0\ri0\fi0\ql\sbasedon2\snext1 Body Text;}{\s2\f1\fs72\i0\b0\cf0 default;}}
\margl1440\margr1440\widowctrl
\s1\li0\ri0\fi0\f1\fs56\i0\b0\ul0\cf0 0\}+-\f2 <\f1 m-+\{0-*\{:-+\f2 ?\f1 m+-\f2 <\f1 m-\f2 W\f1 ;-1\}8m-\f2 Qt\f1 -+\f2 A\f1 $=k\f3\fs44\par
\ql\par
\f4 ()\f1 k \f5 \f1 k#$=-%,-9v;-\f2 >\f1 m-=-;-\f2 ]\f3\}\f1 +-.8m-1*\}-:m=-\f2 <\f1 m-\f2 W\f1 ;-\f2 R\f3\}\f1 ,-#2~-0\}:-0I\}+-.8m-+\{0-*\{:-Q\}#=-X,-#6\},-ao8m-+#8-\f2 %\f3\}\f1 ,-+\f2 ?\f1 m+-\f2 <\f1 m-\f2 W\f1 ;-1\}8m-\f2 Qt\f1 -+\f2 A\f1 $=-6\{=-\f2 A\f1 -0-0bo#=-=\}kk\par
\par
\li720 0\f2 !\f1 ;-.-07$-.\}8m-0W-,-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f0\fnil Monospaced;\f1\fnil TibetanMachineWeb;\f2\fnil Serif;\f3\fnil Tahoma;\f4\fnil TimesNewRoman;\f5\fnil Times New Roman;}
{\stylesheet{\s2\f1\fs72\i0\b0\cf0 default;}{\s1\li0\ri0\fi0\ql\sbasedon2\snext1 Body Text;}}
\margl1440\margr1440\widowctrl
\s1\li0\ri0\fi0\ql\f2\fs28\i0\b0\cf0 bod kyi deb ther dpyid kyi rgyal mo'i glu dbyangs/\f3\fs44\ul0\par
\par
\f2\fs28\ul0 @#/_\f4\fs44\ul0 \f2\fs28\ul0 /gangs can yul gyi sa la spyod pa'i mtho ris kyi rgyal blon gtso bor brjod pa'i deb ther rdzogs ldan gzhon nu'i dga' ston dpyid kyi rgyal mo'i glu dbyangs zhes bya ba bzhugs so//\par
\par
bskal pa bzang po'i blta na sdug pa'i grong khyer dbus na 'jigs bral snying stobs gser gyi gdan khri la//\par
grags snyan nor bu'i rna rgyan 'od gzi mngon par rab 'bar chos kun ma lus gzigs pa'i mig stong can//\par
mtha' gnyis bcud bral sder bcas bcom pa'i rgyal rnga stong brdungs stobs bcu mnga' ba mkhar nyal tshogs kyi dpal//\par
bla na mtho ba'i khyu mchog zas gtsang sras po 'chi med gtso bos 'jig rten gsum du dge legs mdzod//\par
\par
'chi ba'i dngos po rnam par 'joms pa'i gzhom med tshe yi g.yung drung rtag pa'i rdo rje gang //\par
longs su spyod la zad mi shes par 'dod pa 'jo ba'i 'byung gnas mchog gi gan mdzod kyi//\par
khyab bdag dbang por dus gsum rgyal ba yongs kyis legs bsngags tshe dang ye shes dpag tu med//\par
tshe dpal yongs 'du'i ljon pa dus su smin pa'i dngos grub 'bras bu bla na med pa stsol//\par
\par
tshar du dngar ba'i mkhyen pa'i ge sar gzhon nu'i lang tsho'i lcags kyu yis//\par
chos kun ri dwags mig can ma yi snying la bsnun pa'i rang dbang du//\par
'du 'bral zlos gar ri mo'i snang brnyan chos nyid me long gtsang ma'i ngos//\par
rjen par 'char ba'i byed po zur phud lnga pa mgrin pa'i rgyan du bzhugs//\par
\f3\fs44\ul0\par
\li720\f2\fs28\ul0 snang mdzod 'bum gyi dra bas 'khyud pa'i byu ru'i rdul brtsegs la//\par
brtan g.yo'i dngos kun dbang du byed pa'i yon tan yongs rdzogs pa'i//\par
zur mig nyag phran tsam gyis dge ba'i gzugs can 'dus ma byas//\par
'dar mdzad rig byed lha mos srid pa gsum la mnga' sgyur cig/\par
\par
yid 'ong bzhin ras zla gzhon 'khor lo gnyis skyes la//\par
'khrul ba ster yang 'phyang mo sel byed mgo skyes kyi//\par
bai DUr mthing kha'i lan bu rab 'phyang dbyangs can ma//\par
smra ba'i dbang phyug ngag gi rgyal po nyer grub mdzod//\par
\par
gangs can lha lam yangs pa'i khyon 'dir rgyal ba'i bstan pa bcu gnyis bdag po'i gur khang mchog/\par
mkhyen brtse nus pa'i nam mkha'i gru yis nye bar 'dren mdzad chos rgyal mes dbon rnam gsum dang //\par
rgyal ba kun dngos mtsho skyes rdo rje bstan pa'i rtsa lag thams cad mkhyen pa zhi ba 'tsho'i//\par
bka' drin gzugs can dbyig 'dzin lto 'dir shong 'gyur min na kun mkhyen srang las gang gis gzhal//\par
\par
li khri'i lcug phran mkhyen pa'i snang ba can//\par
'jam mgon blo<<[[JSKAD_TMW_TO_WYLIE_ERROR_NO_SUCH_WYLIE: Cannot convert DuffCode <duffcode font=TibetanMachineWeb8 charNum=101 character=e/> to THDL Extended Wylie. Please see the documentation for the TMW font and transcribe this yourself.]]>> yi lang tsho baza<<[[JSKAD_TMW_TO_WYLIE_ERROR_NO_SUCH_WYLIE: Cannot convert DuffCode <duffcode font=TibetanMachineWeb8 charNum=101 character=e/> to THDL Extended Wylie. Please see the documentation for the TMW font and transcribe this yourself.]]>>anga po'i tshon//\par
kha dog so sor bkra ba'i graga<<[[JSKAD_TMW_TO_WYLIE_ERROR_NO_SUCH_WYLIE: Cannot convert DuffCode <duffcode font=TibetanMachineWeb8 charNum=101 character=e/> to THDL Extended Wylie. Please see the documentation for the TMW font and transcribe this yourself.]]>>asa pa<<[[JSKAD_TMW_TO_WYLIE_ERROR_NO_SUCH_WYLIE: Cannot convert DuffCode <duffcode font=TibetanMachineWeb8 charNum=101 character=e/> to THDL Extended Wylie. Please see the documentation for the TMW font and transcribe this yourself.]]>>a'i rgyan//\par
phyogs bral rna lung 'god mkhas rtag tu rgyal//\f3\fs44\ul0\par
\par
\f2\fs28\ul0 dpal ldan chos kyi rang bzhin ngos yangs par//\par
gnas lnga'i bang mdzod 'byor par lhun grub pa'i//\par
mnga' sgyur bgrod byed bn+d+hu dziA wa ka/\par
rmad byung cod pan mchog tu rnam par bsngags//\par
\par
rgya hor lung dang rigs kyis mngon mtho zhing //\par
bka' khrims gser 'khor mchog dman gnya' gnon pa'i//\par
sa skya 'jam mgon dpal ldan rlangs kyi gdung //\par
chos ldan sa skyong rgyal por su mi dad//\par
\par
smra ba'i 'bab stegs mdud pa'i rgyar bcings kyang //\par
mthon po'i khri la dregs pas 'gying min pa'i//\par
legs bshad gtam gyi 'byung gnas blo ldan can//\par
gang du gnas kyang dang ba'i spro ba 'phel//\par
\par
ya rabs dam pa'i spyod tshul pad dkar tshal//\par
ches cher bdo ba snyigs ma'i bsil zer gyis//\par
zum pa'i dus 'dir deb ther gtam rgyud sogs//\par
brjod pa rang nyid ngal ba'i rgyu ru zad//\par
\par
khyad par bcu phrag rig pa'i chu gter che//\par
blo gros gzings kyis sgrol 'dod rig byed pa//\par
shes bya'i tshul la ma sbyangs bstan bcos dag/\par
rtsom par rings pa'i tshul la yid mi gtod//\par
\par
'on tang stobs kyis yangs pa'i nor 'dzin la//\par
'khor los sgyur ba'i bka' yi dri bzhon gyis//\par
deb ther rdzogs ldan gsar pa'i dga' ston mgron//\par
'bod byed ma la ya yi rgyud 'di spro//\par
\f3\fs44\ul0\par
\li0\fi720\f2\fs28\ul0 shis pa brjod pa'i dbyangs kyi nga ro tm+pu ra'i ltud las nye bar drangs te/\f4\fs44\ul0 \f2\fs28\ul0 bla na med pa'i ye shes kyi bdud rtsi zad mi shes pa'i 'byung gnas za ma tog dbang gi rgyal po rmad du byung ba'i thugs kyi gsang mdzod dpal be'u'i mdzes rgyan du spud pa'i bskal pa bzang po 'di'i 'dren mchog stobs bcu mnga' ba stong gi mi ltung 'phreng ba'i dbus nas chu shel dbang po'i dkyil 'khor nya gang ba lta bur mngon par 'phags shing /\f4\fs44\ul0 \f2\fs28\ul0 mda' yis bcings pa'i rlabs po che'i smon lam gyi mthu phul du byung ba'i bden stobs dri ma med pas pad dkar lta bur bsngags pa'i dbyangs kyi rgyal mo'i rnga bo che srid pa gsum gyi khor mo yug tu brdung ba'i rgyal ba bu ram shing pa 'di nyid kyi bstan pa rin po che ni lha dang bcas pa'i 'gro ba'i legs byas grangs med pa'i zong gis bsgrubs pa'i phan bde kun gyi rtsa lag ste/\par
!\f4\fs44\ul0 \f2\fs28\ul0 de yang 'byung zhing 'phel ba dang /\f4\fs44\ul0 \f2\fs28\ul0 yar ldan du rgyas pa'i byed po ni yangs pa'i nor 'dzin gyi khyon la mnga' sgyur ba'i rgyal po chen po zhig la rag las pas na/\f4\fs44\ul0 \f2\fs28\ul0 'o skol gyi ston pas kyang rigs dang /\f4\fs44\ul0 \f2\fs28\ul0 yul dang /\f4\fs44\ul0 \f2\fs28\ul0 dus dang /\f4\fs44\ul0 \f2\fs28\ul0 brgyud dang /\f4\fs44\ul0 \f2\fs28\ul0 bud med de gzigs pa lnga la gzigs nas/\f4\fs44\ul0 \f2\fs28\ul0 zas gtsang gi sras su bltams par mdzad pas/\f4\fs44\ul0 \f2\fs28\ul0 thog mar 'di nyid kyi gdung rabs cung zad brjod par bya ste/\f4\fs44\ul0 \f2\fs28\ul0 'phags pa'i yul gyi mi phal che ba 'chi med kyi gnas nas chad pas/\f4\fs44\ul0 \f2\fs28\ul0 gzhal du med pa'i tshe dang 'dod rgu la longs spyod cing mtha' yas pa'i yon tan du ma la dbang 'byor pa'i tshe/\f4\fs44\ul0 \f2\fs28\ul0 'bad rtsol gyi mthu la rag ma las pa'i bdud rtsi sa'i bcud dang /\f4\fs44\ul0 \f2\fs28\ul0 sa'i zhag\f4\fs44\ul0 \f2\fs28\ul0 myu gu'i tshal/\f4\fs44\ul0 \f2\fs28\ul0 ma rmos pa'i 'bras sa lu rnams la longs spyad pas/\f4\fs44\ul0 \f2\fs28\ul0 lha las chad pa'i yon tan phal cher las gzhan du gyur cing /\f4\fs44\ul0 \f2\fs28\ul0 ma rmos pa'i 'bras kyang rnam par g.yeng ba'i gzhan dbang du gyur pa zhig gi byed pa la brten/\f4\fs44\ul0 \f2\fs28\ul0 so nam gyi bya ba la brtsams pas/\f4\fs44\ul0 \f2\fs28\ul0 phan tshun du rtsod pa dang mtshang 'bru ba byung ba rnams la drang po'i thig gis gcod pa'i zhal lce bar/\f4\fs44\ul0 \f2\fs28\ul0 sgyun gyis bkur zhing 'dud pa las/\f4\fs44\ul0 \f2\fs28\ul0 mang pos bkur ba'i rgyal po zhes rgyal po la snga bar grags shing /\f4\fs44\ul0 \f2\fs28\ul0 de nas rim bzhin 'od mdzes/\f4\fs44\ul0 \f2\fs28\ul0 dge ba/\f4\fs44\ul0 \f2\fs28\ul0 dge mchog\f4\fs44\ul0 \f2\fs28\ul0 gso sbyong 'phags te sngon gyi rgyal po sde lngar brjod la/\f4\fs44\ul0 \f2\fs28\ul0 gso sbyong 'phags kyi spyi bor sha rmen zhig byung ba las nga las nu/\f4\fs44\ul0 \f2\fs28\ul0 de'i brla g.yas par sha rmen zhig byung ba las mdzes pa/\f4\fs44\ul0 \f2\fs28\ul0 de'i brla g.yon par sha rmen zhing byung ba las nye mdzes/\f4\fs44\ul0 \f2\fs28\ul0 de'i rkang pa g.yas par sha rmen zhig byung ba las mdzes ldan/\f4\fs44\ul0 \f2\fs28\ul0 de'i rkang pa g.yon par sha rmen zhig byung ba las nye mdzes ldan te/\f4\fs44\ul0 \f2\fs28\ul0 'di lnga la 'khor los sgyur ba'i rgyal po lngar grags shing /\f4\fs44\ul0 \f2\fs28\ul0 phyi ma bzhis ni gling bzhi nas gcig gi bar la dbang sgyur bas/\f4\fs44\ul0 \f2\fs28\ul0 gser dngul zangs lcags kyi 'khor los sgyur ba'i rgyal po yin no/\f4\fs44\ul0 \f2\fs28\ul0 /\par
\f4\fs44\ul0 \f2\fs28\ul0 rgyal po 'di dag nas rim par brgyud de zas gtsang yan chod du sa ya chig 'bum nyi khri chig stong lnga brgya bcu bzhi byung bar grags la/\f4\fs44\ul0 \f2\fs28\ul0 'jig rten gdags par/\f4\fs44\ul0 \f2\fs28\ul0 rgyal po 'bum phrag brgyad sum khri bzhi stong lnga brgya sum cu rtsa bzhi yod par bshad pa'i lugs gnyis ka snyigs dus kyi lo rgyus smra ba kun gyi gtsug rgyan/\f4\fs44\ul0 \f2\fs28\ul0 gzhon nu dpal gyis 'dren par mdzad pa las gsal bar ma gsungs pas/\f4\fs44\ul0 \f2\fs28\ul0 slad nas kyang lo rgyus la 'dris par 'dod pa'i blo ldan dag gis dpyad par bya'o/\f4\fs44\ul0 \f2\fs28\ul0 /\par
\f4\fs44\ul0 \f2\fs28\ul0 de yang ston pa 'di nyid kyi gdung la nyi ma'i gnyen dang bu ram shing pa shAky zhes brjod pa ni/\f4\fs44\ul0 \f2\fs28\ul0 yul gru 'dzin du rgyal po brgya tham pa byung ba'i mtha' ma rna ba can gyi bu gau ta ma dang b+ha ra d+h+wa dza gnyis las/\f4\fs44\ul0 \f2\fs28\ul0 sngon mas rab tu byung ste lo ma'i spyil po yid du 'ong ba'i bsam gtan gyi khang bur gnas pa'i tshe/\f4\fs44\ul0 \f2\fs28\ul0 g.yo can pad+ma'i rtsa lag dang bzang mo dga' mgur spyod pa'i dus las yol bas/\f4\fs44\ul0 \f2\fs28\ul0 bzang mo bsad pa'i ral gri khrag can lo ma'i spyil po'i nye 'dabs su bor ba'i rkyen gyis gau ta ma bsal shing la bskyon pa'i dus/\f4\fs44\ul0 \f2\fs28\ul0 drang srong mdog nag gi rdzu 'phrul gyis gru char gyi thigs pa dang /\f4\fs44\ul0 \f2\fs28\ul0 dri bzhon lus la reg pa'i rkyen gyis 'dod pa'i gnas rjes su dran pa'i yid kyi shing rtas drangs te/\f4\fs44\ul0 \f2\fs28\ul0 khams kyi dwangs ma gnyis lhan cig tu lhung ba las sgo nga gnyis su gyur pa nyi 'od kyis bskyangs shing khye'u gnyis bu ram gyi shing gseb tu zhugs pas ming de ltar du grags la/\f4\fs44\ul0 \f2\fs28\ul0 bu ram shing pa'i brgyud la rgyal po brgya byung ba'i mtha' ma 'phags skyes po/\f4\fs44\ul0 \f2\fs28\ul0 'phags skyes po la sras bzhi byung yang btsun mo 'das te slar stobs ldan gyi rgyal po gzhan zhig gi bu mo khab tu blangs par sras byung na rgyal srid du dbang bskur bar khas blangs pas dam bcas/\f4\fs44\ul0 \f2\fs28\ul0 sras sngon ma rnams spyugs pa rang rang gi sring mo dang bcas te chu bo skal ldan shing rta'i 'gram du ming sring lhan cig tu 'dus pa las shAkya'i brgyud ces grags pa yin no//\par
\f4\fs44\ul0 \f2\fs28\ul0 de yang kun mkhyen nyi ma'i gnyen 'di nyid 'khrungs lor mkhas grub rnams kyi bzhed tshul mang du mchis kyang don grub ces pa sa lug dbyar zla 'bring po'i chu stod kyi nya ba'i tshes bco lnga'i dus su/\f4\fs44\ul0 \f2\fs28\ul0 yum gso sbyong la gnas pa'i lhums su glang po che'i phrug gu thal dkar gyi rnam par gyur nas zhugs/\f4\fs44\ul0 \f2\fs28\ul0 zla ba bcu phal cher lon pa legs par sbyar ba lha'i skad du ru dra zhes pa bsil ldan pa rnams drag por brjod pa/\f4\fs44\ul0 \f2\fs28\ul0 rgya nag pa dbang thang dang bstun pa'i ming ging shing /\f4\fs44\ul0 \f2\fs28\ul0 bod yul du lcags pho spre'ur 'bod pa'i dpyid tha sa gas nya ba me tog can gyi zla ba/\f4\fs44\ul0 \f2\fs28\ul0 rgya nag pa si yol du brjod pa'i yar ngo'i tshes bdun gyi res gza' 'od zer bdun pa dang /\f4\fs44\ul0 \f2\fs28\ul0 las skar rgyal la babs pa na lum+bi ni'i nags su sku bltams/\f4\fs44\ul0 \f2\fs28\ul0 de nas lang tsho'i kun+d rnam par rgyas pa'i zil mngar gyi sgyu rtsal drug cu rtsa bzhi'i yal 'dab kyi yon tan kun la rang gir bgyis shing /\f4\fs44\ul0 \f2\fs28\ul0 pd+mo'i snyems pa thogs pa'i ri dwags mig can gyi don yongs su tshang ba'i grags 'dzin ma dang sa mtsho ma sogs btsun mor dbang bskur te lo nyi shu rtsa dgu'i bar du nyi 'og gyi rgyal phran gnyis 'thung gi spyi bor 'jigs pa med pa'i rgyal thabs kyi bya ba'i skad gsang mthon pos rang byan du 'gying bar dbang thob na'ang /\f4\fs44\ul0 \f2\fs28\ul0 mchog gi sprul sku'i mdzad pa ston pa'i ched du/\f4\fs44\ul0 \f2\fs28\ul0 dgung lo nyer dgu pa kun 'dzin zhes pa sa pho byi ba la rang byung gi sgo nas/\f4\fs44\ul0 \f2\fs28\ul0 rab byung gi dngos po yongs su rdzogs te/\f4\fs44\ul0 \f2\fs28\ul0 lo drug tu dka' ba spyad pas lang tsho phun sum tshogs pa las gzhan du gyur pa na/\f4\fs44\ul0 \f2\fs28\ul0 dga' mo dang dga' stobs mas ba stong gi 'o ma lan bcu drug gi bar du nying khur byas pa'i 'o thug sbrang rtsi dang sbyar ba'i kun tu bzang po'i mchod sprin gyis sku su war+Na'i mchod sdong nyi gzhon 'bum gyis 'khyud pa ltar gyur te rdo rje gdan du byang chub kyi shing drung na 'chi med bdag pos rtswa 'tshong gyi rnam par sprul te phul ba'i rtswa'i gdan la bzhugs nas/\f4\fs44\ul0 \f2\fs28\ul0 chu srin rgyal mtshan can sde dang bcas pa'i g.yul las rnam par rgyal ba'i ba dan nam mkha'i mtha' klas par bsgrengs te/\f4\fs44\ul0 \f2\fs28\ul0 dgung lo so lnga pa rgyal ba zhes pa shing rta'i sa gas nya ba'i bco lnga'i skya rengs shar ba na ye shes mchog gi bdud rtsi mngon du mdzad do/\f4\fs44\ul0 \f2\fs28\ul0 /mdo las/\f4\fs44\ul0 \f2\fs28\ul0 de'i nyin mo zla ba sgra gcan gyis bzung ba dang /\f4\fs44\ul0 \f2\fs28\ul0 sgra gcan 'dzin dang bdud rtsi zas kyi khye'u zhig kyang skyes par bshad pa'i gza' 'dzin gyi ri mo ni gza' gnas su gcig chu tshod so brgyad zla skar gyi skar gnas su bcu drug chu tshod stong pa sgra gcan gdong gi skar mar bcu drug chu tshod nyer dgu byung bas gza' 'dzin gyi ri mo ni tshad ma'i A dr+sha gtsang ma'i ngos su gsal bar shar ba yin no/\f4\fs44\ul0 \f2\fs28\ul0 /\par
\f4\fs44\ul0 \f2\fs28\ul0 de nas zhag zhe dgu'i bar du dam pa'i chos kyi bdud rtsi'i sgo brgya ma phye ba'i tshul bstan pas/\f4\fs44\ul0 \f2\fs28\ul0 'jig rten gyi byed po gser mngal can gyis skal pa mchog gi bzang po'i dpal dang ldan pa'i don du gsol ba la brten nas/\f4\fs44\ul0 \f2\fs28\ul0 mchog dman gyi gdul bya so so'i blo dang 'tsham par zab rgyas chos kyi sgo glegs rnam par bkral nas theg pa che chung gi rigs can gyi yol go/\f4\fs44\ul0 \f2\fs28\ul0 rang 'dod pa'i tshogs mtha' dag gcig tu 'jo ba'i ro zad mi shes pa mkha' khyab tu bro ba'i 'khor lo bskor te/\f4\fs44\ul0 \f2\fs28\ul0 mthar gyad kyi yul rtswa mchog gi grong du dgung lo gya gcig pa dpa' bo zhes pa lcags 'brug gi lor mi 'gyur ba'i bde ba chen po chos kyi sku'i mkha' klong du sna tshogs pa'i sprul sku'i zlos gar gyis rol pa'i chu 'dzin gzugs sku tha mi dad pa'i mdzad pa bstan to/\f4\fs44\ul0 \f2\fs28\ul0 /\par
\f4\fs44\ul0 \f2\fs28\ul0 de ltar bstan pa rin po che yul dbus 'gyur nas char dus kyi dal 'gro'i klung rang babs su 'gyur ba'i gshis lugs bzhin tha grur khyab pa las/\f4\fs44\ul0 \f2\fs28\ul0 'gro ba'i bla ma shAky seng ge gya gcig pa lcags 'brug lo nag nyar shriA d+hA n+ya ka Ta kar gsang ba kun gyi gan mdzod rnam par 'dzin pa'i mi'i dbang phyug zla ba bzang por sho lo ka stong phrag bcu gnyis kyi bdag nyid can gyi dpal dang po'i sangs rgyas dus kyi 'khor lo'i rgyud gsungs pa sham+b+ha lar spyan drangs nas ma la ya'i skyed tshal du sku gsungs thugs yongs su rdzogs pa'i dkyil 'khor gyi snang brnyan ye shes kyi gzi byin mngon par 'bar ba'i sgyu ma'i gar gyis rtsen pa'i 'dren byed kyi dga' ston gsar pa bskrun te/\f4\fs44\ul0 \f2\fs28\ul0 rdo rje theg pa'i bgo skal ka lA pa'i grong khyer gyi skye rgur 'gyed pa'i mu mtha' bral ba'i mdzad pa nas bzung 'jigs pa med pa'i gdong lnga'i khri la bgrod byed rtsibs stong 'khor lo'i ri mo mchog tu bkra ba'i chos rgyal rigs ldan sum cu rtsa gsum du byon pa mtha' dag gis phyi nang gzhan gsum sbyor ba'i gsang chen nA da'i sgra dbyangs kyi nor bu'i 'phyang 'phrul las ldan gyi rna bar spud par mdzad pa'i tha ma/\f4\fs44\ul0 \f2\fs28\ul0 drag po'i 'khor lo can gyis dgung lo dgu bcu rtsa brgyad par kla klo'i dpung tshogs mtha' dag ming gi lhag mar byas nas snga na med pas sa chen po'i khor yug kun tu khyab par mdzad do/\f4\fs44\ul0 \f2\fs28\ul0 /de yang rigs ldan drag po dgung lo lnga bcu'i steng du kla klo bcom par bzhed pa ltar na/\f4\fs44\ul0 \f2\fs28\ul0 kla klo'i gnas tshad stong dang brgyad brgyar bshad pa las lo grangs bzhi bcu rtsa bdun tsam mi 'grig pa'i skyon yod cing /\f4\fs44\ul0 \f2\fs28\ul0 de dag rags rtsis su 'chad na zhib rtsis ni 'byung ba'i skabs med pas gzur gnas kyi shes ldan rnams soms shig\f4\fs44\ul0 \f2\fs28\ul0 de ltar sham b+ha las mtshon te/\f4\fs44\ul0 \f2\fs28\ul0 o rgyan/\f4\fs44\ul0 \f2\fs28\ul0 bal yul/\f4\fs44\ul0 \f2\fs28\ul0 rgya hor sogs su bstan pa byung tshul ni mtha' yas kyang mang gis dogs pas ma spros so/\f4\fs44\ul0 \f2\fs28\ul0 /\par
\f5\fs24\ul0\par
\pard\ql\f2\fs28\ul0\par
\f1\fs72\par
}

View file

@ -0,0 +1,258 @@
non-TMW character newline in the font Tahoma at location 39
non-TMW character newline in the font Tahoma at location 40
non-TMW character ' ' in the font TimesNewRoman at location 45
non-TMW character '}' in the font Tahoma at location 66
non-TMW character '}' in the font Tahoma at location 88
non-TMW character '}' in the font Tahoma at location 139
non-TMW character '}' in the font Tahoma at location 215
non-TMW character '{' in the font Tahoma at location 219
non-TMW character '}' in the font Tahoma at location 243
non-TMW character '}' in the font Tahoma at location 339
non-TMW character '{' in the font Tahoma at location 365
non-TMW character '}' in the font Tahoma at location 387
non-TMW character '}' in the font Tahoma at location 397
non-TMW character '}' in the font Tahoma at location 599
non-TMW character '}' in the font Tahoma at location 802
non-TMW character '{' in the font Tahoma at location 824
non-TMW character '}' in the font Tahoma at location 931
non-TMW character '{' in the font Tahoma at location 997
non-TMW character newline in the font Tahoma at location 1038
non-TMW character '{' in the font Tahoma at location 1118
non-TMW character '{' in the font Tahoma at location 1211
non-TMW character '\' in the font Tahoma at location 1237
non-TMW character '{' in the font Tahoma at location 1284
non-TMW character '{' in the font Tahoma at location 1299
non-TMW character '{' in the font Tahoma at location 1317
non-TMW character '{' in the font Tahoma at location 1325
non-TMW character '}' in the font Tahoma at location 1437
non-TMW character '{' in the font Tahoma at location 1491
non-TMW character '{' in the font Tahoma at location 1529
non-TMW character '{' in the font Tahoma at location 1585
non-TMW character '{' in the font Tahoma at location 1616
non-TMW character '{' in the font Tahoma at location 1690
non-TMW character '{' in the font Tahoma at location 1730
non-TMW character '}' in the font Tahoma at location 1757
non-TMW character '}' in the font Tahoma at location 1821
non-TMW character newline in the font Tahoma at location 1853
non-TMW character newline in the font Tahoma at location 1854
non-TMW character '}' in the font Tahoma at location 1908
non-TMW character '\' in the font Tahoma at location 1932
non-TMW character '}' in the font Tahoma at location 1938
non-TMW character '{' in the font Tahoma at location 1942
non-TMW character '}' in the font Tahoma at location 2120
non-TMW character '{' in the font Tahoma at location 2153
non-TMW character '{' in the font Tahoma at location 2197
non-TMW character '}' in the font Tahoma at location 2245
non-TMW character '}' in the font Tahoma at location 2276
non-TMW character '}' in the font Tahoma at location 2302
non-TMW character '}' in the font Tahoma at location 2467
non-TMW character '}' in the font Tahoma at location 2470
non-TMW character '}' in the font Tahoma at location 2484
non-TMW character '{' in the font Tahoma at location 2497
non-TMW character '}' in the font Tahoma at location 2582
non-TMW character '\' in the font Tahoma at location 2620
non-TMW character '}' in the font Tahoma at location 2678
non-TMW character '}' in the font Tahoma at location 2683
non-TMW character '{' in the font Tahoma at location 2694
non-TMW character '}' in the font Tahoma at location 2715
non-TMW character newline in the font Tahoma at location 2719
non-TMW character ' ' in the font TimesNewRoman at location 2776
non-TMW character '{' in the font Tahoma at location 2933
non-TMW character '}' in the font Tahoma at location 2942
non-TMW character '}' in the font Tahoma at location 2957
non-TMW character '{' in the font Tahoma at location 2972
non-TMW character ' ' in the font TimesNewRoman at location 3044
non-TMW character ' ' in the font TimesNewRoman at location 3045
non-TMW character '}' in the font Tahoma at location 3077
non-TMW character '}' in the font Tahoma at location 3111
non-TMW character '}' in the font Tahoma at location 3272
non-TMW character '{' in the font Tahoma at location 3336
non-TMW character ' ' in the font TimesNewRoman at location 3340
non-TMW character ' ' in the font TimesNewRoman at location 3341
non-TMW character ' ' in the font TimesNewRoman at location 3342
non-TMW character ' ' in the font TimesNewRoman at location 3369
non-TMW character '{' in the font Tahoma at location 3387
non-TMW character '}' in the font Tahoma at location 3417
non-TMW character '\' in the font Tahoma at location 3426
non-TMW character ' ' in the font TimesNewRoman at location 3464
non-TMW character '}' in the font Tahoma at location 3469
non-TMW character '}' in the font Tahoma at location 3476
non-TMW character ' ' in the font TimesNewRoman at location 3494
non-TMW character ' ' in the font TimesNewRoman at location 3503
non-TMW character ' ' in the font TimesNewRoman at location 3512
non-TMW character ' ' in the font TimesNewRoman at location 3522
non-TMW character ' ' in the font TimesNewRoman at location 3555
non-TMW character ' ' in the font TimesNewRoman at location 3587
non-TMW character '{' in the font Tahoma at location 3633
non-TMW character ' ' in the font TimesNewRoman at location 3635
non-TMW character ' ' in the font TimesNewRoman at location 3687
non-TMW character '}' in the font Tahoma at location 3725
non-TMW character '}' in the font Tahoma at location 3763
non-TMW character ' ' in the font TimesNewRoman at location 3773
non-TMW character ' ' in the font TimesNewRoman at location 3824
non-TMW character ' ' in the font TimesNewRoman at location 3831
non-TMW character ' ' in the font TimesNewRoman at location 3843
non-TMW character ' ' in the font TimesNewRoman at location 3880
non-TMW character ' ' in the font TimesNewRoman at location 3926
non-TMW character '{' in the font Tahoma at location 3984
non-TMW character ' ' in the font TimesNewRoman at location 3996
non-TMW character ' ' in the font TimesNewRoman at location 4020
non-TMW character ' ' in the font TimesNewRoman at location 4096
non-TMW character '\' in the font Tahoma at location 4097
non-TMW character ' ' in the font TimesNewRoman at location 4124
non-TMW character ' ' in the font TimesNewRoman at location 4173
non-TMW character ' ' in the font TimesNewRoman at location 4198
non-TMW character ' ' in the font TimesNewRoman at location 4205
non-TMW character ' ' in the font TimesNewRoman at location 4214
non-TMW character '}' in the font Tahoma at location 4220
non-TMW character '}' in the font Tahoma at location 4232
non-TMW character '{' in the font Tahoma at location 4245
non-TMW character ' ' in the font TimesNewRoman at location 4257
non-TMW character '}' in the font Tahoma at location 4263
non-TMW character ' ' in the font TimesNewRoman at location 4308
non-TMW character ' ' in the font TimesNewRoman at location 4350
non-TMW character ' ' in the font TimesNewRoman at location 4394
non-TMW character ' ' in the font TimesNewRoman at location 4439
non-TMW character ' ' in the font TimesNewRoman at location 4491
non-TMW character '\' in the font Tahoma at location 4509
non-TMW character ' ' in the font TimesNewRoman at location 4535
non-TMW character '\' in the font Tahoma at location 4577
non-TMW character ' ' in the font TimesNewRoman at location 4584
non-TMW character '\' in the font Tahoma at location 4615
non-TMW character ' ' in the font TimesNewRoman at location 4636
non-TMW character ' ' in the font TimesNewRoman at location 4639
non-TMW character ' ' in the font TimesNewRoman at location 4640
non-TMW character ' ' in the font TimesNewRoman at location 4641
non-TMW character '}' in the font Tahoma at location 4714
non-TMW character ' ' in the font TimesNewRoman at location 4743
non-TMW character ' ' in the font TimesNewRoman at location 4761
non-TMW character '}' in the font Tahoma at location 4792
non-TMW character ' ' in the font TimesNewRoman at location 4878
non-TMW character '{' in the font Tahoma at location 4897
non-TMW character ' ' in the font TimesNewRoman at location 4930
non-TMW character '}' in the font Tahoma at location 4967
non-TMW character ' ' in the font TimesNewRoman at location 4990
non-TMW character ' ' in the font TimesNewRoman at location 4993
non-TMW character ' ' in the font TimesNewRoman at location 4994
non-TMW character ' ' in the font TimesNewRoman at location 4995
non-TMW character '}' in the font Tahoma at location 5003
non-TMW character ' ' in the font TimesNewRoman at location 5071
non-TMW character ' ' in the font TimesNewRoman at location 5154
non-TMW character '}' in the font Tahoma at location 5156
non-TMW character '{' in the font Tahoma at location 5173
non-TMW character ' ' in the font TimesNewRoman at location 5233
non-TMW character '}' in the font Tahoma at location 5271
non-TMW character ' ' in the font TimesNewRoman at location 5292
non-TMW character '{' in the font Tahoma at location 5356
non-TMW character '}' in the font Tahoma at location 5382
non-TMW character ' ' in the font TimesNewRoman at location 5393
non-TMW character '}' in the font Tahoma at location 5398
non-TMW character ' ' in the font TimesNewRoman at location 5444
non-TMW character '{' in the font Tahoma at location 5468
non-TMW character ' ' in the font TimesNewRoman at location 5523
non-TMW character '}' in the font Tahoma at location 5562
non-TMW character '{' in the font Tahoma at location 5601
non-TMW character ' ' in the font TimesNewRoman at location 5658
non-TMW character '{' in the font Tahoma at location 5709
non-TMW character ' ' in the font TimesNewRoman at location 5715
non-TMW character '{' in the font Tahoma at location 5722
non-TMW character '}' in the font Tahoma at location 5763
non-TMW character ' ' in the font TimesNewRoman at location 5857
non-TMW character '}' in the font Tahoma at location 5862
non-TMW character ' ' in the font TimesNewRoman at location 5989
non-TMW character ' ' in the font TimesNewRoman at location 5990
non-TMW character ' ' in the font TimesNewRoman at location 5991
non-TMW character '{' in the font Tahoma at location 6004
non-TMW character '}' in the font Tahoma at location 6115
non-TMW character ' ' in the font TimesNewRoman at location 6146
non-TMW character '}' in the font Tahoma at location 6156
non-TMW character ' ' in the font TimesNewRoman at location 6223
non-TMW character ' ' in the font TimesNewRoman at location 6307
non-TMW character ' ' in the font TimesNewRoman at location 6347
non-TMW character '{' in the font Tahoma at location 6367
non-TMW character ' ' in the font TimesNewRoman at location 6414
non-TMW character ' ' in the font TimesNewRoman at location 6488
non-TMW character ' ' in the font TimesNewRoman at location 6533
non-TMW character '\' in the font Tahoma at location 6576
non-TMW character ' ' in the font TimesNewRoman at location 6637
non-TMW character '}' in the font Tahoma at location 6640
non-TMW character '{' in the font Tahoma at location 6645
non-TMW character ' ' in the font TimesNewRoman at location 6881
non-TMW character '}' in the font Tahoma at location 6906
non-TMW character ' ' in the font TimesNewRoman at location 6920
non-TMW character '}' in the font Tahoma at location 6977
non-TMW character ' ' in the font TimesNewRoman at location 6982
non-TMW character ' ' in the font TimesNewRoman at location 7017
non-TMW character ' ' in the font TimesNewRoman at location 7079
non-TMW character '}' in the font Tahoma at location 7095
non-TMW character '}' in the font Tahoma at location 7105
non-TMW character '}' in the font Tahoma at location 7220
non-TMW character ' ' in the font TimesNewRoman at location 7356
non-TMW character '{' in the font Tahoma at location 7375
non-TMW character '{' in the font Tahoma at location 7434
non-TMW character ' ' in the font TimesNewRoman at location 7441
non-TMW character ' ' in the font TimesNewRoman at location 7547
non-TMW character ' ' in the font TimesNewRoman at location 7556
non-TMW character ' ' in the font TimesNewRoman at location 7594
non-TMW character '{' in the font Tahoma at location 7624
non-TMW character '{' in the font Tahoma at location 7636
non-TMW character '}' in the font Tahoma at location 7735
non-TMW character ' ' in the font TimesNewRoman at location 7858
non-TMW character ' ' in the font TimesNewRoman at location 7861
non-TMW character ' ' in the font TimesNewRoman at location 7862
non-TMW character ' ' in the font TimesNewRoman at location 7863
non-TMW character '}' in the font Tahoma at location 7913
non-TMW character '{' in the font Tahoma at location 7921
non-TMW character ' ' in the font TimesNewRoman at location 7938
non-TMW character '{' in the font Tahoma at location 7952
non-TMW character ' ' in the font TimesNewRoman at location 8034
non-TMW character '}' in the font Tahoma at location 8063
non-TMW character '}' in the font Tahoma at location 8089
non-TMW character '{' in the font Tahoma at location 8092
non-TMW character ' ' in the font TimesNewRoman at location 8143
non-TMW character '}' in the font Tahoma at location 8210
non-TMW character '}' in the font Tahoma at location 8226
non-TMW character ' ' in the font TimesNewRoman at location 8232
non-TMW character '}' in the font Tahoma at location 8258
non-TMW character '}' in the font Tahoma at location 8352
non-TMW character '}' in the font Tahoma at location 8379
non-TMW character ' ' in the font TimesNewRoman at location 8439
non-TMW character ' ' in the font TimesNewRoman at location 8442
non-TMW character ' ' in the font TimesNewRoman at location 8443
non-TMW character ' ' in the font TimesNewRoman at location 8444
non-TMW character '}' in the font Tahoma at location 8499
non-TMW character ' ' in the font TimesNewRoman at location 8555
non-TMW character '}' in the font Tahoma at location 8558
non-TMW character '}' in the font Tahoma at location 8692
non-TMW character '{' in the font Tahoma at location 8797
non-TMW character '\' in the font Tahoma at location 8891
non-TMW character '{' in the font Tahoma at location 8915
non-TMW character '{' in the font Tahoma at location 8919
non-TMW character '}' in the font Tahoma at location 8930
non-TMW character ' ' in the font TimesNewRoman at location 8947
non-TMW character '}' in the font Tahoma at location 8979
non-TMW character '{' in the font Tahoma at location 8983
non-TMW character '{' in the font Tahoma at location 8990
non-TMW character '{' in the font Tahoma at location 8998
non-TMW character '}' in the font Tahoma at location 9065
non-TMW character '{' in the font Tahoma at location 9069
non-TMW character '}' in the font Tahoma at location 9078
non-TMW character '}' in the font Tahoma at location 9145
non-TMW character '}' in the font Tahoma at location 9177
non-TMW character ' ' in the font TimesNewRoman at location 9260
non-TMW character '}' in the font Tahoma at location 9312
non-TMW character ' ' in the font TimesNewRoman at location 9402
non-TMW character '{' in the font Tahoma at location 9441
non-TMW character '}' in the font Tahoma at location 9450
non-TMW character ' ' in the font TimesNewRoman at location 9472
non-TMW character '}' in the font Tahoma at location 9476
non-TMW character '}' in the font Tahoma at location 9488
non-TMW character '}' in the font Tahoma at location 9549
non-TMW character ' ' in the font TimesNewRoman at location 9561
non-TMW character ' ' in the font TimesNewRoman at location 9647
non-TMW character ' ' in the font TimesNewRoman at location 9670
non-TMW character ' ' in the font TimesNewRoman at location 9677
non-TMW character ' ' in the font TimesNewRoman at location 9685
non-TMW character '}' in the font Tahoma at location 9745
non-TMW character ' ' in the font TimesNewRoman at location 9751
non-TMW character newline in the font Times New Roman at location 9754

View file

@ -0,0 +1,6 @@
non-TMW character newline in the font Tahoma appears first at location 39
non-TMW character ' ' in the font TimesNewRoman appears first at location 45
non-TMW character '}' in the font Tahoma appears first at location 66
non-TMW character '{' in the font Tahoma appears first at location 219
non-TMW character '\' in the font Tahoma appears first at location 1237
non-TMW character newline in the font Times New Roman appears first at location 9754

View file

@ -250,6 +250,11 @@ public class TibetanDocument extends DefaultStyledDocument {
@return 1 if at least one non-TMW character was found in
the specified range, zero if none were, -1 on error. */
public int findAllNonTMWCharacters(int begin, int end) {
return findAllNonTMWCharacters(begin, end, System.out);
}
/** Configurable so that System.out isn't necessarily used. */
public int findAllNonTMWCharacters(int begin, int end, PrintStream out) {
if (end < 0)
end = getLength();
if (begin >= end)
@ -264,13 +269,13 @@ public class TibetanDocument extends DefaultStyledDocument {
returnValue = 1;
CharacterInAGivenFont cgf
= new CharacterInAGivenFont(getText(i, 1), fontName);
System.out.println("non-TMW character "
out.println("non-TMW character "
+ cgf + " at location " + i);
}
i++;
}
} catch (BadLocationException ble) {
ble.printStackTrace();
ble.printStackTrace(out);
ThdlDebug.noteIffyCode();
returnValue = -1;
}
@ -289,6 +294,11 @@ public class TibetanDocument extends DefaultStyledDocument {
@return 1 if at least one non-TMW character was found in
the specified range, zero if none were, -1 on error. */
public int findSomeNonTMWCharacters(int begin, int end) {
return findSomeNonTMWCharacters(begin, end, System.out);
}
/** Configurable so that System.out isn't necessarily used. */
public int findSomeNonTMWCharacters(int begin, int end, PrintStream out) {
if (end < 0)
end = getLength();
if (begin >= end)
@ -306,14 +316,14 @@ public class TibetanDocument extends DefaultStyledDocument {
= new CharacterInAGivenFont(getText(i, 1), fontName);
if (!cgfTable.containsKey(cgf)) {
cgfTable.put(cgf, "yes this character appears once");
System.out.println("non-TMW character "
+ cgf + " appears first at location " + i);
out.println("non-TMW character "
+ cgf + " appears first at location " + i);
}
}
i++;
}
} catch (BadLocationException ble) {
ble.printStackTrace();
ble.printStackTrace(out);
ThdlDebug.noteIffyCode();
returnValue = -1;
}

View file

@ -933,6 +933,9 @@ public static String getWylieForGlyph(int font, int code) {
public static String getWylieForGlyph(DuffCode dc) {
String hashKey = getHashKeyForGlyph(dc);
if (hashKey == null) {
// This error message is documented in
// www/htdocs/TMW_RTF_TO_THDL_WYLIE.html, so change them both
// when you change this.
return "<<[[JSKAD_TMW_TO_WYLIE_ERROR_NO_SUCH_WYLIE: Cannot convert DuffCode " + dc + " to THDL Extended Wylie. Please see the documentation for the TMW font and transcribe this yourself.]]>>";
}
return wylieForGlyph(hashKey);

View file

@ -0,0 +1,203 @@
/* Taken from the javaxdelta project.
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/javaxdelta/javaxdelta/com/nothome/delta/Checksum.java?rev=1.1.1.1&content-type=text/vnd.viewcvs-markup */
/*
*
* Copyright (c) 2001 Torgeir Veimo
* Copyright (c) 2002 Nicolas PERIDONT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
*/
package org.thdl.util.javaxdelta;
import java.io.*;
import java.util.*;
// DC: import cmp.Primes.*; // Please note that this package has a slightly different copyright style.
public class Checksum {
public static final int BASE = 65521;
public static final int S = (1 << 4); // 16
public static boolean debug = false;
protected int hashtable[];
protected long checksums[];
protected int prime;
public Checksum() { }
protected static final char single_hash[] = {
/* Random numbers generated using SLIB's pseudo-random number generator. */
0xbcd1, 0xbb65, 0x42c2, 0xdffe, 0x9666, 0x431b, 0x8504, 0xeb46,
0x6379, 0xd460, 0xcf14, 0x53cf, 0xdb51, 0xdb08, 0x12c8, 0xf602,
0xe766, 0x2394, 0x250d, 0xdcbb, 0xa678, 0x02af, 0xa5c6, 0x7ea6,
0xb645, 0xcb4d, 0xc44b, 0xe5dc, 0x9fe6, 0x5b5c, 0x35f5, 0x701a,
0x220f, 0x6c38, 0x1a56, 0x4ca3, 0xffc6, 0xb152, 0x8d61, 0x7a58,
0x9025, 0x8b3d, 0xbf0f, 0x95a3, 0xe5f4, 0xc127, 0x3bed, 0x320b,
0xb7f3, 0x6054, 0x333c, 0xd383, 0x8154, 0x5242, 0x4e0d, 0x0a94,
0x7028, 0x8689, 0x3a22, 0x0980, 0x1847, 0xb0f1, 0x9b5c, 0x4176,
0xb858, 0xd542, 0x1f6c, 0x2497, 0x6a5a, 0x9fa9, 0x8c5a, 0x7743,
0xa8a9, 0x9a02, 0x4918, 0x438c, 0xc388, 0x9e2b, 0x4cad, 0x01b6,
0xab19, 0xf777, 0x365f, 0x1eb2, 0x091e, 0x7bf8, 0x7a8e, 0x5227,
0xeab1, 0x2074, 0x4523, 0xe781, 0x01a3, 0x163d, 0x3b2e, 0x287d,
0x5e7f, 0xa063, 0xb134, 0x8fae, 0x5e8e, 0xb7b7, 0x4548, 0x1f5a,
0xfa56, 0x7a24, 0x900f, 0x42dc, 0xcc69, 0x02a0, 0x0b22, 0xdb31,
0x71fe, 0x0c7d, 0x1732, 0x1159, 0xcb09, 0xe1d2, 0x1351, 0x52e9,
0xf536, 0x5a4f, 0xc316, 0x6bf9, 0x8994, 0xb774, 0x5f3e, 0xf6d6,
0x3a61, 0xf82c, 0xcc22, 0x9d06, 0x299c, 0x09e5, 0x1eec, 0x514f,
0x8d53, 0xa650, 0x5c6e, 0xc577, 0x7958, 0x71ac, 0x8916, 0x9b4f,
0x2c09, 0x5211, 0xf6d8, 0xcaaa, 0xf7ef, 0x287f, 0x7a94, 0xab49,
0xfa2c, 0x7222, 0xe457, 0xd71a, 0x00c3, 0x1a76, 0xe98c, 0xc037,
0x8208, 0x5c2d, 0xdfda, 0xe5f5, 0x0b45, 0x15ce, 0x8a7e, 0xfcad,
0xaa2d, 0x4b5c, 0xd42e, 0xb251, 0x907e, 0x9a47, 0xc9a6, 0xd93f,
0x085e, 0x35ce, 0xa153, 0x7e7b, 0x9f0b, 0x25aa, 0x5d9f, 0xc04d,
0x8a0e, 0x2875, 0x4a1c, 0x295f, 0x1393, 0xf760, 0x9178, 0x0f5b,
0xfa7d, 0x83b4, 0x2082, 0x721d, 0x6462, 0x0368, 0x67e2, 0x8624,
0x194d, 0x22f6, 0x78fb, 0x6791, 0xb238, 0xb332, 0x7276, 0xf272,
0x47ec, 0x4504, 0xa961, 0x9fc8, 0x3fdc, 0xb413, 0x007a, 0x0806,
0x7458, 0x95c6, 0xccaa, 0x18d6, 0xe2ae, 0x1b06, 0xf3f6, 0x5050,
0xc8e8, 0xf4ac, 0xc04c, 0xf41c, 0x992f, 0xae44, 0x5f1b, 0x1113,
0x1738, 0xd9a8, 0x19ea, 0x2d33, 0x9698, 0x2fe9, 0x323f, 0xcde2,
0x6d71, 0xe37d, 0xb697, 0x2c4f, 0x4373, 0x9102, 0x075d, 0x8e25,
0x1672, 0xec28, 0x6acb, 0x86cc, 0x186e, 0x9414, 0xd674, 0xd1a5
};
/**
* assumes the buffer is of length S
*/
public static long queryChecksum(byte buf[], int len) {
int high = 0; int low = 0;
for (int i = 0; i < len; i++) {
low += single_hash[buf[i]+128];
high += low;
}
return ((high & 0xffff) << 16) | (low & 0xffff);
}
public static long incrementChecksum(long checksum, byte out, byte in) {
char old_c = single_hash[out+128];
char new_c = single_hash[in+128];
int low = ((int)((checksum) & 0xffff) - old_c + new_c) & 0xffff;
int high = ((int)((checksum) >> 16) - (old_c * S) + low) & 0xffff;
return (high << 16) | (low & 0xffff);
}
public static int generateHash(long checksum) {
long high = (checksum >> 16) & 0xffff;
long low = checksum & 0xffff;
long it = (high >> 2) + (low << 3) + (high << 16);
int hash = (int) (it ^ high ^ low);
return hash > 0 ? hash : -hash;
}
/**
* Initialize checksums for source. The checksum for the S bytes at offset
* S * i is inserted into an array at index i.
*
* This is not good enough, we also need a hashtable into these indexes.
*
*/
public void generateChecksums(File sourceFile, int length) throws IOException {
InputStream is = new BufferedInputStream(new FileInputStream(sourceFile));
int checksumcount = (int)sourceFile.length() / S;
// DC: System.out.println("generating checksum array of size " + checksumcount);
// DC: added this:
if (checksumcount == 0) checksumcount = 16;
checksums = new long[checksumcount];
hashtable = new int[checksumcount];
prime = findClosestPrime(checksumcount);
// DC: added this but I think it isn't needed thanks to the above addition:
if (0 == prime) throw new Error("Checksum failed 304ffe");
// DC: System.out.println("using prime " + prime);
// generate cheksums at each interval
for (int i = 0; i < checksumcount; i++) {
byte buf[] = new byte[S];
is.read(buf, 0, S);
checksums[i] = queryChecksum(buf, S);
}
is.close();
// generate hashtable entries for all checksums
for (int i = 0; i < checksumcount; i++) hashtable[i] = -1;
for (int i = 0; i < checksumcount; i++) {
int hash = generateHash(checksums[i]) % prime;
if (debug)
System.out.println("checking with hash: " + hash);
if (hashtable[hash] != -1) {
if (debug)
System.out.println("hash table collision for index " + i);
} else {
hashtable[hash] = i;
}
}
//System.out.println("checksums : " + printLongArray(checksums));
//System.out.println("hashtable : " + printIntArray(hashtable));
}
public int findChecksumIndex(long checksum) {
return hashtable[generateHash(checksum) % prime];
}
public static int findClosestPrime(int size) {
// since it is used only one, we initialize the prime number generator here
Primes primes = new Primes(size);
return primes.below(size);
}
private String printIntArray(int[] a) {
String result = "";
result += "[";
for (int i = 0; i < a.length; i++) {
result += a[i];
if (i != (a.length - 1))
result += ",";
else
result += "]";
}
return result;
}
private String printLongArray(long[] a) {
String result = "";
result += "[";
for (int i = 0; i < a.length; i++) {
result += a[i];
if (i != (a.length - 1))
result += ",";
else
result += "]";
}
return result;
}
}

View file

@ -0,0 +1,79 @@
/* Taken from the javaxdelta project.
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/javaxdelta/javaxdelta/com/nothome/delta/DebugDiffWriter.java?rev=1.1.1.1&content-type=text/vnd.viewcvs-markup */
/*
*
* Copyright (c) 2001 Torgeir Veimo
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
*/
package org.thdl.util.javaxdelta;
/**
* This class implements a GDIFF output queue, that will contatenate
* subsequent copy statements when necessary, and write both
* copy statement and insert statement to the specified OutputStream.
*
* The output follows the GDIFF file specification available at
* http://www.w3.org/TR/NOTE-gdiff-19970901.html.
*/
import java.util.*;
import java.io.*;
public class DebugDiffWriter implements DiffWriter {
byte buf[] = new byte[256]; int buflen = 0;
public DebugDiffWriter() {}
public void addCopy(int offset, int length) throws IOException {
if (buflen > 0)
writeBuf();
System.err.println("COPY off: " + offset + ", len: " + length);
}
public void addData(byte b) throws IOException {
if (buflen < 256)
buf[buflen++] = b;
else
writeBuf();
}
private void writeBuf() {
if (buflen > 0) { // DC: added this
System.err.print("DATA: ");
for (int ix = 0; ix < buflen; ix++) {
if (buf[ix] == '\n')
System.err.print("\\n");
else
System.err.print(String.valueOf((char)((char) buf[ix])));
//System.err.print("0x" + Integer.toHexString(buf[ix]) + " "); // hex output
}
System.err.println("");
buflen = 0;
}
}
public void flush() throws IOException { writeBuf(); } // DC: these did nothing, but that's not correct.
public void close() throws IOException { flush(); } // DC: these did nothing, but that's not correct.
}

View file

@ -0,0 +1,269 @@
/* Taken from the javaxdelta project.
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/javaxdelta/javaxdelta/com/nothome/delta/Delta.java?rev=1.1.1.1&content-type=text/vnd.viewcvs-markup */
/*
*
* Copyright (c) 2001 Torgeir Veimo
* Copyright (c) 2002 Nicolas PERIDONT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
*/
package org.thdl.util.javaxdelta;
import java.io.*;
import java.util.*;
public class Delta {
public final static int S = Checksum.S;
public final static boolean debug = false;
public final static int buff_size = 64*S;
public Delta() { }
public void computeDelta(File sourceFile, File targetFile, DiffWriter output) throws IOException {
int targetLength = (int) targetFile.length();
int sourceLength = (int) sourceFile.length();
int targetidx = 0;
Checksum checksum = new Checksum();
if (debug) {
System.out.println("source len: " + sourceLength);
System.out.println("target len: " + targetLength);
System.out.println("using match length S = " + S);
}
checksum.generateChecksums(sourceFile, sourceLength);
PushbackInputStream target = new PushbackInputStream(new BufferedInputStream(new FileInputStream(targetFile)),buff_size);
RandomAccessFile source = new RandomAccessFile(sourceFile, "r");
boolean done = false;
byte buf[] = new byte[S];
long hashf = 0; byte b[] = new byte[1]; byte sourcebyte[] = new byte[S];
if (targetLength-targetidx <= S) {
System.err.println("too short input file");
return;
}
// initialize first complete checksum.
target.read(buf, 0, S);
targetidx += S;
hashf = checksum.queryChecksum(buf, S);
// The check for alternative hashf is only because I wanted to verify that the
// update method really is correct. I will remove it shortly.
long alternativehashf = hashf;
if (debug)
System.out.println("my hashf: " + hashf + ", adler32: " + alternativehashf);
while (!done) {
int index = checksum.findChecksumIndex(hashf);
if (index != -1) {
// possible match, need to check byte for byte
boolean match = true;
int offset = index * S;
int length = S - 1;
source.seek(offset);
source.read(sourcebyte, 0, S);
for (int ix = 0; ix < S; ix++) {
if (sourcebyte[ix] != buf[ix]) {
match = false;
}
}
if (match) {
//System.out.println("before targetidx : " + targetidx );
// The length of the match is determined by comparing bytes.
long start = System.currentTimeMillis();
boolean ok = true;
byte[] sourceBuff = new byte[buff_size];
byte[] targetBuff = new byte[buff_size];
int source_idx = 0;
int target_idx = 0;
do{
source_idx = source.read(sourceBuff, 0, buff_size);
target_idx = target.read(targetBuff, 0, buff_size);
int read_idx = Math.max(source_idx,target_idx);
int i = 0;
do {
targetidx++;
++length;
ok = sourceBuff[i] == targetBuff[i];
i++;
if(!ok) {
b[0] = targetBuff[i-1];
target.unread(targetBuff,i,target_idx-i);
}
} while(i < read_idx && ok);
} while(ok && targetLength-targetidx > 0);
// this is a insert instruction
//System.out.println("output.addCopy("+offset+","+length+")");
output.addCopy(offset, length);
if (targetLength-targetidx <= S) { // eof reached, special case for last bytes
if (debug)
System.out.println("last part of file");
buf[0] = b[0]; // don't loose this byte
int remaining = targetLength-targetidx;
target.read(buf, 1 , remaining);
targetidx += remaining;
for (int ix = 0; ix < (remaining + 1); ix++)
output.addData(buf[ix]);
done = true;
} else {
buf[0] = b[0];
target.read(buf, 1, S - 1);
targetidx += S-1;
alternativehashf = hashf = checksum.queryChecksum(buf, S);
}
continue; //continue loop
}
}
if (targetLength-targetidx > 0) {
// update the adler fingerpring with a single byte
target.read(b, 0, 1);
targetidx += 1;
// insert instruction with the old byte we no longer use...
output.addData(buf[0]);
alternativehashf = checksum.incrementChecksum(alternativehashf, buf[0], b[0]);
for (int j = 0; j < 15; j++)
buf[j] = buf[j+1];
buf[15] = b[0];
hashf = checksum.queryChecksum(buf, S);
if (debug)
System.out.println("raw: " + Integer.toHexString((int)hashf) + ", incremental: " + Integer.toHexString((int)alternativehashf));
} else {
for (int ix = 0; ix < S; ix++)
output.addData(buf[ix]);
done = true;
}
}
output.close();
}
// sample program to compute the difference between two input files.
public static void main(String argv[]) {
// DC: javaxdeltamain(argv);
thdltoolsmain(argv);
}
public static void javaxdeltamain(String argv[]) {
Delta delta = new Delta();
if (argv.length != 3) {
System.err.println("usage Delta [-d] source target [output]");
System.err.println("either -d or an output filename must be specified.");
System.err.println("aborting..");
return;
}
try {
DiffWriter output = null;
File sourceFile = null;
File targetFile = null;
if (argv[0].equals("-d")) {
sourceFile = new File(argv[1]);
targetFile = new File(argv[2]);
output = new DebugDiffWriter();
} else {
sourceFile = new File(argv[0]);
targetFile = new File(argv[1]);
output = new GDiffWriter(new DataOutputStream(new BufferedOutputStream(new FileOutputStream(new File(argv[2])))));
}
if (sourceFile.length() > Integer.MAX_VALUE || targetFile.length() > Integer.MAX_VALUE) {
System.err.println("source or target is too large, max length is " + Integer.MAX_VALUE);
System.err.println("aborting..");
return;
}
//output.close();
delta.computeDelta(sourceFile, targetFile, output);
output.flush();
output.close();
// DC: System.out.println("finished generating delta");
} catch (IOException ioe) {
System.err.println("error while generating delta; " + ioe);
}
}
public static void thdltoolsmain(String argv[]) {
Delta delta = new Delta();
if (argv.length != 2) {
System.err.println("usage Delta source target");
System.err.println("aborting..");
System.exit(-2);
}
int rc = Delta.areFilesDifferent(argv[0], argv[1]);
if (rc == 1)
System.out.println("files differ");
else if (rc == 0)
System.out.println("files are the same");
else
System.out.println("error comparing files");
System.exit(rc);
}
/** Returns 1 if source and target differ, 0 if they don't, -1 on
error. David Chandler wrote this based on main(). */
public static int areFilesDifferent(String source, String target) {
Delta delta = new Delta();
try {
YesOrNoDiffWriter output = new YesOrNoDiffWriter();
File sourceFile = new File(source);
File targetFile = new File(target);
if (sourceFile.length() > Integer.MAX_VALUE || targetFile.length() > Integer.MAX_VALUE) {
return -1;
}
delta.computeDelta(sourceFile, targetFile, output);
return (output.areFilesDifferent()) ? 1 : 0;
} catch (IOException ioe) {
return -1;
}
}
}

View file

@ -0,0 +1,43 @@
/* Taken from the javaxdelta project.
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/javaxdelta/javaxdelta/com/nothome/delta/DiffWriter.java?rev=1.1.1.1&content-type=text/vnd.viewcvs-markup */
/*
*
* Copyright (c) 2001 Torgeir Veimo
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
*/
package org.thdl.util.javaxdelta;
import java.io.IOException;
/**
*
* @author torgeir
*/
public interface DiffWriter {
public void addCopy(int offset, int length) throws IOException;
//public void addInsert(String insertString) throws IOException;
public void addData(byte b) throws IOException;
public void flush() throws IOException;
public void close() throws IOException;
}

View file

@ -0,0 +1,141 @@
/* Taken from the javaxdelta project.
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/javaxdelta/javaxdelta/com/nothome/delta/GDiffWriter.java?rev=1.1.1.1&content-type=text/vnd.viewcvs-markup */
/*
*
* Copyright (c) 2001 Torgeir Veimo
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
*/
package org.thdl.util.javaxdelta;
/**
* The output follows the GDIFF file specification available at
* http://www.w3.org/TR/NOTE-gdiff-19970901.html.
*/
import java.util.*;
import java.io.*;
public class GDiffWriter implements DiffWriter {
byte buf[] = new byte[256]; int buflen = 0;
protected boolean debug = false;
//Vector writeQueue = new Vector();
DataOutputStream output = null;
public GDiffWriter(DataOutputStream os) throws IOException {
this.output = os;
// write magic string "d1 ff d1 ff 04"
output.writeByte(0xd1);
output.writeByte(0xff);
output.writeByte(0xd1);
output.writeByte(0xff);
output.writeByte(0x04);
}
public void setDebug(boolean flag) { debug = flag; }
public void addCopy(int offset, int length) throws IOException {
if (buflen > 0)
writeBuf();
//output debug data
if (debug)
System.err.println("COPY off: " + offset + ", len: " + length);
// output real data
byte command;
if (offset > Integer.MAX_VALUE) {
// use long, int format
output.writeByte(255);
// Actually, we don't support longer files than int.MAX_VALUE at the moment..
} else if (offset < 65536) {
if (length < 256) {
// use ushort, ubyte
output.writeByte(249);
output.writeShort(offset);
output.writeByte(length);
} else if (length > 65535) {
// use ushort, int
output.writeByte(251);
output.writeShort(offset);
output.writeInt(length);
} else {
// use ushort, ushort
output.writeByte(250);
output.writeShort(offset);
output.writeShort(length);
}
} else {
if (length < 256) {
// use int, ubyte
output.writeByte(252);
output.writeInt(offset);
output.writeByte(length);
} else if (length > 65535) {
// use int, int
output.writeByte(254);
output.writeInt(offset);
output.writeInt(length);
} else {
// use int, ushort
output.writeByte(253);
output.writeInt(offset);
output.writeShort(length);
}
}
}
public void addData(byte b) throws IOException {
if (buflen >= 246)
writeBuf();
buf[buflen] = b; buflen++;
}
private void writeBuf() throws IOException {
// output debug data
if (debug) {
System.err.print("DATA:");
for (int ix = 0; ix < buflen; ix++) {
if (buf[ix] == '\n')
System.err.print("\\n");
else
System.err.print(String.valueOf((char)((char) buf[ix])));
}
System.err.println("");
}
if (buflen > 0) {
// output real data
output.writeByte(buflen);
output.write(buf, 0, buflen);
}
buflen = 0;
}
public void flush() throws IOException { if (buflen > 0) writeBuf(); output.flush(); }
public void close() throws IOException { this.flush(); }
}

View file

@ -0,0 +1,228 @@
/* Taken from the javaxdelta project. */
/*
Primes 1.1 calculates the primes 1..N, tells you if N is prime,
computes the prime just below or above N. It is useful in computing
optimal HashTable sizes. Java source included. Copyright 1998 by
Roedy Green of Canadian Mind Products. May be freely distbributed
for any purpose but military.
*/
// Primes.java
package org.thdl.util.javaxdelta;
/** Copyright 1998
* Roedy Green
* Canadian Mind Products
* #208 - 525 Ninth Street
* New Westminster, BC Canada V3M 5T9
* tel: (604) 777-1804
* mailto:roedy@mindprod.com
* http://mindprod.com
*/
// May be freely distributed for any purpose but military
import java.util.BitSet;
/**
* @author Roedy Green
* @version 1.10 1998 November 10
* Calculate primes using Eratostheses Sieve.
* Tell if a given number is prime.
* Find a prime just below a given number.
* Find a prime just above a given number.
*/
/*
* version 1.1 1998 November 10 - new address and phone.
*/
public class Primes
{
private static final String EmbeddedCopyright =
"Copyright 1997-2000 Roedy Green, Canadian Mind Products, http://mindprod.com";
/**
* constructors
*/
public Primes()
{
ensureCapacity(1000);
}
/**
* @param capacity - largest number you will be asking if prime.
* If give too small a number, it will automatically grow by
* recomputing the sieve array.
*/
public Primes (int capacity)
{
ensureCapacity(capacity);
}
/**
* @param candidate - is this a prime?
*/
public boolean isPrime(int candidate)
{
ensureCapacity(candidate);
if (candidate < 3) return candidate != 0;
if (candidate % 2 == 0 ) return false;
return !b.get(candidate/2);
}
/**
* @return first prime higher than candidate
*/
public int above(int candidate)
{
do
{
// see what we can find in the existing sieve
for (int i=candidate+1; i<= sieveCapacity; i++)
{
if (isPrime(i)) return i;
}
// Keep building ever bigger sieves till we succeed.
// The next prime P' is between P+2 and P^2 - 2.
// However that is a rather pessimistic upper bound.
// Ideally some theorem would tell us how big we need to build
// to find one.
ensureCapacity(Math.max(candidate*2, sieveCapacity*2));
} // end do
while (true);
} // end above
/**
* @param return first prime less than candidate
*/
public int below (int candidate)
{
for (candidate--; candidate > 0; candidate--)
{
if (isPrime(candidate)) return candidate;
}
// candidate was 1 or 0 or -ve
return 0;
}
/**
* calc all primes in the range 1..n,
* not the first n primes.
* @param n, highest candidate, not necessarily prime.
* @return list of primes 1..n in an array
*/
public final int[] getPrimes(int n)
{
// calculate the primes
ensureCapacity(n);
// pass 1: count primes
int countPrimes = 0;
for (int i = 0; i <= n; i++)
{
if (isPrime(i)) countPrimes++;
}
// pass 2: construct array of primes
int [] primes = new int[countPrimes];
countPrimes = 0;
for (int i = 0; i <= n; i++)
{
if (isPrime(i)) primes[countPrimes++] = i;
}
return primes;
} // end getPrimes
/**
* calculate the sieve, bit map of all primes 0..n
* @param n highest number evalutated by the sieve, not necessarily prime.
*/
private final void sieve ( int n )
{
// Presume BitSet b set is big enough for our purposes.
// Presume all even numbers are already marked composite, effectively.
// Presume all odd numbers are already marked prime (0 in bit map).
int last = (int)(Math.sqrt(n))+1;
for (int candidate = 3; candidate <= last; candidate += 2)
{
// only look at odd numbers
if (!b.get(candidate/2) /* if candidate is prime */)
{
// Our candidate is prime.
// Only bother to mark multiples of primes. Others already done.
// no need to mark even multiples, already done
int incr = candidate*2;
for ( int multiple = candidate + incr; multiple < n; multiple += incr)
{
b.set(multiple/2); // mark multiple as composite
} // end for multiple
} // end if
} // end for candidate
// at this point our sieve b is correct, except for 0..2
} // end sieve
/**
* Ensure have a sieve to tackle primes as big as n.
* If we don't allocate a sieve big enough and calculate it.
* @param n - ensure sieve big enough to evaluate n for primality.
*/
private void ensureCapacity (int n)
{
if ( n > sieveCapacity )
{
b = new BitSet((n+1)/2);
// starts out all 0, presume all numbers prime
sieveCapacity = n;
sieve(n);
}
// otherwise existing sieve is fine
} // end ensureCapacity
private int sieveCapacity;
// biggest number we have computed in our sieve.
// our BitSet array is indexed 0..N (odd only)
private BitSet b; /* true for each odd number if is composite */
/**
* Demonstrate and test the methods
*/
public static void main (String[] args)
{
// print primes 1..101
Primes calc = new Primes(106);
int[] primes = calc.getPrimes(101);
for (int i=0; i<primes.length; i++)
{
System.out.println(primes[i]);
}
// demonstrate isPrime, above, below
System.out.println(calc.isPrime(149));
System.out.println(calc.below(149));
System.out.println(calc.above(149));
// print all the primes just greater than powers of 2
calc = new Primes(10000000);
for (int pow=8; pow < 10000000; pow*=2)
System.out.println(calc.above(pow));
// Validate that isPrime works by comparing it with brute force
for (int i=3; i<=151; i++)
{
boolean prime = true;
for (int j=2; j<i; j++)
{
if (i % j == 0 )
{
prime = false;
break;
}
} // end for j
if ( calc.isPrime(i) != prime ) System.out.println(i + " oops");
} // end for i
} // end main
} // end Primes

View file

@ -0,0 +1,60 @@
/* Added by David Chandler, based on stuff in this package. */
/*
*
* Copyright (c) 2001 Torgeir Veimo
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
*/
package org.thdl.util.javaxdelta;
import java.util.*;
import java.io.*;
/** We look to see that one special DATA statement and only one COPY statment
are generated. If so, there's no difference between the input and
the output. Otherwise there is.
@author David Chandler */
public class YesOrNoDiffWriter implements DiffWriter {
public YesOrNoDiffWriter() {}
private int numCopies = 0;
private int numDatas = 0;
public void addCopy(int offset, int length) throws IOException {
if (numCopies == 1) numCopies = 2;
if (numCopies == 0) numCopies = 1;
}
public void addData(byte b) throws IOException {
if (numDatas == 1) numDatas = 2;
if (numDatas == 0) numDatas = 1;
}
public boolean areFilesDifferent() {
return numCopies != 1 || numDatas != 1;
}
private void writeBuf() { }
public void flush() throws IOException { }
public void close() throws IOException { }
}