2 ###############################################################################
5 # RCS: $Header: /home/matthew/cvs/bible-kjv-4.10/makeindex2,v 2.2 2003/01/13 17:40:29 matthew Exp $
6 # Description: Create start_verse and start_chapter tables
8 # Created: Tue Jan 5 14:20:08 1993
9 # Modified: Tue Apr 27 12:30:49 1993 (Chip Chapin) chip@hpclbis
11 # Package: Text Storage Library (Bible Retrieval System)
12 # Status: Experimental (Do Not Distribute)
14 ###############################################################################
17 # $Log: makeindex2,v $
18 # Revision 2.2 2003/01/13 17:40:29 matthew
19 # changed to #!/bin/bash, since that's in Debian's build-essential
20 # whereas ksh isn't :)
22 # Revision 2.1 2003/01/08 16:06:25 matthew
23 # create the vrs2num.index file earlier on so that the later routines do not barf
25 # Tue Apr 27 12:30:21 1993 (Chip Chapin) chip@hpclbis
26 # Use temp files and only create output files if successful.
27 # Tue Jan 5 14:23:06 1993 (Chip Chapin) chip@hpclbis
28 # Initial creation, incorporating the scripts "vrs2num", "mkvstruct",
29 # and "mkcstruct" from January 1989. This is the first time I've had to
30 # rebuild these tables since then...
31 # Many changes to vrs2num, required by changes to rawtext format.
32 # Additional changes were required throughout to reflect small data structure
33 # changes that had been made by hand.
34 ###############################################################################
38 print "Usage: $0 datafile"
47 ###############################################################################
48 # vrs2num, January 21, 1989
50 # script to read bible text and produce a list will specify
51 # the absolute "verse number" from the start of the KJ text
52 # for each Book:Chapter (zero-based). Also records how many verses
53 # are in each chapter.
54 # Output is the following table:
56 # Book Chapter VrsNum NumVerses
64 book = "Ge"; chap = 1;
69 # File starts with an info line.
70 if ( split($1,p,":") < 2 ) next;
73 if (book_chap != last_bc) {
74 # starting new chapter
75 # Print info for last chapter.
76 # Book -- Chapter -- Starting absverse -- Number of verses
77 printf "%s\t%d\t%d\t%d\n", book, chap, start_absverse, nverses;
79 # Get ref without first character. This avoids problems with
80 # refs that start with a number, e.g. "1Ki1:1".
81 # Then find out where the chapter number starts.
82 # Finally, extract the book and chapter info.
83 tempbc = substr(book_chap, 2);
84 n=match(tempbc, /[0-9]/);
85 book = substr(book_chap, 1, n);
86 chap = substr(book_chap, n+1);
88 start_absverse = NR-2; # Remember where we are now.
89 # Lose one due to leading \n in file,
90 # and one because we are zero-based.
94 nverses++; # Keep count of verses in chapter
97 END { # print the last chapter. Might as well do this right.
98 printf "%s\t%d\t%d\t%d\n", book, chap, start_absverse, nverses;
102 #Do this now, so we have a vrs2num.index to work from later.
103 if [ -s "$T1" ]; then mv $T1 vrs2num.index ; fi
107 ###############################################################################
108 # mkvstruct, January 21, 1989
110 # Make verse structure -- creates the array that contains the
111 # "absolute verse number" (zero-based) for every CHAPTER in the Bible.
112 # Uses the table "vrs2num" which we created earlier.
114 # This table gives the number of verses occuring in the Bible BEFORE
115 # any particular chapter. Gen 1 is "chapter 1", Gen 2 is "chapter 2"
116 # etc. Since there are no verses prior to Gen 1, start_verse[1] == 0.
117 # start_verse[2] == 31 because there are 31 verses prior to Gen 2:1.
119 # Chip Chapin, 890114.
124 printf "short start_verse[]={ 0,";
127 if (chaps_printed % 10 == 0) printf "\n\t";
133 printf "%d\n\t};\n", nextone ;
135 ' vrs2num.index > $T2
138 ###############################################################################
139 # mkcstruct, January 21, 1989
140 # Adapted from mkvstruct
142 # Make chapter structure -- creates the array that contains the
143 # "absolute chapter number" (zero-based) for every BOOK in the Bible.
144 # Uses the table "vrs2num" which we created earlier, and contains one
145 # entry for each chapter in the Bible. We wish to create a table that
146 # can be indexed by BOOK (Genesis == 0, Revelation == 65) to determine
147 # the number of chapters that precede that book in the Bible.
148 # Our only purpose here is to create the appropriate C structure.
150 # The start_chapter table is indexed by Bible BOOK (0..65) and
151 # gives the number of CHAPTERS in the whole Bible that precede that
152 # particular book. Thus given the BOOK, CHAPTER, and VERSE for a
153 # reference, we can easily compute an absolute verse number for that
154 # reference as follows:
156 # abs_verse = start_verse[ start_chapter[BOOK] + CHAPTER ] + VERSE
158 # Chip Chapin, 890114.
163 printf "short start_chapter[]={";
168 if (books_printed % 10 == 0) printf "\n\t";
174 printf "%d\n\t};\n", NR ;
176 ' vrs2num.index > $T3
178 # Have to do this earlier or the second two routines barf
179 #if [ -s "$T1" ]; then mv $T1 vrs2num.index ; fi
180 if [ -s "$T2" ]; then mv $T2 brl-startverse.h ; fi
181 if [ -s "$T3" ]; then mv $T3 brl-startchapter.h; fi
185 ###############################################################################
186 # Gnu Emacs variables...
190 # eval: (auto-fill-mode 0)
191 # default-header-comment-character: ?#
192 # header-prefix: "#!/bin/ksh"
194 # header-comment-character: ?#