[sword-svn] r159 - trunk/versification

chrislit at crosswire.org chrislit at crosswire.org
Tue Mar 10 04:36:04 MST 2009


Author: chrislit
Date: 2009-03-10 04:36:04 -0700 (Tue, 10 Mar 2009)
New Revision: 159

Modified:
   trunk/versification/v11nsys.pl
Log:
finished more of the conversion script (constructs the [on]tbooks[] arrays)

Modified: trunk/versification/v11nsys.pl
===================================================================
--- trunk/versification/v11nsys.pl	2009-03-10 11:12:22 UTC (rev 158)
+++ trunk/versification/v11nsys.pl	2009-03-10 11:36:04 UTC (rev 159)
@@ -13,6 +13,18 @@
     return $ret;
 }
 
+sub buildBooks {
+    if ($lastBook eq "Matt") {
+	$otnt = 1;
+    }
+    if ($otnt == 0) {
+	$otbooks .= "\t{\"$idmap{$lastBook}\", \"$lastBook\", \"$lastBook\", $lastChap},\n";
+    }
+    else {
+	$ntbooks .= "\t{\"$idmap{$lastBook}\", \"$lastBook\", \"$lastBook\", $lastChap},\n";
+    }
+}
+
 # @canons will contain this list of files, these are in a basic XML format.
 # Each file lists osisIDs along with the English names associated with the
 # osisID. These aren't exhaustive, and may or may not overlap (but hopefully
@@ -69,42 +81,55 @@
     $thisBook = "";
     $thisChap = "";
     $thisVers = "";
-
+    
     $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";
+    $booksCloser = "\t{\"\", \"\", \"\", 0}\n};\n";
+    
+    $otnt = 0; # 0 = ot, 1 = nt
+    
     while (<INF>) {
 	$line = $_;
-
+	
 	$line = cleanupLine($line);
-
+	
 	if ($line =~ /<osisID.+?code=\"(.+?)\"\/>/) {
 	    $osisID = $1;
 	    
 	    $lastBook = $thisBook;
 	    $lastChap = $thisChap;
 	    $lastVers = $thisVers;
-
+	    
 	    $osisID =~ /([^\.]+)\.(\d+)\.(\d+)/;
-
+	    
 	    $thisBook = $1;
 	    $thisChap = $2;
 	    $thisVers = $3;
-
+	    
 	    if ((($thisBook ne $lastBook) ||($thisChap ne $lastChap)) && $lastVers ne "") {
 		$vm .= "$lastVers, ";
 	    }
 
 	    if ($thisBook ne $lastBook) {
 		$vm .= "\n\t// $idmap{$thisBook}\n\t";
+		if ($lastBook ne "") {
+		    buildBooks{};
+		}
 	    }
 	}
     }
     $vm .= "$thisVers\n};\n";
-
-    print OUTF "$vm";
-
+    buildBooks();
+    $otbooks .= $booksCloser;
+    $ntbooks .= $booksCloser;
+    
+    print OUTF $otbooks;
+    print OUTF $ntbooks;
+    print OUTF $vm;
+    
     print OUTF "\nSWORD_NAMESPACE_END\n\n#endif\n";
-
+    
     close (INF);
     close (OUTF);
 }




More information about the sword-cvs mailing list