[sword-svn] r173 - trunk/versification

chrislit at crosswire.org chrislit at crosswire.org
Sat Mar 14 02:58:38 MST 2009


Author: chrislit
Date: 2009-03-14 02:58:38 -0700 (Sat, 14 Mar 2009)
New Revision: 173

Modified:
   trunk/versification/canon.bible.xml
   trunk/versification/v11nsys.pl
Log:
added abbrevs array builder

Modified: trunk/versification/canon.bible.xml
===================================================================
--- trunk/versification/canon.bible.xml	2009-03-14 08:44:58 UTC (rev 172)
+++ trunk/versification/canon.bible.xml	2009-03-14 09:58:38 UTC (rev 173)
@@ -568,7 +568,10 @@
 		<abbr>Psx</abbr>
 		<abbr>2Ps</abbr>
 		<name>Additional Psalm</name>
+		<name>Ps 151</name>
+		<name>Ps151</name>
 		<name>Psalm 151</name>
+		<name>Psalm151</name>
 	</book>
 	<book>
 		<id>EsthGr</id>

Modified: trunk/versification/v11nsys.pl
===================================================================
--- trunk/versification/v11nsys.pl	2009-03-14 08:44:58 UTC (rev 172)
+++ trunk/versification/v11nsys.pl	2009-03-14 09:58:38 UTC (rev 173)
@@ -5,17 +5,16 @@
 #  When run without any arguments, this script reads the CCEL files:
 #  Bible.*.xml.
 #  
-#  Otherwise, supply the script with a list (or wildcard) of VPL files and it
+#  Otherwise, supply the script with a list (or wildcard) files and it
 #  will attempt to create a v11n system definition on that basis.
 #  
-#  If the --nosis switch is added as the first argument, the script will
-#  interpret book abbreviations rather than simply assume that they are OSIS 
-#  abbreviations.
+#  The --vpl switch instructs the script to interpret files as VPL files.
+#  The --imp switch instructs the script to interpret files as IMP files.
 #
 ###############################################################################
 
 
-sub buildBooks {
+sub buildBooksArrays {
     if ($lastBook ne "" && $osis{lc($lastBook)} eq "") {
 	print "ERROR: Unknown book abbreviation: $lastBook in $v11n\n";
     }
@@ -58,6 +57,7 @@
 	if ($line =~ /<id>(.+?)<\/id>/) {
 	    $id = $1;
 	    $osis{lc($id)} = $id;
+	    $abbrevs{lc($id)} = "$id;"
 	}
 	elsif ($line =~ /<abbr>(.+?)<\/abbr>/) {
 	    $name = $1;
@@ -65,16 +65,17 @@
 		$osis{lc($name)} = $id;
 	    }
 	    else {
-		print "ERROR: Duplicate mapping from $id found in $mapfile (<abbr>).\n";
+#		print "ERROR: Duplicate mapping from $id found in $mapfile (<abbr>).\n";
 	    }
 	}
 	elsif ($line =~ /<name>(.+?)<\/name>/) {
 	    $name = $1;
 	    if ($osis{lc($name)} eq "") {
 		$osis{lc($name)} = $id;
+		$abbrevs{lc($id)} .= "$name;"
 	    }
 	    else {
-		print "ERROR: Duplicate mapping from $id found in $mapfile (<name>).\n";
+#		print "ERROR: Duplicate mapping from $id found in $mapfile (<name>).\n";
 	    }
 
 	    if ($idmap{$id} eq "") {
@@ -88,19 +89,18 @@
     }
     close (MAP);
 }
-die();
 
 if (@ARGV[0] ne "") {
     $n = 0;
     $mode = "xml";
     while (@ARGV[$n] ne "") {
-	if ($n == 0 && @ARGV[0] eq "--vpl") {
+	if (@ARGV[$n] eq "--vpl") {
 	    $mode = "vpl";
 	}
-	elsif ($n == 0 && @ARGV[0] eq "--imp") {
+	elsif (@ARGV[$n] eq "--imp") {
 	    $mode = "imp";
 	}
-	elsif ($n == 0 && @ARGV[0] eq "--xml") {
+	elsif (@ARGV[$n] eq "--xml") {
 	    $mode = "xml";
 	}
 	else {
@@ -134,7 +134,7 @@
     open OUTF, ">$outfile";
 
     print OUTF "/******************************************************************************\n * $outfile.h - Versification data for the $v11n system\n *\n * Copyright 1998-2005 CrossWire Bible Society (http://www.crosswire.org)\n *	CrossWire Bible Society\n *	P. O. Box 2528\n *	Tempe, AZ  85280-2528\n *\n * This program is free software; you can redistribute it and/or modify it\n * under the terms of the GNU General Public License as published by the\n * Free Software Foundation version 2.\n *\n * This program is distributed in the hope that it will be useful, but\n * WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n * General Public License for more details.\n *\n";
-    print OUTF "\n#ifndef V11N" . uc($v11n) . "_H\n#define V11N" . uc($v11n) . "_H\n\nSWORD_NAMESPACE_START\n\n";
+    print OUTF "\n#ifndef V11N" . uc($v11n) . "_H\n#define V11N" . uc($v11n) . "_H\n\nSWORD_NAMESPACE_START\n\n\n";
 
     $thisBook = "";
     $thisChap = "";
@@ -144,6 +144,10 @@
     $cCount = 0;
     $vCount = 0;
     
+    $abbrevs = "/******************************************************************************\n *	Abbreviations - MUST be in alphabetical order & by PRIORITY\n *		RULE: first match of entire key\n *			(e.g. key: \"1CH\"; match: \"1CHRONICLES\")\n */\n\nconst struct abbrev builtin_abbrevs$v11n\[\] = {\n";
+    $abbrevsCloser = "\t{\"\", \"\"}\n};\n\n\n";
+    $abbrevsList = "";
+
     $vm = "/******************************************************************************\n *	Maximum verses per chapter\n */\n\nint vm$v11n\[\] = {";
     $otbooks = "/******************************************************************************\n * [on]tbooks$v11n - initialize static instance for all canonical text names\n *		and chapmax\n */\nstruct sbook otbooks$v11n\[\] = {\n";
     $ntbooks = "struct sbook ntbooks$v11n\[\] = {\n";
@@ -184,8 +188,10 @@
 	    if ($thisBook ne $lastBook) {
 		$bCount++;
 		$vm .= "\n\t// $idmap{$osis{lc($thisBook)}}\n\t";
+		$abbrevsList .= $abbrevs{lc($thisBook)};
+		
 		if ($lastBook ne "") {
-		    buildBooks{};
+		    buildBooksArrays{};
 		}
 		$cCount = 1;
 		$vCount = 1;
@@ -200,15 +206,28 @@
 	}
     }
     $vm .= "$vCount\n};\n";
-    buildBooks();
+    buildBooksArrays();
     $otbooks .= $booksCloser;
     $ntbooks .= $booksCloser;
     
+    $abbrevsList = lc($abbrevsList);
+    @abbrevsQueue = (); 
+    while ($abbrevsList =~ /^(.+?);/) {
+	push @abbrevsQueue, $1;
+	$abbrevsList =~ s/^(.+?);//;
+    }
+    @abbrevsQueue = sort @abbrevsQueue;
+    foreach $a (@abbrevsQueue) {
+	$abbrevs .= "\t{\"" . uc($a) . "\", \"" . $osis{lc($a)} . "\"},\t\t//" . $idmap{$osis{lc($a)}} . "\n";
+    }
+    $abbrevs .= $abbrevsCloser;
+
     print OUTF $otbooks;
     print OUTF $ntbooks;
+    print OUTF $abbrevs;
     print OUTF $vm;
     
-    print OUTF "\nSWORD_NAMESPACE_END\n\n#endif\n";
+    print OUTF "\n\nSWORD_NAMESPACE_END\n\n\n#endif\n";
     
     close (INF);
     close (OUTF);




More information about the sword-cvs mailing list