2 *******************************************************************************
5 * RCS: $Header: /home/matthew/cvs/bible-kjv-4.10/bible.c,v 2.7 2008/03/11 20:48:41 matthew Exp $
6 * Description: Write Bible text to stdout.
7 * Author: Chip Chapin, Hewlett Packard Company
9 * Modified: Mon Apr 26 11:11:45 1993 (Chip Chapin) chip@hpclbis
11 * Package: Bible Retrieval System
12 * Status: Experimental (Do Not Distribute)
14 *******************************************************************************
18 * Mon Apr 26 11:09:58 1993 (Chip Chapin) chip@hpclbis
19 * Print welcome message when invoked interactively.
20 * Fri Apr 23 12:57:34 1993 (Chip Chapin) chip@hpclbis
21 * Changed fflush( NULL ) to fflush( stdout ) to make SunOS happy.
22 * Thu Apr 22 11:20:56 1993 (Chip Chapin) chip@hpclbis
23 * Support non-POSIX sprintf.
24 * Tue Jan 5 17:10:01 1993 (Chip Chapin) chip@hpclbis
25 * Removed printverse(), might as well call brl_printverse().
26 * get_verse() is now commented out. Nobody uses it anymore.
27 * Allow leading white space on input lines.
28 * Tue Jan 5 10:46:17 1993 (Chip Chapin) chip@hpclbis
29 * Added line formatting to cmd_list output.
31 * Mon Jan 4 15:41:26 1993 (Chip Chapin) chip@hpclbis
32 * Added ?or and ?in commands. Some big changes here.
33 * Thu Dec 24 11:04:04 1992 (Chip Chapin) chip@hpclbis
34 * Added prompter function.
35 * Wed Dec 23 13:19:22 1992 (Chip Chapin) chip@hpclbis
36 * Add release version to help output.
38 * Fix bug in command processing "?".
39 * Minor tweaks to eliminate compile warnings.
40 * Mon Dec 21 19:12:30 1992 (Chip Chapin) chip@hpclbis
41 * Added interactive command processing and concordance.
42 *******************************************************************************
45 * Revision 2.7 2008/03/11 20:48:41 matthew
46 * #include <string.h> (enables compilation on Mac OS) - closes Debian
49 * Revision 2.6 2005/01/23 11:14:25 matthew
52 * Revision 2.5 2005/01/22 18:52:48 matthew
53 * No longer write over strings
55 * Revision 2.4 2005/01/21 18:55:33 matthew
56 * make pretty_print toggling a bit clearer.
57 * Remove unused variables.
58 * add undeclared functions to brl.h
59 * include readline/history.h
62 * Revision 2.3 2005/01/21 18:32:25 matthew
63 * Remove #defines to bible.h and include that
65 * Revision 2.2 2005/01/21 18:24:03 matthew
66 * prototype all functions
68 * Revision 2.1 2003/01/08 15:50:53 matthew
69 * applied debian patch
71 * Revision 2.0 2003/01/08 15:29:51 matthew
72 * versions collected from the net
74 * Revision 1.19 93/04/26 11:17:27 11:17:27 chip (Chip Chapin)
76 * Public release of portable datafile version.
78 * Revision 1.18 93/04/23 13:07:58 13:07:58 chip (Chip Chapin)
80 * This version supports portable data files, usable on machines with
81 * differing native byte-orders.
82 * Also, this version compiles and runs on non-HPUX systems. It has been
83 * tested on SunOS 4.? and ULTRIX 4.?, using SPARC and DEC 3100 hardware
84 * respectively. Note that the data file format has rolled again.
86 * Revision 1.17 93/01/05 19:03:13 19:03:13 chip (Chip Chapin)
87 * Release 3.00: (not for distribution)
88 * Fixed errors (blank lines) in bible.data file. Data file is not compatible
89 * with previous (1.x and 2.x) distributions. Further changes pending.
90 * Rewrote context handling, and added "<" and ">" commands.
91 * Tools for building brl-index are now part of release.
93 * Revision 1.16 93/01/05 11:31:34 11:31:34 chip (Chip Chapin)
94 * Release 2.2c: Minor tweaks.
96 * Revision 1.15 93/01/05 11:19:02 11:19:02 chip (Chip Chapin)
97 * Release 2.2b: Another cmd fix.
99 * Revision 1.14 93/01/05 11:02:01 11:02:01 chip (Chip Chapin)
100 * Release 2.2a: Fix command bug.
102 * Revision 1.13 93/01/05 10:49:07 10:49:07 chip (Chip Chapin)
103 * Release 2.2, Added ?w command and line formatting to ?l output.
105 * Revision 1.12 93/01/04 16:20:55 16:20:55 chip (Chip Chapin)
106 * Release 2.1, implements ?in and ?or commands.
108 * Revision 1.11 92/12/24 11:09:11 11:09:11 chip (Chip Chapin)
109 * Release 2.04. Include verse ref in prompt line.
111 * Revision 1.10 92/12/23 14:10:14 14:10:14 chip (Chip Chapin)
112 * Release 2.03: minor tweaks and bug fixes.
114 * Revision 1.9 92/12/22 18:17:04 18:17:04 chip (Chip Chapin)
115 * Minor tweaks for release 2.02.
117 * Revision 1.8 92/12/22 11:28:30 11:28:30 chip (Chip Chapin)
118 * Minor release 2.01 -- fix a couple of bugs.
120 * Revision 1.7 92/12/21 20:00:45 20:00:45 chip (Chip Chapin)
121 * Release 2.0. This release adds the concordance, and some small fixes.
123 * Revision 1.6 89/10/02 22:19:55 22:19:55 chip (Chip Chapin)
124 * Fix bug in processing "-l 2peter" sorts of things.
126 * Revision 1.5 89/10/02 14:24:42 14:24:42 chip (Chip Chapin)
127 * Revised usage text.
129 * Revision 1.4 89/09/14 20:33:35 20:33:35 chip (Chip Chapin)
130 * Release 1-2. Supports -f and -l options for formatting the output.
131 * Updates primarily brl.c, bible.c, and bible.1.
133 * Revision 1.3 89/09/13 21:48:26 21:48:26 chip (Chip Chapin)
134 * Implement -f and -l options for pretty-printing and linewidth limitation.
136 * Revision 1.2 89/09/08 09:00:26 09:00:26 chip (Chip Chapin)
137 * Bug fix and simplification: send whole input lines or arguments to BRL,
138 * and let BRL worry about multiple references. We don't care.
140 * Revision 1.1 89/09/05 17:47:27 17:47:27 chip (Chip Chapin)
146 /*----------------------------------------------------------------------
151 | Reads verse specs from the command line or from stdin and
152 | writes Bible verses to stdout. Uses the Bible Retrieval
153 | Library for all text access functions.
159 | 890121 cc Initial Creation
160 | 890824 cc Updated to use new brl_verse_text.
161 | 890829 cc Updated to think about buffer size.
162 | 921221 cc See Revision list above for further history...
164 \*----------------------------------------------------------------------*/
170 #include <readline/readline.h>
171 #include <readline/history.h>
177 char help_text[]="\n\
178 -Bible verse specifications:\n\
179 Verses may be specified using various standard abbreviations and \n\
180 notations, including both single verses and verse ranges.\n\
181 E.g. Jn3:16, jn3:16,17 ps1:1-6\n\
182 Partial specs are interpreted in the context of the previous verse.\n\
183 E.g. \"Rev3:20\" followed by \"15\" prints Rev3:15.\n\
184 -Concordance (word search) commands:\n\
185 ??word Find all verses containing \"word\".\n\
186 Creates a \"ref list\" for subsequent use.\n\
187 ?list List the references in ref list. (abbrev ?l)\n\
188 ?view View text of verses in ref list. (abbrev ?v)\n\
189 ?and word Combine ref list w/MATCHING refs for \"word\". (abbrev ?a)\n\
190 ?or word Combine ref list w/ALL refs for \"word\". (abbrev ?o)\n\
191 ?in <verse range> Limit ref list to range of verses.\n\
192 ?in all Reset ref list limit.\n\
193 To get a list of refs, each containing multiple words, start with:\n\
194 ??word for the first word, followed by\n\
195 ?and word for each following word.The order of the words doesn't matter.\n\
196 -A few miscellaneous program control commands.\n\
197 ?, ?h, ?help -- Prints this help text.\n\
198 <, > -- Change direction through text.\n\
199 ?w file -- Begin writing (appending) output to \"file\".\n\
200 ?w -- Stop writing output to a file.\n\
201 ?f -- Toggles output formatting modes.\n\
202 q, ?bye, ?exit, ?quit, ?q -- End this program.\n\
203 Note that a blank line will advance one verse in current direction.\n\
208 int do_concordance(char *word,ref_t *buf )
209 /*----------------------------------------------------------------------
214 | Utility/wrapper function for tsl_scan_concordance.
215 | Prints results of search. Called from all concordance
219 | 930104 cc Initial creation.
221 \*----------------------------------------------------------------------*/
225 char range_str[VSPECSZ];
226 char vref1[REFSZ], vref2[REFSZ];
228 printf( " Searching for '%s'...", word );
230 fprintf( outf, " Searching for '%s'...", word );
234 sprintf( range_str, " in %s-%s",
235 brl_num_to_ref(vref1, &inrange_start),
236 brl_num_to_ref(vref2, &inrange_end) );
241 if ((cnt=tsl_scan_concordance( word, buf, inrange_start, inrange_end )) == 0) {
242 printf( " not found%s.\n", range_str );
244 fprintf( outf, " not found%s.\n", range_str );
246 if (cnt == 1) ref_word = "ref";
247 else ref_word = "refs";
248 printf( " [%d %s%s]\n", cnt, ref_word, range_str );
250 fprintf( outf, " [%d %s%s]\n", cnt, ref_word, range_str );
253 } /* do_concordance */
257 void cmd_ANDconcordance(char *word)
258 /*----------------------------------------------------------------------
263 | Look up a word in the concordance, if found, combine ref list
264 | with current ref list using logical AND.
267 | 921218 cc Initial creation.
269 \*----------------------------------------------------------------------*/
273 ref_t sbuf[SELECTSZ]; /* List of selected verses */
274 ref_t tbuf[SELECTSZ]; /* temp buff of selected verses */
276 if (select_count < 1) {
277 fprintf( stderr, "No references. Use '??word'.\n" );
281 fprintf( stderr, "To AND-search for a word use '?and word'\n" );
285 if ((cnt = do_concordance( word, sbuf )) == 0) return;
287 /* AND with existing list */
289 while ((i < select_count) && (j < cnt)) {
290 if (selectbuf[i] == sbuf[j]) {
291 tbuf[k++] = sbuf[j++];
294 else if (selectbuf[i] > sbuf[j]) j++;
295 else if (selectbuf[i] < sbuf[j]) i++;
298 /* Update global list */
300 for (i=0; i<cnt; i++) selectbuf[i] = tbuf[i];
301 printf( " [%d refs in combined list]\n", select_count );
303 fprintf( outf, " [%d refs in combined list]\n", select_count );
306 /* Go ahead and display the refs */
308 } /* cmd_ANDconcordance */
312 void cmd_ORconcordance(char *word)
313 /*----------------------------------------------------------------------
318 | Look up a word in the concordance, if found, combine ref list
319 | with current ref list using logical OR.
322 | 930104 cc Initial creation.
324 \*----------------------------------------------------------------------*/
328 ref_t sbuf[SELECTSZ]; /* List of selected verses */
329 ref_t tbuf[SELECTSZ]; /* temp buff of selected verses */
332 fprintf( stderr, "To OR-search for a word use '?OR word'\n" );
336 if ((cnt = do_concordance( word, sbuf )) == 0) return;
338 /* OR with existing list (i.e. merge the lists) */
340 while ((i < select_count) && (j < cnt)) {
341 if (selectbuf[i] < sbuf[j]) {
342 tbuf[k++] = selectbuf[i++];
343 } else if (selectbuf[i] == sbuf[j]) {
344 tbuf[k++] = selectbuf[i++];
346 } else if (selectbuf[i] > sbuf[j]) {
347 tbuf[k++] = sbuf[j++];
350 /* One of the lists probably has remaining elements.
351 Only ONE of the following loops will execute.
353 while (i < select_count) {
354 tbuf[k++] = selectbuf[i++];
357 tbuf[k++] = sbuf[j++];
360 /* Update global list */
362 for (i=0; i<select_count; i++) selectbuf[i] = tbuf[i];
363 printf( " [%d refs in combined list]\n", select_count );
365 fprintf( outf, " [%d refs in combined list]\n", select_count );
368 /* Go ahead and display the refs */
370 } /* cmd_ORconcordance */
374 void cmd_concordance(char *word)
375 /*----------------------------------------------------------------------
380 | Look up a word in the concordance.
383 | 921217 cc Initial creation.
385 \*----------------------------------------------------------------------*/
388 fprintf( stderr, "To search for a word type '??word'\n" );
392 select_count = do_concordance( word, selectbuf );
395 /* Go ahead and display the refs */
397 } /* cmd_concordance */
402 /*----------------------------------------------------------------------
407 | Print Help message for this program.
410 | 921217 cc Initial creation.
411 | 921223 cc Added release_version.
413 \*----------------------------------------------------------------------*/
416 printf( "%s: %s\n", myname, release_version );
417 printf( "%s", help_text );
419 fprintf( outf, "%s: %s\n", myname, release_version );
420 fprintf( outf, "%s", help_text );
427 void cmd_inrange(char *range)
428 /*----------------------------------------------------------------------
433 | Limit concordance ref list to a certain verse range. The
434 | limit range will be applied immediately to modify the
435 | current ref list (if any), and will apply to all
436 | subsequent searches.
438 | If the specified verse range is "all", then the limits are
442 | 930104 cc Initial creation.
444 \*----------------------------------------------------------------------*/
446 ref_t start; /* starting verse */
447 int count; /* number of verses */
448 ref_t tbuf[SELECTSZ]; /* temp buffer */
450 char vref1[REFSZ], vref2[REFSZ];
452 if (strcmp(range, "all") == 0) {
454 inrange_start = inrange_end = 0;
457 /*Assignment used as truth value*/
458 if ((start = brl_verse_spec( &range, &count ))) {
459 inrange_start = start;
460 inrange_end = start + count -1;
463 /* Edit current ref list */
464 for (count=i=0; i < select_count; i++) {
465 if (selectbuf[i] > inrange_end) break;
466 if (inrange_start <= selectbuf[i]) tbuf[count++]=selectbuf[i];
468 /* Update global list */
469 select_count = count;
470 for (i=0; i < count; i++) selectbuf[i] = tbuf[i];
471 printf( " [%d refs in range %s-%s]\n", select_count,
472 brl_num_to_ref(vref1, &inrange_start),
473 brl_num_to_ref(vref2, &inrange_end) );
475 fprintf( outf, " [%d refs in range %s-%s]\n", select_count,
476 brl_num_to_ref(vref1, &inrange_start),
477 brl_num_to_ref(vref2, &inrange_end) );
480 printf( " [range is %s-%s]\n",
481 brl_num_to_ref(vref1, &inrange_start),
482 brl_num_to_ref(vref2, &inrange_end) );
484 fprintf( outf, " [range is %s-%s]\n",
485 brl_num_to_ref(vref1, &inrange_start),
486 brl_num_to_ref(vref2, &inrange_end) );
495 /*----------------------------------------------------------------------
500 | List references found in previous search.
501 | List is formatted using line_width.
504 | 921217 cc Initial creation.
505 | 930105 cc Format output into lines.
507 \*----------------------------------------------------------------------*/
510 char vref[REFSZ]; /* verse ref buffer */
512 char lbuf[LINESZ]; /* line buffer */
513 int lcnt; /* count of chars in line */
516 if (select_count < 1) {
517 printf( "No references. Use '??word' first.\n" );
520 sprintf( lbuf, " References [%d]: ", select_count );
521 /* Support non-POSIX sprintf */
524 for (cnt=0; cnt < select_count; cnt++) {
525 brl_num_to_ref(vref, &selectbuf[cnt]);
527 if ((lcnt + i +1)> line_width) {
533 lbuf[0] = '\0'; lcnt = 0;
538 strcat( lbuf, vref );
550 void cmd_pretty_print(int verbose)
551 /*----------------------------------------------------------------------
556 | Toggle pretty-printing modes
559 | 921217 cc Initial creation.
561 \*----------------------------------------------------------------------*/
565 /*invert the pretty_printing setting*/
566 pretty_printing=pretty_printing ? FALSE : TRUE;
568 if (pretty_printing) {
569 if (line_width == 0) {
571 This forces pretty_printing to be done with a
572 restricted line width. If somebody doesn't like that,
573 they can use "-l999" or something.
575 if ((s=getenv("COLUMNS")) == NULL)
576 line_width = 79; /* Take a guess. Oh well */
578 line_width = atoi(s) -1;
579 if (line_width > LINESZ) line_width = LINESZ -1;
583 /* If pretty_printing is being turned off, they probably don't
584 want line breaks either */
588 printf( "Output formatting %s\n", pretty_printing?"ON":"OFF" );
590 fprintf( outf, "Output formatting %s\n", pretty_printing?"ON":"OFF" );
592 } /* cmd_pretty_print */
597 /*----------------------------------------------------------------------
602 | View full text of refs found in previous search.
605 | 921217 cc Initial creation.
607 \*----------------------------------------------------------------------*/
613 if (select_count < 1) {
614 fprintf( stderr, "No references. Use '??word' first.\n" );
617 printf( "Viewing References [%d]: \n", select_count );
619 fprintf( outf, "Viewing References [%d]: \n", select_count );
621 for (cnt=0; cnt < select_count; cnt++) {
622 /* Print refs without updating current context */
623 brl_num_to_ref( vref, &selectbuf[cnt] );
624 brl_printverse( vref, pretty_printing, line_width, outf );
630 void cmd_write(char *fname)
631 /*----------------------------------------------------------------------
636 | Begin writing a copy of program output to a file. If we
637 | are already writing to a file, then close it, and open a
638 | new one. The file is opened in "append" mode.
640 | fname -- String with name of file.
642 | If fname is null then close current file (if any) and
646 | 930105 cc Initial creation.
648 \*----------------------------------------------------------------------*/
653 printf( "%s: Output file closed.\n", myname );
656 if ((outf = fopen( fname, "a" )) == NULL) {
657 fprintf( stderr, "%s: Cannot append to file '%s'\n",
660 printf( "%s: Writing to %s.\n", myname, fname );
666 void do_command(char *cmd)
667 /*----------------------------------------------------------------------
672 | Handle a control command.
673 | For now, all control commands begin with "?".
676 | 921217 cc Initial creation
678 \*----------------------------------------------------------------------*/
684 /* Convert to lower case */
685 for (p=cmd; *p; p++) {
686 if (isupper((int)*p)) *p =tolower((int)*p);
688 n=sscanf(cmd, "?%s", w);
692 (strcmp(w, "") == 0) ||
693 (strcmp(w, "h") == 0) ||
694 (strcmp(w, "help") == 0))
697 } else if (*w == '?') {
698 /* Concordance (word search) */
700 /* Support "?? word" (with space) */
701 w[0] = '\0'; /* ensure correctness for plain "??" */
703 n=sscanf(p, "%s", w);
704 cmd_concordance( w );
706 cmd_concordance( w+1 );
708 } else if ((strcmp(w, "a") == 0) ||
709 (strcmp(w, "and") == 0)) {
710 /* "and" word search */
711 p = cmd + strlen(w) +1;
712 n=sscanf(p, "%s", w);
713 cmd_ANDconcordance( w );
714 } else if ((strcmp(w, "f") == 0)) {
715 /* Toggle pretty-print modes */
716 cmd_pretty_print(TRUE);
717 } else if (strcmp(w, "in") == 0) {
718 /* IN -- limit ref list to a verse range */
719 p = cmd + strlen(w) +1;
720 n=sscanf(p, "%s", w);
722 } else if ((strcmp(w, "l") == 0) ||
723 (strcmp(w, "list") == 0)) {
724 /* LIST refs from previous search */
726 } else if ((strcmp(w, "o") == 0) ||
727 (strcmp(w, "or") == 0)) {
728 /* "or" word search */
729 p = cmd + strlen(w) +1;
730 n=sscanf(p, "%s", w);
731 cmd_ORconcordance( w );
732 } else if ((strcmp(w, "v") == 0) ||
733 (strcmp(w, "view") == 0)) {
734 /* VIEW text of refs from previous search */
736 } else if (*w == 'w') {
737 /* WRITE to a file */
739 /* Support "?w file" (with space) */
740 w[0] = '\0'; /* ensure correctness for plain "?w" */
742 n=sscanf(p, "%s", w);
745 /* Support "?wfile" (no space) */
748 } else if ((strcmp(w, "bye") == 0) ||
749 (strcmp(w, "exit") == 0) ||
750 (strcmp(w, "q") == 0) ||
751 (strcmp(w, "quit") == 0)) {
757 fprintf( stderr, "%s: Unrecognized command '%s'\n", myname, w);
764 void user_input(char *cmd)
765 /*----------------------------------------------------------------------
770 | Process a user command.
772 | 1) A Bible verse spec, e.g. "Jn3:16-18", or even "3"
773 | (context sensitive).
774 | 2) A control command, e.g. "?"
777 | 921217 cc Initial creation.
779 \*----------------------------------------------------------------------*/
785 /* Is it a control command?
786 For now, all control commands start with "?". */
788 /* Control Command */
790 } else if (*cmd == '>' || *cmd == '<' || *cmd == '\0') {
791 if (*cmd == '>') skip_inc = 1;
792 if (*cmd == '<') skip_inc = -1;
794 /* Print next verse and update context. */
795 brl_cur_vnum += skip_inc;
796 brl_printverse( brl_num_to_ref(vs, &brl_cur_vnum),
797 pretty_printing, line_width, outf );
800 Print it and update context.
802 brl_cur_vnum = brl_printverse( cmd, pretty_printing, line_width, outf );
808 char *getprompt(void)
809 /*----------------------------------------------------------------------
814 | Get prompt for interactive user.
817 | 921224 cc Initial creation.
818 | 020707 dm Change prompter to getprompt for readline.
820 \*----------------------------------------------------------------------*/
824 static char promptbuf[LINESZ];
826 sprintf(promptbuf, "%s(%s) [%s]%s ", myname,
827 brl_textname, brl_num_to_ref(vbuf, &brl_cur_vnum),
828 (skip_inc > 0 ? ">" : "<") );
835 /*----------------------------------------------------------------------
840 | Print usage message to stderr, then exit program.
844 | 890912 cc Added -f, -l.
845 | 891002 cc Tinkered with help text.
847 \*----------------------------------------------------------------------*/
850 fprintf( stderr, "Usage: %s [-f][-l[cols]][-m mem][-p path][-d file][<verse spec>...]\n",
852 fprintf( stderr, "\n\
853 -d file Override default datafile name\n\
854 -f Format the output (implies -l)\n\
855 -l[cols] Set line width (default value: COLUMNS env. variable)\n\
856 -m mem Specify maximum buffer memory usage\n\
857 in Kbytes. Defaults to 1024K.\n\
858 -p path Override default datafile search path.\n\
865 int main(int argc,char **argv)
866 /*----------------------------------------------------------------------
873 | Handle command line options.
874 | Initialize the Bible Retrieval Library.
875 | Read user commands from the command line or from stdin.
878 | 890830 cc Added options processing.
879 | 890908 cc Send whole lines to printverse instead of
880 | partially parsing them.
881 | 890912 cc Added -f, -l options.
883 \*----------------------------------------------------------------------*/
886 char *dfname, *dfpath, *s;
888 char def_verse[]="Gen1:1";
890 mem_limit = 1024; /* Default 1024K of buffer space */
891 dfname = dfpath = NULL; /* Use library's default values */
893 myname = s = *argv++; argc--; /* Program name */
895 if (*s == '/') myname = s+1;
899 cmd_pretty_print(FALSE); /* Kind of hokey -- this calls turns it on */
901 #define ARGVAL() (*++(*argv) || (--argc && *++argv))
902 for (;argc && **argv == '-'; argc--, argv++) {
903 /* Got an option flag */
905 /* Process all flags in this argument */
909 fprintf( stderr, "%s: -d Missing datafile-name\n", myname );
915 cmd_pretty_print(FALSE);
918 if (isdigit((int)*(*argv+1))) {
919 line_width = atoi(++(*argv));
920 if (line_width > LINESZ) line_width = LINESZ -1;
923 && isdigit((int)*(argv[1]))
924 && ((ch= *(argv[1]+1)) == '\0' || isdigit((int)ch))) {
925 line_width = atoi(*++argv);
926 if (line_width > LINESZ) line_width = LINESZ -1;
929 argc++; /* hack-alert! Fix error from above */
930 /* Set line width to COLUMNS-1. Avoids auto-newline. */
931 if ((s=getenv("COLUMNS")) == NULL)
932 line_width = 79; /* Take a guess. Oh well */
934 line_width = atoi(s) -1;
935 if (line_width > LINESZ) line_width = LINESZ -1;
940 if (!ARGVAL() || !isdigit((int)**argv)) {
941 fprintf(stderr, "%s: -m Missing memory-limit\n", myname);
944 mem_limit = atoi(*argv);
948 fprintf( stderr, "%s: -p Missing path-list\n", myname );
954 fprintf(stderr, "%s: Unknown flag: '%c'\n", myname, **argv);
961 brl_init( dfname, dfpath, mem_limit ); /* Initialize Bible Retrieval Lib */
964 /* read from command line */
967 user_input( *argv++ );
970 /* read from stdin */
971 printf( "%s: %s\n", myname, release_version );
972 printf( "Hit '?' for help.\n" );
973 rl_bind_key('\t', rl_insert);
974 brl_printverse( def_verse, pretty_printing, line_width, outf );
975 while((line = readline(getprompt())) != NULL) {
977 if (*line != '\0') add_history(line);