home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume9 / bibtools < prev    next >
Text File  |  1989-12-04  |  181KB  |  7,233 lines

  1. Newsgroups: comp.sources.misc
  2. From: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  3. Reply-To: <kannan@osc.edu>
  4. Subject: v09i046: bibtools:  tools for BibTeX
  5. Sender: kannan@osc.edu
  6.  
  7. Posting-number: Volume 9, Issue 46
  8. Submitted-by: kannan@osc.edu (Kannan Varadhan)
  9. Archive-name: bibtools
  10.  
  11. I have written out what I think are fairly decent and comprehensive set
  12. of tools for manipulating BibTeX style bibliographies that I would like
  13. to have distributed via 'comp.sources.misc'.  With this intent in mind,
  14. I am sending you this shar file.
  15.  
  16. Briefly, the tools that I have are...
  17.  
  18.     bibc -  This is a tool for creating and appending bibliography
  19.         records to a file.  This program works by prompting the
  20.         user for the required fields, and then writes
  21.         out/appends the record in the correct format.
  22.  
  23.     bibv -  This tool takes one or more bib files, and produces a
  24.         sample file, called bibtex.tex, and a dvi version of
  25.         the same, that contain an entry corresponding to every
  26.         record in the files.  This uses bibtex to flag
  27.         duplicate entries, hence, the name BIB-Verifier.
  28.  
  29.     shbib - This is used to show complete entries matching
  30.         a given regular expression.  The syntax is somewhat
  31.         similar to egrep.
  32.  
  33.     rmbib - This removes entries matching the given regular
  34.         expression from the specified files.  It is useful, in
  35.         that, the delete records are written to stdout, so one
  36.         can shuffle records around various bib-files.
  37.  
  38. You will also find, a library of tools that I designed, for breaking up
  39. entries in set of specified bibliography files, and having each entry
  40. processed by a routine of the user's choice.  Notes on these can be found
  41. in README.lib_bib.
  42.  
  43. The manpages have more detailed information.
  44.  
  45. Installation requires one to have Henry Spencer's regular expression
  46. package, and Flex.
  47.  
  48. #--------------------------------------------------------------------------
  49. # to unpack the routine(s) in this package, remove everything
  50. # above the dotted line and say, `sh filename'
  51. # If any of the routines already exists, say, `sh -o filename'
  52. #    Makefile README README.lib_bib TODO alpha.lex bibc.c bibc.h bibcent.c
  53. #    bibcent.h bibl.l bibtools.man bibv.c bibv.h config.h foo.bib
  54. #    gen_lex_file header includes.h inits.c lex.yy.c lexstrings.lex
  55. #    lib_bib.c misc/ omega.lex pyr.regexp.a specl.bst strings.h sun.regexp.a
  56. #    templates.c typescript misc/Changes misc/README misc/bibv.sh
  57. #    misc/gets.c
  58. if [ ! -d . ] ; then
  59.     echo -n Directory . not found. Creating....
  60.     mkdir .
  61.     if [ ! -d . ] ; then
  62.         echo ...failed
  63.         echo unable to create directory ..  Please create the directory and try again
  64.         exit
  65.     fi
  66.     echo ...done
  67. fi
  68. echo -n "Makefile..." 1>&2
  69. if test -f Makefile
  70. then
  71.     case $# in 
  72.     0)
  73.         echo 'exists, `sh filename -o'\'' to overwrite'
  74.         exit 0;;
  75.     esac
  76.     case $1 in 
  77.     -o)    ;;
  78.     *)
  79.         echo 'exists, `sh filename -o'\'' to overwrite'
  80.         exit 0;;
  81.     esac
  82. fi
  83. sed 's/^X//' << 'EOFile Makefile' > Makefile
  84. X.SUFFIXES:    .out .o .c .l .lex
  85. X
  86. X# The ARCH defines the type of architecture we are using to install
  87. X# these tools.  This is essentially only to figure out the final BINDEST
  88. X# INCDIR defines the location of the regexp includes.
  89. X# RELIB defines the location of the regular expression library
  90. X# MANTYPE defines the location of the man pages, as manl/bibtools.l
  91. X# TEXLIB is the location to put specl.bst, the bibtex macro file
  92. XARCH=pyr
  93. XCFLAGS=-O
  94. XINCDIR=-I../Regexp
  95. XRELIB=$(ARCH).regexp.a
  96. XBINDEST=/n/shell/0/kannan/bin/${ARCH}/
  97. XMANTYPE=l
  98. XMANDEST=/n/shell/0/kannan/man/man$(MANTYPE)
  99. XTEXLIB=/n/shell/0/kannan/Bib/
  100. X
  101. XCCFLAGS=${CFLAGS} ${INCDIR}
  102. XINCLUDES=includes.h config.h strings.h
  103. X
  104. Xall:    bibc shbib rmbib bibv
  105. X    @echo Fee Fi Fo Fum
  106. X
  107. Xbibc:    bibc.o lex.yy.o inits.o templates.o lib_bib.o
  108. X    cc ${CFLAGS} bibc.o lex.yy.o inits.o templates.o lib_bib.o $(RELIB) -o $@
  109. X
  110. Xshbib:    shbib.o lib_bib.o
  111. X    cc ${CFLAGS} shbib.o lib_bib.o $(RELIB) -o $@
  112. X
  113. Xrmbib:    rmbib.o lib_bib.o
  114. X    cc ${CFLAGS} rmbib.o lib_bib.o $(RELIB) -o $@
  115. X
  116. Xbibv:    bibv.o lib_bib.o
  117. X    cc ${CFLAGS} bibv.o lib_bib.o $(RELIB) -o $@
  118. X
  119. Xbibc.o:        bibc.c $(INCLUDES) bibc.h
  120. X    cc -c ${CCFLAGS} bibc.c
  121. X
  122. Xinits.o:    inits.c $(INCLUDES) bibc.h
  123. X    cc -c ${CCFLAGS} inits.c
  124. X
  125. Xtemplates.o:    templates.c $(INCLUDES) bibc.h
  126. X    cc -c ${CCFLAGS} templates.c
  127. X
  128. Xlex.yy.o:    lex.yy.c $(INCLUDES)
  129. X    cc -c ${CCFLAGS} lex.yy.c
  130. X
  131. Xlex.yy.c:    bibl.l $(INCLUDES)
  132. X    flex -I bibl.l
  133. X
  134. Xbibl.l:        alpha.lex lexstrings.lex omega.lex
  135. X    gen_lex_file alpha.lex lexstrings.lex omega.lex > bibl.l
  136. X
  137. Xshbib.o: bibcent.c $(INCLUDES) bibcent.h
  138. X    cc -c -DSHBIB ${CCFLAGS} bibcent.c
  139. X    mv bibcent.o shbib.o
  140. X
  141. Xrmbib.o: bibcent.c $(INCLUDES) bibcent.h
  142. X    cc -c -DRMBIB ${CCFLAGS} bibcent.c
  143. X    mv bibcent.o rmbib.o
  144. X
  145. Xbibv.o:    bibv.c $(INCLUDES) bibv.h
  146. X    cc -c ${CCFLAGS} bibv.c
  147. X
  148. Xlib_bib.o:    lib_bib.c $(INCLUDES)
  149. X    cc -c ${CCFLAGS} lib_bib.c
  150. X
  151. Xinstall: all
  152. X    install -s bibc ${BINDEST}
  153. X    install -s bibv ${BINDEST}
  154. X    install -s shbib ${BINDEST}
  155. X    install -s rmbib ${BINDEST}
  156. X    install -c specl.bst ${TEXLIB}
  157. X    cp bibtools.man ${MANDEST}/bibtools.$(MANTYPE)
  158. X    ln ${MANDEST}/bibtools.$(MANTYPE) ${MANDEST}/bibc.$(MANTYPE)
  159. X    ln ${MANDEST}/bibtools.$(MANTYPE) ${MANDEST}/bibv.$(MANTYPE)
  160. X    ln ${MANDEST}/bibtools.$(MANTYPE) ${MANDEST}/shbib.$(MANTYPE)
  161. X    ln ${MANDEST}/bibtools.$(MANTYPE) ${MANDEST}/rmbib.$(MANTYPE)
  162. X
  163. Xclean:
  164. X    rm -f bibc bibv shbib rmbib core linterrs *.o
  165. X
  166. Xlint:
  167. X    lint $(INCDIR) bibc.c inits.c templates.c lib_bib.c lex.yy.c > linterrs
  168. X    lint $(INCDIR) -DSHBIB bibcent.c lib_bib.c >> linterrs
  169. X    lint $(INCDIR) -DRMBIB bibcent.c lib_bib.c >> linterrs
  170. X    lint $(INCDIR) bibv.c lib_bib.c >> linterrs
  171. X
  172. X#
  173. X# Debug and test makes.....
  174. X#
  175. Xdebug:
  176. X    make CFLAGS='-gx -DEBUG' ARCH=${ARCH} all
  177. X
  178. Xbackup:
  179. X    @rm -f core linterrs *.o
  180. X    (cd .. ; pack Bibcreate/* > bibc.shar)
  181. X
  182. Xmakes:
  183. X    sed 's/^ARCH=.*/ARCH=sun/' Makefile > makefile.sun
  184. X    sed 's/^ARCH=.*/ARCH=pyr/' Makefile > makefile.pyr
  185. EOFile Makefile
  186. chmod u=rw+,g=rw+,o=r++ Makefile
  187. echo '...done' 1>&2
  188. if [ ! -d . ] ; then
  189.     echo -n Directory . not found. Creating....
  190.     mkdir .
  191.     if [ ! -d . ] ; then
  192.         echo ...failed
  193.         echo unable to create directory ..  Please create the directory and try again
  194.         exit
  195.     fi
  196.     echo ...done
  197. fi
  198. echo -n "README..." 1>&2
  199. if test -f README
  200. then
  201.     case $# in 
  202.     0)
  203.         echo 'exists, `sh filename -o'\'' to overwrite'
  204.         exit 0;;
  205.     esac
  206.     case $1 in 
  207.     -o)    ;;
  208.     *)
  209.         echo 'exists, `sh filename -o'\'' to overwrite'
  210.         exit 0;;
  211.     esac
  212. fi
  213. sed 's/^X//' << 'EOFile README' > README
  214. XCopyright (c) 1989 Ohio State University
  215. XWritten by Kannan Varadhan.  Not derived from licensed software.
  216. X
  217. XPermission is granted to anyone to use this software for any purpose on
  218. Xany computer system, and to redistribute it freely, subject to the
  219. Xfollowing restrictions...
  220. X
  221. X    1. The author is not responsible for the consequences of use of
  222. X        this software, no matter how awful, even if they arise
  223. X        from defects in it.
  224. X
  225. X    2. The origin of this software must not be misrepresented, either
  226. X        by explicit claim or by omission.
  227. X
  228. X    3. Altered versions must be plainly marked as such, and must not
  229. X        be misrepresented as being the original software.
  230. X
  231. XInstalling bibc:
  232. X
  233. XBefore you start, you will need
  234. Xa) a regular expression package.  I prefer to use the one that Henry
  235. XSpenser wrote aeons ago.  This one is in the public domain.  A copy of
  236. Xit should be in the Regexp directory.  From this, we need regcomp(),
  237. Xregexec() and regerror().
  238. X
  239. XIf you wish to use some other regular expression package, you have to
  240. Xfigure out how your set of routines will compile the re, and then how it
  241. Xwill execute a string on the resulting automaton.  You can then change
  242. Xthe defines REGCOMP, REGEXEC, which are routine invokes, and REGEXP, the
  243. Xstruct, and change the includes for regexp.h in 'includes.h'.  Simple,
  244. Xisn't it? :-)
  245. X
  246. Xb) You will also need flex before you can make bibc though.  In case
  247. Xyou do not have access to flex, you could use the lex.yy.c with this
  248. Xcode, which has been generated with flex.
  249. X
  250. XBoth these packages have appeared on comp.sources.xxxxxxxx.
  251. X
  252. XNow edit Makefile, and config.h, and put in your various options.  There
  253. Xare adequate comments alongside the various parameters, so one should
  254. Xhave no problem here.
  255. X
  256. XIf you are on a system V machine, edit strings.h, and make sure all the
  257. Xdefinitions there are ok too.
  258. X
  259. Xmake, and make install should see you through.
  260. X
  261. XNote that bibv uses a specially hacked bst file, called specl.bst.  This
  262. Xstyle causes the bibitem keys to be the same as the \cite-keys that you
  263. Xhave used.  This is a convenient style for keeping hardcopies for ready
  264. Xreference, considering that these are sorted nicely and all that :)
  265. XIf you would like to have a copy of the btxbst.doc file, send me a note,
  266. Xand I'll send it to you....
  267. X
  268. XKANNAN        Sun Dec  3 02:08:19 EST 1989
  269. EOFile README
  270. chmod u=rw+,g=rw+,o=r++ README
  271. echo '...done' 1>&2
  272. if [ ! -d . ] ; then
  273.     echo -n Directory . not found. Creating....
  274.     mkdir .
  275.     if [ ! -d . ] ; then
  276.         echo ...failed
  277.         echo unable to create directory ..  Please create the directory and try again
  278.         exit
  279.     fi
  280.     echo ...done
  281. fi
  282. echo -n "README.lib_bib..." 1>&2
  283. if test -f README.lib_bib
  284. then
  285.     case $# in 
  286.     0)
  287.         echo 'exists, `sh filename -o'\'' to overwrite'
  288.         exit 0;;
  289.     esac
  290.     case $1 in 
  291.     -o)    ;;
  292.     *)
  293.         echo 'exists, `sh filename -o'\'' to overwrite'
  294.         exit 0;;
  295.     esac
  296. fi
  297. sed 's/^X//' << 'EOFile README.lib_bib' > README.lib_bib
  298. XThis is a detailed note on the kind of functions available as part of a
  299. Xlibrary for manipulating bib-files.    Hopefully, someone might find
  300. Xthis useful to write other tools to manipulate bibliographies in other
  301. Xways.
  302. X
  303. X-------------------------------------------------------------------------
  304. X
  305. Xchar    *
  306. Xmy_gets (buffer, size)
  307. X/*
  308. X * This is an emulation of gets() using fgets.3
  309. X * This routine reads everything upto a newline, using fgets.3
  310. X * 
  311. X * OUTPUT: Returns buffer on exit, (char *) NULL on error
  312. X * The contents of buffer are the input string, a max of (size -1)
  313. X * characters are filled on exit,
  314. X * The buffer is zeroed and returned on EOF.
  315. X *
  316. X * This routine only deals with EOF as an error cleanly.  On any other 
  317. X * error returned by fgets.3, this routine will return will return
  318. X * (char *) NULL and a partially filled buffer....*sigh*
  319. X *
  320. X * if EMUL_GETS is turned on, (it probably should, neh? :-) then
  321. X * it converts any trailing NEWLINE character ('\n') to a NIL ('\0')
  322. X * character, else, it leaves them alone
  323. X */
  324. Xchar    *buffer;
  325. Xint    size;
  326. X
  327. X-------------------------------------------------------------------------
  328. X
  329. Xanswer (string, resp)
  330. X/*
  331. X * Display string, query user....return TRUE if answer = resp
  332. X */
  333. Xchar    *string;
  334. Xchar    resp;
  335. X
  336. X-------------------------------------------------------------------------
  337. X
  338. Xprocess_bibfiles (files, process_recd, onerror)
  339. X/*
  340. X * For each file in files, 
  341. X *    delineate_next_record
  342. X *    process_record (file, record);
  343. X *        if process_record() indicates error,
  344. X *            onerror (open_file_descriptor);
  345. X *            lseek to EOF
  346. X *            cause exit()
  347. X *
  348. X * An argument of "-" as a filename, returns the filedescriptor 0,
  349. X * corresponding to stdin.
  350. X */
  351. Xchar    **files;
  352. Xint    (*process_recd)(), (*onerror)();
  353. X
  354. X-------------------------------------------------------------------------
  355. X
  356. Xget_next_file (curfd)
  357. X/*
  358. X * Close current file descriptor;
  359. X * get next bib file from bibflist
  360. X * open file, and return new file descriptor;
  361. X *
  362. X * An argument of "-" as a filename, returns the filedescriptor 0,
  363. X * corresponding to stdin.
  364. X */
  365. Xint    curfd;
  366. X
  367. X-------------------------------------------------------------------------
  368. X
  369. Xchar    *
  370. Xlcase (string)
  371. X/*
  372. X * Lower case the given string
  373. X */
  374. Xchar    *string;
  375. X
  376. X-------------------------------------------------------------------------
  377. X
  378. Xchar    *
  379. Xreplstr (str)
  380. X/*
  381. X * replicate the given string.  get storage, and return the new string.
  382. X */
  383. Xchar    *str;
  384. X
  385. X-------------------------------------------------------------------------
  386. X
  387. Xchar    *
  388. Xdelineate_recd (string)
  389. X/*
  390. X * Get next record, using '\n@' as a flag per record.
  391. X * Match all braces, 
  392. X * If record found, delineate current record by placing '\0' at end of
  393. X *    current record, and return address of next record.
  394. X * else return (char *) NULL;
  395. X */
  396. Xchar    *string;
  397. X
  398. X-------------------------------------------------------------------------
  399. X
  400. Xstrcount (str, c)
  401. X/*
  402. X * Count the number of occurences of character 'c' in string "str"
  403. X */
  404. Xchar    *str;
  405. Xchar    c;
  406. X
  407. X-------------------------------------------------------------------------
  408. X
  409. Xchar    *
  410. Xget_atsign (str)
  411. X/*
  412. X * Get an atsign, check if it is preceeded by a newline
  413. X *    If yes, return value,
  414. X *    else repeat search
  415. X */
  416. Xchar    *str;
  417. X
  418. X-------------------------------------------------------------------------
  419. X
  420. XREGEXP    *
  421. Xmy_rcomp (re)
  422. X/*
  423. X * STRATEGY: lcase the string inplace, and feed to regcomp(), return the
  424. X * value returned as is...
  425. X */
  426. Xchar    *re;
  427. X
  428. X{ return regcomp (lcase (re)); }
  429. X
  430. X-------------------------------------------------------------------------
  431. X
  432. Xmy_rexec (prog, str)
  433. Xregexp    *prog;
  434. X/*
  435. X * my_rexec = TRUE, if lcase (copy of str) contains given re
  436. X *        = FALSE otherwise.
  437. X */
  438. Xchar    *str;
  439. X
  440. EOFile README.lib_bib
  441. chmod u=rw+,g=r++,o=r++ README.lib_bib
  442. echo '...done' 1>&2
  443. if [ ! -d . ] ; then
  444.     echo -n Directory . not found. Creating....
  445.     mkdir .
  446.     if [ ! -d . ] ; then
  447.         echo ...failed
  448.         echo unable to create directory ..  Please create the directory and try again
  449.         exit
  450.     fi
  451.     echo ...done
  452. fi
  453. echo -n "TODO..." 1>&2
  454. if test -f TODO
  455. then
  456.     case $# in 
  457.     0)
  458.         echo 'exists, `sh filename -o'\'' to overwrite'
  459.         exit 0;;
  460.     esac
  461.     case $1 in 
  462.     -o)    ;;
  463.     *)
  464.         echo 'exists, `sh filename -o'\'' to overwrite'
  465.         exit 0;;
  466.     esac
  467. fi
  468. sed 's/^X//' << 'EOFile TODO' > TODO
  469. Xerror handling in abrupt departures        bibc
  470. X    handled some of it...clean exit is still guaranteed, though
  471. X    some garbage (?) gets seen on the screen
  472. Xsignals                        all
  473. X    nyeah..considering the algorithm we are using for processing the
  474. X    files, this, unless I am shown otherwise, is not going to be
  475. X    really necessary!  Consider the algorithms in brief:
  476. X
  477. X    bibc:
  478. X        while ! EOF do
  479. X            get a record from user, 
  480. X            write out record,
  481. X            done
  482. X    bibv:    For each file do
  483. X          for each record in file do
  484. X            get cite key
  485. X            write into bibtex.tex
  486. X            store filename
  487. X            done
  488. X          done
  489. X        write out list of files,
  490. X        run latex, bibtex, latex, latex
  491. X
  492. X    shbib, rmbib:    for each file do
  493. X              for each record in file do
  494. X                match regexp against record
  495. X                if match, printout
  496. X                if no match, and remove specified,
  497. X                write record into file.bak
  498. X                done
  499. X              if file.bak exists rename file.bak as file
  500. X              done
  501. X
  502. X    Notice that the original file is never destroyed irrecoverably.
  503. Xcleaner handling of stdin            shbib and rmbib
  504. X    Question is, why? stdin can always be specified as "-"
  505. X    to shbib, rmbib and bibv.  With shbib and rmbib, a file "-.bak"
  506. X    will be created for stdin, which is "safe".
  507. Xstat the file before editing            bibc
  508. X    DONE
  509. Xmanual pages                    all
  510. X    Whatever, I guess
  511. XA README writeup on installation        all
  512. X    DONE
  513. XA writeup and comments for lib_bib.c        libbib
  514. X    DONE
  515. EOFile TODO
  516. chmod u=rw+,g=r++,o=r++ TODO
  517. echo '...done' 1>&2
  518. if [ ! -d . ] ; then
  519.     echo -n Directory . not found. Creating....
  520.     mkdir .
  521.     if [ ! -d . ] ; then
  522.         echo ...failed
  523.         echo unable to create directory ..  Please create the directory and try again
  524.         exit
  525.     fi
  526.     echo ...done
  527. fi
  528. echo -n "alpha.lex..." 1>&2
  529. if test -f alpha.lex
  530. then
  531.     case $# in 
  532.     0)
  533.         echo 'exists, `sh filename -o'\'' to overwrite'
  534.         exit 0;;
  535.     esac
  536.     case $1 in 
  537.     -o)    ;;
  538.     *)
  539.         echo 'exists, `sh filename -o'\'' to overwrite'
  540.         exit 0;;
  541.     esac
  542. fi
  543. sed 's/^X//' << 'EOFile alpha.lex' > alpha.lex
  544. X%{
  545. X
  546. X/*
  547. X * This program has been written by Kannan Varadhan.  You are welcome to
  548. X * use, copy, modify, or circulate as you please, provided you do not
  549. X * charge any fee for any of it, and you do not remove these header
  550. X * comments from any of these files.
  551. X *
  552. X *        -- kva    Mon Dec  4 11:26:37 EST 1989
  553. X */
  554. X
  555. X#include    "bibc.h"
  556. X#undef    YY_INPUT
  557. X#define    YY_INPUT(buf,reslt,msize)    my_input (buf, &reslt, msize)
  558. X
  559. Xmy_input (buf,reslt, size)
  560. Xchar    *buf;
  561. Xint    *reslt;
  562. Xint    size;
  563. X
  564. X{
  565. Xchar    inputln[80];
  566. X
  567. X    bzero (inputln, 80);
  568. X    if (! GETS (inputln, 80))
  569. X      Strcpy (buf, "EOF");
  570. X    else
  571. X      Strncpy (buf, inputln, size);
  572. X    Strcat (buf, "!");
  573. X#ifdef    FLEX_DEBUG
  574. X    Fprintf (stderr, "buf contains: %s\n", buf);
  575. X#endif
  576. X    return *reslt = strlen (buf);
  577. X}
  578. X
  579. X
  580. Xmy_yylex ()
  581. X
  582. X{
  583. X#define    PROMPTSTR            "\
  584. XWhat kind of record would you like to enter (one of the following)?\n\
  585. X    article        book        booklet        conference\n\
  586. X    inbook        incollection    inproceedings    manual\n\
  587. X    mastersthesis    msthesis    misc        phdthesis\n\
  588. X    proceedings    techreport    unpublished\n\
  589. Xor    EDIT        quit\n"
  590. X    
  591. X    Fprintf (stderr, PROMPTSTR);
  592. X    return yylex ();
  593. X}
  594. X
  595. X%}
  596. EOFile alpha.lex
  597. chmod u=rw+,g=r++,o=r++ alpha.lex
  598. echo '...done' 1>&2
  599. if [ ! -d . ] ; then
  600.     echo -n Directory . not found. Creating....
  601.     mkdir .
  602.     if [ ! -d . ] ; then
  603.         echo ...failed
  604.         echo unable to create directory ..  Please create the directory and try again
  605.         exit
  606.     fi
  607.     echo ...done
  608. fi
  609. echo -n "bibc.c..." 1>&2
  610. if test -f bibc.c
  611. then
  612.     case $# in 
  613.     0)
  614.         echo 'exists, `sh filename -o'\'' to overwrite'
  615.         exit 0;;
  616.     esac
  617.     case $1 in 
  618.     -o)    ;;
  619.     *)
  620.         echo 'exists, `sh filename -o'\'' to overwrite'
  621.         exit 0;;
  622.     esac
  623. fi
  624. sed 's/^X//' << 'EOFile bibc.c' > bibc.c
  625. X/*
  626. X * This program has been written by Kannan Varadhan.  You are welcome to
  627. X * use, copy, modify, or circulate as you please, provided you do not
  628. X * charge any fee for any of it, and you do not remove these header
  629. X * comments from any of these files.
  630. X *
  631. X *        -- kva    Mon Dec  4 11:26:37 EST 1989
  632. X */
  633. X
  634. X#define    GLOBALS
  635. X#include "bibc.h"
  636. X
  637. Xmain (argc, argv, envp)
  638. Xint    argc;
  639. Xchar    **argv, **envp;
  640. X
  641. X{
  642. Xint    retval;
  643. X
  644. X    retval = FLD_NULL;
  645. X
  646. X    (void) process_args (argc, argv);
  647. X    (void) initialise (&bibitem);
  648. X
  649. X    while (retval = my_yylex()) {
  650. X      switch (retval) {
  651. X        case FLD_ERROR:    Fprintf (stderr, "Uh oh! no no no\n");
  652. X                continue;
  653. X        case ARTICLE:    retval = get_article ();    break;
  654. X        case BOOK:        retval = get_book ();        break;
  655. X        case BOOKLET:    retval = get_booklet ();    break;
  656. X        case CONFERENCE:    retval = get_inproceedings ();    break;
  657. X        case INBOOK:    retval = get_inbook ();        break;
  658. X        case INCOLLECTION:    retval = get_incollection ();    break;
  659. X        case INPROCEEDINGS:    retval = get_inproceedings ();    break;
  660. X        case MANUAL:    retval = get_manual ();        break;
  661. X        case MASTERSTHESIS:    retval = get_mastersthesis ();    break;
  662. X        case MISC:        retval = get_misc ();        break;
  663. X        case PHDTHESIS:    retval = get_phdthesis ();    break;
  664. X        case PROCEEDINGS:    retval = get_proceedings ();    break;
  665. X        case TECHREPORT:    retval = get_techreport ();    break;
  666. X        case UNPUBLISHED:    retval = get_unpublished ();    break;
  667. X        case FLD_EDITOR:    retval = edit (outfile, _O_outfilename, envp); break;
  668. X        }
  669. X      if (retval != -1)
  670. X        (void) writeout (&bibitem, outfile);
  671. X      (void) resetall (&bibitem);
  672. X      }
  673. X    fclose (outfile);
  674. X    return 0;
  675. X}
  676. X
  677. Xwriteout (bi, outfile)
  678. Xbibrec    *bi;
  679. XFILE    *outfile;
  680. X
  681. X{
  682. X#define    PUT(VAR,REC)                            \
  683. X    if (ISSET (VAR,REC))                        \
  684. X      {                                \
  685. X      if (Index (ISVAL(VAR,REC), QUOTE_CHAR))            \
  686. X        { tmp1 = OPEN_BRACE; tmp2 = CLOSE_BRACE ; }            \
  687. X      else if (ISVAL(VAR,REC)[0] == '\\')                \
  688. X        {                                \
  689. X        tmp1 = tmp2 = ' ';                        \
  690. X        ISVAL(VAR,REC)[0] = ' ';                    \
  691. X        }                                \
  692. X      else                                \
  693. X        tmp1 = tmp2 = QUOTE_CHAR;                    \
  694. X      Sprintf (recordbuf, "%s ,\n\t%s = %c%s%c", recordbuf,        \
  695. X            (VAR)->REC.prompt, tmp1, ISVAL (VAR,REC), tmp2);\
  696. X      }
  697. Xchar    recordbuf[1024];
  698. Xchar    tmp1, tmp2;
  699. Xint    i;
  700. X
  701. X    Sprintf (recordbuf, "@%s { %s", ISVAL(bi, rectype), ISVAL (bi, citekey));
  702. X    PUT (bi, address);
  703. X    PUT (bi, annote);
  704. X    PUT (bi, author);
  705. X    PUT (bi, booktitle);
  706. X    PUT (bi, chapter);
  707. X    PUT (bi, edition);
  708. X    PUT (bi, editor);
  709. X    PUT (bi, howpublished);
  710. X    PUT (bi, institution);
  711. X    PUT (bi, journal);
  712. X    PUT (bi, key);
  713. X    PUT (bi, month);
  714. X    PUT (bi, note);
  715. X    PUT (bi, number);
  716. X    PUT (bi, organisation);
  717. X    PUT (bi, pages);
  718. X    PUT (bi, publisher);
  719. X    PUT (bi, school);
  720. X    PUT (bi, series);
  721. X    PUT (bi, title);
  722. X    PUT (bi, type);
  723. X    PUT (bi, volume);
  724. X    PUT (bi, year);
  725. X    PUT (bi, comment);
  726. X    for (i = 0; i != usr_defns_ctr; i++)
  727. X      PUT (bi, usr_defns[i]);
  728. X    Strcat (recordbuf, "\n\t}\n\n");
  729. X
  730. X    (void) write (2, " ", 1);
  731. X    if (_O_verbose)
  732. X      Fprintf (stderr, recordbuf);
  733. X    if (_O_verify)
  734. X      {
  735. X      if (answer ("Is this correct?", NO))
  736. X        return 0;
  737. X      }
  738. X    Fprintf (outfile, recordbuf);
  739. X    fflush (outfile);
  740. X    return 0;
  741. X}
  742. X
  743. X
  744. Xget_field (next_field, rectype, status)
  745. Xfield    *next_field;
  746. Xchar    *rectype;
  747. Xchar    status;
  748. X
  749. X{
  750. X#define    ERRORMSG1    \
  751. X    "ERROR: %s is a REQUIRED FIELD for %s. Let's try that again...sigh...\n"
  752. X#define ERRORMSG2    \
  753. X    "ERROR: Frankly my dear, I don't give a damn...\n"
  754. Xchar    inputline[512];
  755. Xchar    error;
  756. Xchar    secondtime = FALSE;
  757. X
  758. XRETRY:    Fprintf (stderr, "%s%s? ", next_field->prompt, 
  759. X        ((status == OPTIONAL)? " (optional)" : "" ));
  760. X    fflush (stderr);
  761. X    error = FALSE;
  762. X    bzero (inputline, 512);
  763. X    if (! GETS (inputline, 512))
  764. X      return -1;
  765. X    switch (inputline[0]) {
  766. X      case '\0':
  767. X        if ((status == REQUIRED) && _O_pester_usr)
  768. X          error = TRUE;
  769. X        else
  770. X          return 0;
  771. X        break;
  772. X      case '?':
  773. X        Fprintf (stderr, "%s\n", next_field->helpstring);
  774. X        goto RETRY;
  775. X      case 'x':
  776. X        if (! Strcmp(inputline, "xx"))
  777. X          {
  778. X          if (answer ("Abort?", YES))
  779. X            return -1;
  780. X          }
  781. X      case ' ':
  782. X        (void) clr_leading_blanks (inputline);
  783. X        if (Strlen(inputline) == 0)
  784. X          {
  785. X          if ((status == REQUIRED) && _O_pester_usr)
  786. X            error = TRUE;
  787. X          else
  788. X            return 0;
  789. X          }
  790. X        break;
  791. X      }
  792. X    if (error)
  793. X      {
  794. X      if (secondtime)
  795. X        {
  796. X        Fprintf (stderr, ERRORMSG2, next_field->prompt, rectype);
  797. X        return 0;
  798. X        }
  799. X      else
  800. X        {
  801. X        Fprintf (stderr, ERRORMSG1, next_field->prompt, rectype);
  802. X        secondtime = TRUE;
  803. X        goto RETRY;
  804. X        }
  805. X      }
  806. X    Strcpy (next_field->string, inputline);
  807. X    next_field->full = TRUE;
  808. X    return 0;
  809. X}
  810. X
  811. X
  812. Xedit (filep, editfile, envp)
  813. XFILE    *filep;
  814. Xchar    *editfile;
  815. Xchar    **envp;
  816. X
  817. X{
  818. XFILE    *freopen();
  819. Xchar    *EDITOR, *TEXEDIT, *getenv();
  820. Xchar    *string, *format_cmd();
  821. Xint    editorpid;
  822. Xint    statresult;
  823. Xstruct    stat    efile;
  824. X
  825. X    statresult = stat (editfile, &efile);
  826. X    if ((statresult == -1) || (efile.st_mode & S_IFREG != 1))
  827. X      {
  828. X      Fprintf (stderr, "Cannot edit file %s\n", editfile);
  829. X      return -1;
  830. X      }
  831. X    TEXEDIT = getenv ("TEXEDIT");
  832. X    if (! TEXEDIT)
  833. X      {
  834. X      EDITOR = getenv ("VISUAL");
  835. X      if (! EDITOR) EDITOR = getenv ("EDITOR");
  836. X      if (! EDITOR) EDITOR = DEFAULT_EDITOR;
  837. X      }
  838. X    else
  839. X      string = format_cmd (TEXEDIT, editfile);
  840. X
  841. X    fclose (filep);
  842. X    editorpid = fork();
  843. X    if (editorpid < 0)
  844. X      {
  845. X      perror ("Cannot fork Editor");
  846. X      exit (-2);
  847. X      }
  848. X    else if (editorpid == 0)    /* CHILD */
  849. X      {
  850. X      if (TEXEDIT)
  851. X        execle ("/bin/sh", "sh", "-c", string, (char *) NULL, envp);
  852. X      else
  853. X        execlp (EDITOR, EDITOR, editfile, (char *) NULL, envp);
  854. X      perror ("Cannot exec EDITOR, using DEFAULT_EDITOR");
  855. X      execlp (DEFAULT_EDITOR, DEFAULT_EDITOR, editfile, (char *) NULL, envp);
  856. X      perror ("Cannot exec DEFAULT_EDITOR, giving up");
  857. X      exit (-3);
  858. X      }
  859. X    else
  860. X      (void) wait ((union wait *) 0);
  861. X    filep = freopen (_O_outfilename, "a", filep);
  862. X    return -1 /* A wierd return code, indicating, print nothing..*/;
  863. X}
  864. X
  865. X
  866. Xclr_leading_blanks (string)
  867. Xchar    *string;
  868. X
  869. X{
  870. Xchar    *temp, buffer[512];
  871. X
  872. X    temp = string;
  873. X    while (*temp == ' ') temp++;
  874. X    Strcpy (buffer, temp);
  875. X    Strcpy (string, buffer);
  876. X    return 0;
  877. X}
  878. X
  879. X
  880. X
  881. Xchar    *
  882. Xformat_cmd (envstr, filename)
  883. Xchar    *envstr, *filename;
  884. X
  885. X{
  886. X/*
  887. X * The envstr is going to be the TEXEDIT environment string.
  888. X * The filename is going to be the name of the bibfile we are concerned with
  889. X * We assume that the format of the TEXEDIT string is going to be of the form
  890. X *    <editor name> [%d] %s
  891. X * The %d would be optional, and contain the displacement variable....
  892. X * Since we are appending to the end of the bibfile always, we would
  893. X * position the editor to the bottom of the file always.
  894. X * Strategy......
  895. X *    locate the first %, if the character spec after it is not d, 
  896. X *        ie, it is not %d, then assume it is <editor> %s %d
  897. X *    The %d is really unimportant then, see...
  898. X *    stuff the stuff in, and return the cmd string...
  899. X */
  900. Xint    lineno;
  901. XFILE    *temp, *fopen();
  902. Xchar    *strndx, buffer[100], cmdstr[100];
  903. X
  904. X    /* First find the size in terms of lines of filename    */
  905. X    temp = fopen (filename, "r"); lineno = 0;
  906. X    if (temp)
  907. X      {
  908. X      while (fgets (buffer, 100, temp)) lineno++;
  909. X      fclose (temp);
  910. X      lineno -= 10;        /* An arbitrary figure        */
  911. X      }
  912. X
  913. X    /* lineno = %d specs now...                */
  914. X    strndx = Index (envstr, '%');
  915. X    if (! strndx)
  916. X      Strcpy (cmdstr, envstr);
  917. X    else if (*++strndx == 'd')
  918. X      Sprintf (cmdstr, envstr, lineno, filename);
  919. X    else
  920. X      Sprintf (cmdstr, envstr, filename, lineno);
  921. X    return cmdstr;
  922. X}
  923. X
  924. EOFile bibc.c
  925. chmod u=rw+,g=r++,o=r++ bibc.c
  926. echo '...done' 1>&2
  927. if [ ! -d . ] ; then
  928.     echo -n Directory . not found. Creating....
  929.     mkdir .
  930.     if [ ! -d . ] ; then
  931.         echo ...failed
  932.         echo unable to create directory ..  Please create the directory and try again
  933.         exit
  934.     fi
  935.     echo ...done
  936. fi
  937. echo -n "bibc.h..." 1>&2
  938. if test -f bibc.h
  939. then
  940.     case $# in 
  941.     0)
  942.         echo 'exists, `sh filename -o'\'' to overwrite'
  943.         exit 0;;
  944.     esac
  945.     case $1 in 
  946.     -o)    ;;
  947.     *)
  948.         echo 'exists, `sh filename -o'\'' to overwrite'
  949.         exit 0;;
  950.     esac
  951. fi
  952. sed 's/^X//' << 'EOFile bibc.h' > bibc.h
  953. X/*
  954. X * This program has been written by Kannan Varadhan.  You are welcome to
  955. X * use, copy, modify, or circulate as you please, provided you do not
  956. X * charge any fee for any of it, and you do not remove these header
  957. X * comments from any of these files.
  958. X *
  959. X *        -- kva    Mon Dec  4 11:26:37 EST 1989
  960. X */
  961. X
  962. X#include    "includes.h"
  963. X
  964. X#define    OPTIONAL    FALSE
  965. X#define    REQUIRED    TRUE
  966. X
  967. X#define    FLD_ERROR        -1
  968. X#define    FLD_NULL    0x0000
  969. X#define    ARTICLE        0x0001
  970. X#define    BOOK        0x0002
  971. X#define    BOOKLET        0x0004
  972. X#define    CONFERENCE    0x0008
  973. X#define    INBOOK        0x0010
  974. X#define    INCOLLECTION    0x0020
  975. X#define    INPROCEEDINGS    0x0040
  976. X#define    MANUAL        0x0080
  977. X#define    MASTERSTHESIS    0x0100
  978. X#define    MISC        0x0200
  979. X#define    PHDTHESIS    0x0400
  980. X#define    PROCEEDINGS    0x0800
  981. X#define    TECHREPORT    0x1000
  982. X#define    UNPUBLISHED    0x2000
  983. X#define    FLD_EDITOR    0x4000
  984. X
  985. X#define    GET(VAR,FIELD,STATUS)            \
  986. X    if (get_field (&(VAR)->FIELD, ISVAL(VAR, rectype), STATUS) == -1)\
  987. X        return -1 
  988. X#define    SET(VAR,FIELD,VALUE)    {            \
  989. X        Strcpy ((VAR)->FIELD.string, VALUE);    \
  990. X        (VAR)->FIELD.full = TRUE;        \
  991. X        }
  992. X#define    RESET(VAR,FIELD)    {            \
  993. X        Strcpy ((VAR)->FIELD.string, "");    \
  994. X        (VAR)->FIELD.full = FALSE;        \
  995. X        }
  996. X#define    ISSET(VAR,FIELD)    (VAR)->FIELD.full
  997. X#define    ISVAL(VAR,FIELD)    (VAR)->FIELD.string
  998. X#define    ISHELP(VAR,FIELD)    (VAR)->FIELD.helpstring
  999. Xtypedef    struct    record    {
  1000. X    char    full    /* Actually holds a boolean place value    */;
  1001. X    char    string[391]    /* An even 32 words / field    */;
  1002. X    char    prompt[32];
  1003. X    char    helpstring[344]    /* Display if user is confused    */;
  1004. X    }    field;
  1005. X
  1006. Xtypedef    struct    biblio_record    {
  1007. X    field    rectype;
  1008. X    field    citekey;
  1009. X    field    address;
  1010. X    field    annote;
  1011. X    field    author;
  1012. X    field    booktitle;
  1013. X    field    chapter;
  1014. X    field    edition;
  1015. X    field    editor;
  1016. X    field    howpublished;
  1017. X    field    institution;
  1018. X    field    journal;
  1019. X    field    key;
  1020. X    field    month;
  1021. X    field    note;
  1022. X    field    number;
  1023. X    field    organisation;
  1024. X    field    pages;
  1025. X    field    publisher;
  1026. X    field    school;
  1027. X    field    series;
  1028. X    field    title;
  1029. X    field    type;
  1030. X    field    volume;
  1031. X    field    year;
  1032. X    field    comment;
  1033. X    field    cross_ref;
  1034. X    field    usr_defns[USR_DEFNS_MAX];
  1035. X    }    bibrec;
  1036. X
  1037. XDCL (char, _O_help, FALSE);
  1038. XDCL (char, _O_verify, FALSE);
  1039. XDCL (char, _O_verbose, TRUE);
  1040. XDCL (FILE, *outfile, stdout);
  1041. XDCL (char, _O_outfilename[50], "");
  1042. XDCL (char, _O_pester_usr, SAFE);
  1043. X
  1044. XDCLX (bibrec, bibitem);
  1045. XDCL (int, usr_defns_ctr, 0);
  1046. X
  1047. X
  1048. EOFile bibc.h
  1049. chmod u=rw+,g=r++,o=r++ bibc.h
  1050. echo '...done' 1>&2
  1051. if [ ! -d . ] ; then
  1052.     echo -n Directory . not found. Creating....
  1053.     mkdir .
  1054.     if [ ! -d . ] ; then
  1055.         echo ...failed
  1056.         echo unable to create directory ..  Please create the directory and try again
  1057.         exit
  1058.     fi
  1059.     echo ...done
  1060. fi
  1061. echo -n "bibcent.c..." 1>&2
  1062. if test -f bibcent.c
  1063. then
  1064.     case $# in 
  1065.     0)
  1066.         echo 'exists, `sh filename -o'\'' to overwrite'
  1067.         exit 0;;
  1068.     esac
  1069.     case $1 in 
  1070.     -o)    ;;
  1071.     *)
  1072.         echo 'exists, `sh filename -o'\'' to overwrite'
  1073.         exit 0;;
  1074.     esac
  1075. fi
  1076. sed 's/^X//' << 'EOFile bibcent.c' > bibcent.c
  1077. X/*
  1078. X * This program has been written by Kannan Varadhan.  You are welcome to
  1079. X * use, copy, modify, or circulate as you please, provided you do not
  1080. X * charge any fee for any of it, and you do not remove these header
  1081. X * comments from any of these files.
  1082. X *
  1083. X *        -- kva    Mon Dec  4 11:26:37 EST 1989
  1084. X */
  1085. X
  1086. X#define    GLOBALS
  1087. X#include "bibcent.h"
  1088. X
  1089. X#ifdef    SHBIB
  1090. X#undef    RMBIB        /* why? God alone knows    */
  1091. X#endif
  1092. X
  1093. X#ifdef    RMBIB
  1094. X#define    PROGSTR    "rmbib"
  1095. X#else
  1096. X#define    PROGSTR    "shbib"
  1097. X#endif
  1098. X
  1099. Xmain (argc, argv)
  1100. Xint    argc;
  1101. Xchar    *argv[];
  1102. X
  1103. X{
  1104. Xextern    int    process_record(), onerror_cleanup();
  1105. X
  1106. X    if (process_args (argc, argv) == -1)
  1107. X      return -1    /* EXIT */;
  1108. X    regprog = (REGEXP *) REGCOMP (_O_regexp);
  1109. X    
  1110. X    (void) process_bibfiles (_O_flist, process_record, onerror_cleanup);
  1111. X
  1112. X    (void) finish_up ();
  1113. X    return 0;
  1114. X}
  1115. X
  1116. X
  1117. Xfinish_up ()
  1118. X
  1119. X{
  1120. X    if (store.isfull)
  1121. X      (void) output_record (store.filename, store.bibentry);
  1122. X
  1123. X    if (_O_rem)
  1124. X      {
  1125. X      DASSERT (mytmpfile);
  1126. X      (void) restore_bakfile (_O_file, mytmpfile);
  1127. X      }
  1128. X    return 0;
  1129. X}
  1130. X
  1131. X
  1132. Xonerror_cleanup (rdfd)
  1133. Xint    rdfd;
  1134. X
  1135. X{
  1136. XFILE    *rdfp, *fdopen();
  1137. Xchar    buffer[100];
  1138. X
  1139. X    if (mytmpfile)
  1140. X      {
  1141. X      rdfp = fdopen (rdfd, "r");
  1142. X      while (fgets (buffer, sizeof(buffer), rdfp))
  1143. X        Fprintf (mytmpfile, buffer);
  1144. X      (void) restore_bakfile (_O_file, mytmpfile);
  1145. X      }
  1146. X
  1147. X    return 0;
  1148. X}
  1149. X
  1150. X
  1151. Xprocess_record (file, string)
  1152. Xchar    *file, *string;
  1153. X
  1154. X{
  1155. Xint    retcode = 0;
  1156. Xchar    tmpfn[20];
  1157. X
  1158. X    if (_O_file != file)
  1159. X      {
  1160. X      if (_O_rem)
  1161. X        {
  1162. X        (void) restore_bakfile (_O_file, mytmpfile);
  1163. X        Sprintf (tmpfn, "%s.bak", file);
  1164. X        mytmpfile = fopen (tmpfn, "w");
  1165. X        }
  1166. X      _O_file = file;
  1167. X      }
  1168. X
  1169. X    if (REGMATCH (regprog, string) != 1)
  1170. X      {
  1171. X      STASH (string);
  1172. X      retcode = 0;
  1173. X      }
  1174. X    else switch (_O_srch)
  1175. X      {
  1176. X      case FIRST_MATCH:
  1177. X        if (output_record (_O_file, string) == -1)
  1178. X          break /* record was not processed...return normally */;
  1179. X        retcode = -1;
  1180. X        break;
  1181. X      case LAST_MATCH:
  1182. X        if (store.isfull)
  1183. X          {
  1184. X          STASH (store.bibentry);
  1185. X          free (store.bibentry);
  1186. X          }
  1187. X        store.isfull = TRUE;
  1188. X        store.filename = _O_file;
  1189. X        store.bibentry = (char *) replstr (string);
  1190. X        break;
  1191. X      case GLOBAL_MATCH:
  1192. X        (void) output_record (_O_file, string);
  1193. X        break;
  1194. X      }
  1195. X    return retcode;
  1196. X}
  1197. X
  1198. X
  1199. Xprocess_args (argc, argv)
  1200. Xint    argc;
  1201. Xchar    *argv[];
  1202. X
  1203. X{
  1204. Xint    opt, count, i;
  1205. Xextern    char    *optarg;
  1206. Xextern    int    optind;
  1207. Xchar    **temp;
  1208. X
  1209. X    if (argc <= 1)
  1210. X      _O_help = TRUE;
  1211. X
  1212. X    while ((opt = getopt (argc, argv, "fghilrs")) != EOF)
  1213. X      switch (opt) {
  1214. X        case 'f':
  1215. X        _O_srch = FIRST_MATCH;
  1216. X        break;
  1217. X        case 'g':    
  1218. X        _O_srch = GLOBAL_MATCH;
  1219. X        break;
  1220. X        case 'l':
  1221. X        _O_srch = LAST_MATCH;
  1222. X        break;
  1223. X        case 'h':
  1224. X        _O_help = TRUE;
  1225. X        break;
  1226. X        case 'r':
  1227. X#ifndef    RMBIB
  1228. X        _O_rem = TRUE;
  1229. X#endif
  1230. X        break;
  1231. X        case 'i':
  1232. X#ifdef    RMBIB
  1233. X        _O_inq = TRUE;
  1234. X#endif
  1235. X        break;
  1236. X        case 's':
  1237. X        _O_silent = TRUE;
  1238. X        break;
  1239. X        case '?':
  1240. X        default:
  1241. X        _O_help = TRUE;
  1242. X        }
  1243. X    
  1244. X    if (_O_help)
  1245. X      {
  1246. X      (void) usage ();
  1247. X      return -1;
  1248. X      }
  1249. X    
  1250. X#ifdef    RMBIB
  1251. X    _O_rem = TRUE;
  1252. X#endif
  1253. X
  1254. X    _O_regexp = argv[optind];
  1255. X    _O_files = (char **) malloc ((unsigned) (sizeof(char *) * (argc - optind + 1)));
  1256. X    if (_O_files == (char **) NULL)
  1257. X      {
  1258. X      perror (PROGSTR);
  1259. X      exit (-2);
  1260. X      }
  1261. X
  1262. X    count = 0;
  1263. X    temp = _O_flist = _O_files;
  1264. X    for (i = ++optind; i < argc; i++)
  1265. X      {
  1266. X      *temp = argv[i];
  1267. X      temp++;
  1268. X      count++;
  1269. X      }
  1270. X    *temp = (char *) NULL;
  1271. X    if (! *_O_flist)
  1272. X      *_O_flist = "-"        /* stdin */;
  1273. X    if (count <= 1) _O_silent = TRUE;
  1274. X    store.isfull = FALSE;
  1275. X
  1276. X    return 0;
  1277. X}
  1278. X      
  1279. X
  1280. Xrestore_bakfile (file, fptr)
  1281. Xchar    *file;
  1282. XFILE    *fptr;
  1283. X
  1284. X{
  1285. Xchar    tmpfn[20];
  1286. X
  1287. X    if (! fptr)
  1288. X      return 0;
  1289. X
  1290. X    fclose (fptr);
  1291. X    Sprintf (tmpfn, "%s.bak", file);
  1292. X    (void) rename (tmpfn, file);
  1293. X    return 0;
  1294. X}
  1295. X
  1296. X
  1297. Xusage ()
  1298. X
  1299. X{
  1300. X#ifndef    RMBIB
  1301. XFprintf (stderr, "usage: %s [-f] [-l] [-g] [-r] [-s] [-h] reg-expn file(s)\n",
  1302. X            PROGSTR);
  1303. XFprintf (stderr, "\t-f\tGet first match only\n");
  1304. XFprintf (stderr, "\t-l\tGet last matching record only\n");
  1305. XFprintf (stderr, "\t-g\tGet all matches\n");
  1306. XFprintf (stderr, "\t-r\tDelete matching record\n");
  1307. XFprintf (stderr, "\t-s\tAct Silently, ie don't echo record to stdout\n");
  1308. XFprintf (stderr, "\t-h\tPrint this help\n");
  1309. X#else
  1310. XFprintf (stderr, "usage: %s [-f] [-l] [-g] [-i] [-s] [-h] reg-expn file(s)\n",
  1311. X            PROGSTR);
  1312. XFprintf (stderr, "\t-f\tDelete first matching record only\n");
  1313. XFprintf (stderr, "\t-l\tDelete last matching record only\n");
  1314. XFprintf (stderr, "\t-g\tDelete all matches\n");
  1315. XFprintf (stderr, "\t-i\tInquire before deleting record\n");
  1316. XFprintf (stderr, "\t-s\tAct Silently, ie don't echo record to stdout\n");
  1317. XFprintf (stderr, "\t-h\tPrint this help\n");
  1318. X#endif
  1319. Xreturn 0;
  1320. X}
  1321. X
  1322. X
  1323. Xoutput_record (file, record)
  1324. Xchar    *file, *record;
  1325. X
  1326. X{
  1327. X    if (! _O_silent)
  1328. X      Fprintf (stdout, "%s:\n", file);
  1329. X#ifdef    RMBIB
  1330. X    if (_O_inq)
  1331. X      {
  1332. X      Fprintf (stderr, "%s\n", record);
  1333. X      if (answer ("remove? ", NO))
  1334. X        {
  1335. X        STASH (record);
  1336. X        return -1    /* deletion did not occur */;
  1337. X        }
  1338. X      else
  1339. X        Fprintf (stdout, "%s\n", record);
  1340. X      }
  1341. X#else
  1342. X        Fprintf (stdout, "%s\n", record);
  1343. X#endif
  1344. X    return 0;
  1345. X}
  1346. EOFile bibcent.c
  1347. chmod u=rw+,g=r++,o=r++ bibcent.c
  1348. echo '...done' 1>&2
  1349. if [ ! -d . ] ; then
  1350.     echo -n Directory . not found. Creating....
  1351.     mkdir .
  1352.     if [ ! -d . ] ; then
  1353.         echo ...failed
  1354.         echo unable to create directory ..  Please create the directory and try again
  1355.         exit
  1356.     fi
  1357.     echo ...done
  1358. fi
  1359. echo -n "bibcent.h..." 1>&2
  1360. if test -f bibcent.h
  1361. then
  1362.     case $# in 
  1363.     0)
  1364.         echo 'exists, `sh filename -o'\'' to overwrite'
  1365.         exit 0;;
  1366.     esac
  1367.     case $1 in 
  1368.     -o)    ;;
  1369.     *)
  1370.         echo 'exists, `sh filename -o'\'' to overwrite'
  1371.         exit 0;;
  1372.     esac
  1373. fi
  1374. sed 's/^X//' << 'EOFile bibcent.h' > bibcent.h
  1375. X/*
  1376. X * This program has been written by Kannan Varadhan.  You are welcome to
  1377. X * use, copy, modify, or circulate as you please, provided you do not
  1378. X * charge any fee for any of it, and you do not remove these header
  1379. X * comments from any of these files.
  1380. X *
  1381. X *        -- kva    Mon Dec  4 11:26:37 EST 1989
  1382. X */
  1383. X
  1384. X#include    "includes.h"
  1385. X
  1386. X#define    FIRST_MATCH    1        /* -f flag, the default    */
  1387. X#define    GLOBAL_MATCH    2        /* -g flag    */
  1388. X#define    LAST_MATCH    4        /* -l flag    */
  1389. X
  1390. XREGEXP    *REGCOMP();
  1391. X
  1392. Xtypedef    struct    recd    {
  1393. X    int    isfull;
  1394. X    char    *filename;
  1395. X    char    *bibentry;
  1396. X    }    record;
  1397. X
  1398. XDCL (char, _O_srch, FIRST_MATCH);
  1399. XDCL (char, _O_rem, FALSE);        /* -r flag, shent only    */
  1400. X#ifdef    RMBIB
  1401. XDCL (char, _O_inq, FALSE);        /* -i flag, rment only    */
  1402. X#endif
  1403. XDCL (char, _O_silent, FALSE);        /* -s flag, shent only    */
  1404. XDCL (char, _O_help, FALSE);        /* -h flag    */
  1405. X
  1406. XDCLX (char, **_O_files);
  1407. XDCLX (char, **_O_flist);
  1408. XDCL  (char , *_O_file, (char *) NULL);
  1409. XDCL (char, *_O_regexp, (char *) NULL);
  1410. X
  1411. XDCLX (REGEXP, *regprog);
  1412. XDCLX (FILE, *mytmpfile);
  1413. X
  1414. XDCLX (record, store);
  1415. X
  1416. X#ifdef RMBIB
  1417. X#define    STASH(str)    fprintf (mytmpfile, "%s\n", str)
  1418. X#else
  1419. X#define    STASH(str)    if (mytmpfile) fprintf (mytmpfile, "%s\n", str)
  1420. X#endif
  1421. EOFile bibcent.h
  1422. chmod u=rw+,g=r++,o=r++ bibcent.h
  1423. echo '...done' 1>&2
  1424. if [ ! -d . ] ; then
  1425.     echo -n Directory . not found. Creating....
  1426.     mkdir .
  1427.     if [ ! -d . ] ; then
  1428.         echo ...failed
  1429.         echo unable to create directory ..  Please create the directory and try again
  1430.         exit
  1431.     fi
  1432.     echo ...done
  1433. fi
  1434. echo -n "bibl.l..." 1>&2
  1435. if test -f bibl.l
  1436. then
  1437.     case $# in 
  1438.     0)
  1439.         echo 'exists, `sh filename -o'\'' to overwrite'
  1440.         exit 0;;
  1441.     esac
  1442.     case $1 in 
  1443.     -o)    ;;
  1444.     *)
  1445.         echo 'exists, `sh filename -o'\'' to overwrite'
  1446.         exit 0;;
  1447.     esac
  1448. fi
  1449. sed 's/^X//' << 'EOFile bibl.l' > bibl.l
  1450. X%{
  1451. X
  1452. X/*
  1453. X * This program has been written by Kannan Varadhan.  You are welcome to
  1454. X * use, copy, modify, or circulate as you please, provided you do not
  1455. X * charge any fee for any of it, and you do not remove these header
  1456. X * comments from any of these files.
  1457. X *
  1458. X *        -- kva    Mon Dec  4 11:26:37 EST 1989
  1459. X */
  1460. X
  1461. X#include    "bibc.h"
  1462. X#undef    YY_INPUT
  1463. X#define    YY_INPUT(buf,reslt,msize)    my_input (buf, &reslt, msize)
  1464. X
  1465. Xmy_input (buf,reslt, size)
  1466. Xchar    *buf;
  1467. Xint    *reslt;
  1468. Xint    size;
  1469. X
  1470. X{
  1471. Xchar    inputln[80];
  1472. X
  1473. X    bzero (inputln, 80);
  1474. X    if (! GETS (inputln, 80))
  1475. X      Strcpy (buf, "EOF");
  1476. X    else
  1477. X      Strncpy (buf, inputln, size);
  1478. X    Strcat (buf, "!");
  1479. X#ifdef    FLEX_DEBUG
  1480. X    Fprintf (stderr, "buf contains: %s\n", buf);
  1481. X#endif
  1482. X    return *reslt = strlen (buf);
  1483. X}
  1484. X
  1485. X
  1486. Xmy_yylex ()
  1487. X
  1488. X{
  1489. X#define    PROMPTSTR            "\
  1490. XWhat kind of record would you like to enter (one of the following)?\n\
  1491. X    article        book        booklet        conference\n\
  1492. X    inbook        incollection    inproceedings    manual\n\
  1493. X    mastersthesis    msthesis    misc        phdthesis\n\
  1494. X    proceedings    techreport    unpublished\n\
  1495. Xor    EDIT        quit\n"
  1496. X    
  1497. X    Fprintf (stderr, PROMPTSTR);
  1498. X    return yylex ();
  1499. X}
  1500. X
  1501. X%}
  1502. X
  1503. X%%
  1504. X"a!"        return ARTICLE;
  1505. X"ar!"        return ARTICLE;
  1506. X"art!"        return ARTICLE;
  1507. X"arti!"        return ARTICLE;
  1508. X"artic!"        return ARTICLE;
  1509. X"articl!"        return ARTICLE;
  1510. X"article!"        return ARTICLE;
  1511. X"book!"        return BOOK;
  1512. X"bookl!"        return BOOKLET;
  1513. X"bookle!"        return BOOKLET;
  1514. X"booklet!"        return BOOKLET;
  1515. X"c!"        return CONFERENCE;
  1516. X"co!"        return CONFERENCE;
  1517. X"con!"        return CONFERENCE;
  1518. X"conf!"        return CONFERENCE;
  1519. X"confe!"        return CONFERENCE;
  1520. X"confer!"        return CONFERENCE;
  1521. X"confere!"        return CONFERENCE;
  1522. X"conferen!"        return CONFERENCE;
  1523. X"conferenc!"        return CONFERENCE;
  1524. X"conference!"        return CONFERENCE;
  1525. X"inb!"        return INBOOK;
  1526. X"inbo!"        return INBOOK;
  1527. X"inboo!"        return INBOOK;
  1528. X"inbook!"        return INBOOK;
  1529. X"inc!"        return INCOLLECTION;
  1530. X"inco!"        return INCOLLECTION;
  1531. X"incol!"        return INCOLLECTION;
  1532. X"incoll!"        return INCOLLECTION;
  1533. X"incolle!"        return INCOLLECTION;
  1534. X"incollec!"        return INCOLLECTION;
  1535. X"incollect!"        return INCOLLECTION;
  1536. X"incollecti!"        return INCOLLECTION;
  1537. X"incollectio!"        return INCOLLECTION;
  1538. X"incollection!"        return INCOLLECTION;
  1539. X"inp!"        return INPROCEEDINGS;
  1540. X"inpr!"        return INPROCEEDINGS;
  1541. X"inpro!"        return INPROCEEDINGS;
  1542. X"inproc!"        return INPROCEEDINGS;
  1543. X"inproce!"        return INPROCEEDINGS;
  1544. X"inprocee!"        return INPROCEEDINGS;
  1545. X"inproceed!"        return INPROCEEDINGS;
  1546. X"inproceedi!"        return INPROCEEDINGS;
  1547. X"inproceedin!"        return INPROCEEDINGS;
  1548. X"inproceeding!"        return INPROCEEDINGS;
  1549. X"inproceedings!"        return INPROCEEDINGS;
  1550. X"man!"        return MANUAL;
  1551. X"manu!"        return MANUAL;
  1552. X"manua!"        return MANUAL;
  1553. X"manual!"        return MANUAL;
  1554. X"mas!"        return MASTERSTHESIS;
  1555. X"mast!"        return MASTERSTHESIS;
  1556. X"maste!"        return MASTERSTHESIS;
  1557. X"master!"        return MASTERSTHESIS;
  1558. X"masters!"        return MASTERSTHESIS;
  1559. X"masterst!"        return MASTERSTHESIS;
  1560. X"mastersth!"        return MASTERSTHESIS;
  1561. X"mastersthe!"        return MASTERSTHESIS;
  1562. X"mastersthes!"        return MASTERSTHESIS;
  1563. X"mastersthesi!"        return MASTERSTHESIS;
  1564. X"mastersthesis!"        return MASTERSTHESIS;
  1565. X"ms!"        return MASTERSTHESIS;
  1566. X"mst!"        return MASTERSTHESIS;
  1567. X"msth!"        return MASTERSTHESIS;
  1568. X"msthe!"        return MASTERSTHESIS;
  1569. X"msthes!"        return MASTERSTHESIS;
  1570. X"msthesi!"        return MASTERSTHESIS;
  1571. X"msthesis!"        return MASTERSTHESIS;
  1572. X"mi!"        return MISC;
  1573. X"mis!"        return MISC;
  1574. X"misc!"        return MISC;
  1575. X"ph!"        return PHDTHESIS;
  1576. X"phd!"        return PHDTHESIS;
  1577. X"phdt!"        return PHDTHESIS;
  1578. X"phdth!"        return PHDTHESIS;
  1579. X"phdthe!"        return PHDTHESIS;
  1580. X"phdthes!"        return PHDTHESIS;
  1581. X"phdthesi!"        return PHDTHESIS;
  1582. X"phdthesis!"        return PHDTHESIS;
  1583. X"pr!"        return PROCEEDINGS;
  1584. X"pro!"        return PROCEEDINGS;
  1585. X"proc!"        return PROCEEDINGS;
  1586. X"proce!"        return PROCEEDINGS;
  1587. X"procee!"        return PROCEEDINGS;
  1588. X"procees!"        return PROCEEDINGS;
  1589. X"proceesi!"        return PROCEEDINGS;
  1590. X"proceesin!"        return PROCEEDINGS;
  1591. X"proceesing!"        return PROCEEDINGS;
  1592. X"proceesings!"        return PROCEEDINGS;
  1593. X"t!"        return TECHREPORT;
  1594. X"te!"        return TECHREPORT;
  1595. X"tec!"        return TECHREPORT;
  1596. X"tech!"        return TECHREPORT;
  1597. X"techr!"        return TECHREPORT;
  1598. X"techre!"        return TECHREPORT;
  1599. X"techrep!"        return TECHREPORT;
  1600. X"techrepo!"        return TECHREPORT;
  1601. X"techrepor!"        return TECHREPORT;
  1602. X"techreport!"        return TECHREPORT;
  1603. X"u!"        return UNPUBLISHED;
  1604. X"un!"        return UNPUBLISHED;
  1605. X"unp!"        return UNPUBLISHED;
  1606. X"unpu!"        return UNPUBLISHED;
  1607. X"unpub!"        return UNPUBLISHED;
  1608. X"unpubl!"        return UNPUBLISHED;
  1609. X"unpubli!"        return UNPUBLISHED;
  1610. X"unpublis!"        return UNPUBLISHED;
  1611. X"unpublish!"        return UNPUBLISHED;
  1612. X"unpublishe!"        return UNPUBLISHED;
  1613. X"unpublished!"        return UNPUBLISHED;
  1614. X"quit!"            return FLD_NULL;
  1615. X"EOF!"            return FLD_NULL;
  1616. X"EDIT!"            return FLD_EDITOR;
  1617. X[a-zA-Z0-9]*!        return FLD_ERROR;
  1618. X%%
  1619. X
  1620. EOFile bibl.l
  1621. chmod u=rw+,g=r++,o=r++ bibl.l
  1622. echo '...done' 1>&2
  1623. if [ ! -d . ] ; then
  1624.     echo -n Directory . not found. Creating....
  1625.     mkdir .
  1626.     if [ ! -d . ] ; then
  1627.         echo ...failed
  1628.         echo unable to create directory ..  Please create the directory and try again
  1629.         exit
  1630.     fi
  1631.     echo ...done
  1632. fi
  1633. echo -n "bibtools.man..." 1>&2
  1634. if test -f bibtools.man
  1635. then
  1636.     case $# in 
  1637.     0)
  1638.         echo 'exists, `sh filename -o'\'' to overwrite'
  1639.         exit 0;;
  1640.     esac
  1641.     case $1 in 
  1642.     -o)    ;;
  1643.     *)
  1644.         echo 'exists, `sh filename -o'\'' to overwrite'
  1645.         exit 0;;
  1646.     esac
  1647. fi
  1648. sed 's/^X//' << 'EOFile bibtools.man' > bibtools.man
  1649. X.\" @(#)bibtools.1 (beta version) Sept 15 89
  1650. X.TH BIBTOOLS 1 "15 September 1989"
  1651. X.SH NAME
  1652. X.sp1
  1653. X.nf
  1654. X\fBbibtools\fP
  1655. X    \fBbibc\fP \- Create BibTeX and scribe style bibliographies
  1656. X    \fBbibv\fP \- Verify a series of BibTeX style bibliographies for
  1657. X            citation conflicts
  1658. X    \fBshbib\fP \- Display one or more records fromthe specified bib files
  1659. X    \fBrmbib\fP \- Delete one or more records fromthe specified bib files
  1660. X.fi
  1661. X.SH SYNOPSIS
  1662. X.sp1
  1663. X.nf
  1664. X\fBbibc\fP [-verify|-i] [-|+pester] [-|+verbose] [-file \fIfilename\fP] [-help]
  1665. X\fBbibv\fP [-s <style>] [-h] [ \fIfilename\fP ... ]
  1666. X\fBshbib\fP [-f|-g|-l] [-s] [-r] [-h] \fIregexp\fP [ \fIfilename\fP... ]
  1667. X\fBrmbib\fP [-f|-g|-l] [-s] [-i] [-h] \fIregexp\fP [ \fIfilename\fP... ]
  1668. X.fi
  1669. X.SH DESCRIPTION
  1670. X.sp 1
  1671. X\fIbibc\fP (mnemonic for BIB-Creator) is a prompt based tool for
  1672. Xcreating bibliographies in the BibTeX format.  \fIbibc\fP first queries the
  1673. Xuser for the kind of record they wish to create.  \fIbibc\fP understands
  1674. Xthe various fields required for the kind of record specified, and will
  1675. Xquery the user for the values for each of these fields.  \fIbibc\fP can
  1676. Xdistinguish between required and optional fields, and will, by default
  1677. Xinsist once on the user specifying the required fields.
  1678. X
  1679. X.nf
  1680. X    Once it has obtained a complete record, it will write it to the
  1681. X    file specified using the \fB-file\fP option, or to stdout.
  1682. X
  1683. X    \fIbibc\fP's  insistence can be turned off by using the
  1684. X    \fB-pester\fP flag.  Specifying \fB+pester\fP will reverse this
  1685. X    flag.  Default is \fB+pester\fP.
  1686. X
  1687. X    One can require \fIbibc\fP to confirm every record before it is
  1688. X    entered into the bib-file by using the \fB-verify,\fP or
  1689. X    \fB-i\fP option.  The default is "do not verify".
  1690. X
  1691. X    If the \fB-verbose\fP option is specified, \fIbibc\fP will not echo the
  1692. X    record to stdout.  \fB+verbose\fP will cause every record to be
  1693. X    echoed.  Default is \fB+verbose\fP.
  1694. X
  1695. X    The \fB-help\fP option causes \fIbibc\fP to print out a short usage
  1696. X    summary, describing all the options available to it.
  1697. X.fi
  1698. X
  1699. XTyping a '?' will cause \fIbibc\fP to print out one or two lines of help about
  1700. Xthe concerned field.  One can abort the current record, and restart a
  1701. Xnew one by typing "xx" to a field.
  1702. X
  1703. XA field that begins with a '\\' is assumed to flag a macro, and will
  1704. Xtherefore not be quoted in the output.
  1705. X
  1706. XSpecifying "EDIT" (case is important here), will cause \fIbibc\fP to fork an
  1707. Xeditor on the current file.  \fIbibc\fP will first attempt to fork off an
  1708. Xeditor using the "TEXEDIT" environment variable.  Then, it will
  1709. Xsucessively try "VISUAL", and "EDITOR", failing which it will try to
  1710. Xfork off a default editor, fixed by your system administrator.
  1711. X
  1712. XIt is possible for a user to define a maximum of 5 fields for
  1713. Xthemselves.  This is done by setting an environment variable called
  1714. X\fBBIBCINIT\fP.  The syntax of this variable is similar to the MAILPATH
  1715. Xvariable in ksh, and is 'FIELD1?help_string1:FIELD2?help_string2:...'
  1716. XThese fields are queried at the very end, the help_strings are the
  1717. Xstrings put out when one types a '?' to get information on the specific
  1718. Xfield.  By default, these fields are considered optional.
  1719. X
  1720. XSee the USAGE section for more help.
  1721. X
  1722. X\fIbibv\fP (mnemonic for BIB Verifier) creates a small sample LaTeX file,
  1723. Xcontaining just citations for every entry in the bib files specified,
  1724. Xand runs this file sucessively through latex, bibtex, latex, latex to
  1725. Xproduce bibtex.tex and bibtex.dvi files.  The run through bibtex causes
  1726. Xany duplicate citations to be flagged.  One can print the dvi file, and
  1727. Xget a hardcopy record of all the entries in the specified bib files.
  1728. X
  1729. X.nf
  1730. X    \fIbibv\fP uses a special kind of bst file, called
  1731. X    \fBspecl\fP.  This style file causes the bibitem keys to be the
  1732. X    same as the \\cite-keys that are used in the bib files
  1733. X    themselves. This is a convenient style for keeping hardcopies
  1734. X    of the bibliographies for reference.
  1735. X    One can use the \fB-s\fP option to specify a different style to
  1736. X    be used.
  1737. X
  1738. X    The \fB-h\fP option causes a brief help message to get printed out.
  1739. X.fi
  1740. X
  1741. X\fIshbib\fP (mnemonic for SHow BIB entry) is used to view records in the
  1742. Xgiven bib files.  The records matching the specific regular expression
  1743. Xare printed on stdout.
  1744. X
  1745. X.nf
  1746. X    The \fB-f\fP option specifies that only the first matching record is
  1747. X    to be printed out.  This is the default.
  1748. X
  1749. X    The \fB-g\fP option specifies the all records matching the expression
  1750. X    amongst all the files is to be printed out.  This is a mnemonic
  1751. X    for "globally match".
  1752. X
  1753. X    The \fB-l\fP option specifies that only the last matching record is
  1754. X    to be  printed out.
  1755. X
  1756. X    The \fB-r\fP option asks shbib to remove all records that get printed
  1757. X    out, from the respective files.  Note that this option can be
  1758. X    dangerous when used carelessly,  and is not always recommended.
  1759. X
  1760. X    If more than one files is given to \fIshbib\fP, the file where the
  1761. X    corresponding match is made is also echoed to stdout.  The \fB-s\fP
  1762. X    option, for silent, asks \fIshbib\fP not to do this echoing.
  1763. X
  1764. X    The \fI-h\fP option causes a brief help message to get printed out.
  1765. X.fi
  1766. X
  1767. X\fIrmbib\fP (mnemonic for ReMove BIB entry) is a tool to remove records
  1768. Xmatching the given regular expression from the corresponding bib
  1769. Xfiles.  The records that are deleted are also echoed to stdout.
  1770. X
  1771. X.nf
  1772. X    The \fB-f\fP option, the default specifies that only the first
  1773. X    matching record is to be deleted.
  1774. X
  1775. X    The \fB-g\fP option, requires all matching records are to be deleted.
  1776. X
  1777. X    The \fB-l\fP option requires that only the last matching record is to
  1778. X    be deleted.
  1779. X
  1780. X    The \fB-s\fP option asks \fIrmbib\fP not to echo the filename
  1781. X    matched, if more than one bibfile has been specified.
  1782. X
  1783. X    The \fB-i\fP option requires \fIrmbib\fP to inquire the user before
  1784. X    deleting any record.
  1785. X
  1786. X    The \fB-h\fP option causes a brief help message to get printed out.
  1787. X.fi
  1788. X
  1789. X.sp1
  1790. X.SH USAGE
  1791. X.sp1
  1792. X
  1793. XSee the sample walkthrough of usage of \fIbibc\fP, and a brief use of
  1794. X\fIshbib\fP.  \fBBold\fP lettering indicates characters that the user
  1795. Xtypes in.
  1796. X
  1797. X.nf
  1798. XScript started on Sun Dec  3 00:47:28 1989
  1799. Xcheops Bibcreate. \fBbibc -help\fP
  1800. XUsage: bibc [-i|-verify] [+|-verbose] [+|-pester] [-file <filename>] [-help]
  1801. X    -i            Inquire whether to commit a record
  1802. X    -verify            Same as above, a duplicate form
  1803. X    -verbose        Turn off verbose flag
  1804. X    +verbose        Turn on verbose flag
  1805. X    -pester            Do not insist, even for required fields
  1806. X    +pester            Insist once for required fields
  1807. X    -file <filename>    Output bib entries to <filename>
  1808. X    -help            Print this help output
  1809. Xcheops Bibcreate. \fBbibc -file foo.bib\fP
  1810. XWhat kind of record would you like to enter (one of the following)?
  1811. X    article        book        booklet        conference
  1812. X    inbook        incollection    inproceedings    manual
  1813. X    mastersthesis    msthesis    misc        phdthesis
  1814. X    proceedings    techreport    unpublished
  1815. Xor    EDIT        quit
  1816. X\fBinb\fP
  1817. XCITEKEY? \fBNAR88\fP
  1818. XAUTHOR? \fBNarayan, R. K.\fP
  1819. XTITLE? \fBA Writer's Nightmare\fP
  1820. XCHAPTER? 
  1821. XERROR: CHAPTER is a REQUIRED FIELD for INBOOK. Let's try that again...sigh...
  1822. XCHAPTER? 
  1823. XERROR: Frankly my dear, I don't give a damn...
  1824. XPAGES (optional)? \fB164--166\fP
  1825. XPUBLISHER? \fBPenguin Books\fP
  1826. XYEAR? \fB1988\fP
  1827. XVOLUME (optional)? \fB1\fP
  1828. XSERIES (optional)? 
  1829. XADDRESS (optional)? 
  1830. XEDITION (optional)? 
  1831. XMONTH (optional)? 
  1832. XNOTE (optional)? 
  1833. XKEY (optional)? \fB?\fP
  1834. XUsed for alphabetising and creating a label when the author and
  1835. X  editor fields are missing.
  1836. XKEY (optional)? 
  1837. XCOMMENT (optional)? 
  1838. XCROSS-REFERENCE (optional)? 
  1839. X @INBOOK { NAR88 ,
  1840. X    AUTHOR = "Narayan, R. K." ,
  1841. X    PAGES = "164--166" ,
  1842. X    PUBLISHER = "Penguin Books" ,
  1843. X    TITLE = "A Writer's Nightmare" ,
  1844. X    VOLUME = "1" ,
  1845. X    YEAR = "1988"
  1846. X    }
  1847. X
  1848. XWhat kind of record would you like to enter (one of the following)?
  1849. X    article        book        booklet        conference
  1850. X    inbook        incollection    inproceedings    manual
  1851. X    mastersthesis    msthesis    misc        phdthesis
  1852. X    proceedings    techreport    unpublished
  1853. Xor    EDIT        quit
  1854. X\fBin\fP
  1855. XUh oh! no no no
  1856. XWhat kind of record would you like to enter (one of the following)?
  1857. X    article        book        booklet        conference
  1858. X    inbook        incollection    inproceedings    manual
  1859. X    mastersthesis    msthesis    misc        phdthesis
  1860. X    proceedings    techreport    unpublished
  1861. Xor    EDIT        quit
  1862. X\fBmi\fP
  1863. XCITEKEY? \fBxx\fP
  1864. XAbort? [y|n] \fBy\fP
  1865. XWhat kind of record would you like to enter (one of the following)?
  1866. X    article        book        booklet        conference
  1867. X    inbook        incollection    inproceedings    manual
  1868. X    mastersthesis    msthesis    misc        phdthesis
  1869. X    proceedings    techreport    unpublished
  1870. Xor    EDIT        quit
  1871. X\fB^D\fP
  1872. Xcheops Bibcreate. \fBBIBCINIT="USR_FIELD1:USR_FIELD2?Bah Humbug" export BIBCINIT\fP
  1873. Xcheops Bibcreate. \fBbibc -file foo.bib\fP
  1874. XWhat kind of record would you like to enter (one of the following)?
  1875. X    article        book        booklet        conference
  1876. X    inbook        incollection    inproceedings    manual
  1877. X    mastersthesis    msthesis    misc        phdthesis
  1878. X    proceedings    techreport    unpublished
  1879. Xor    EDIT        quit
  1880. X\fBa\fP
  1881. XCITEKEY? \fBLAM78\fP
  1882. XAUTHOR? \fBLamport, Leslie\fP
  1883. XTITLE? \fBTime, Clocks, and the Ordering of Events in a Distributed System\fP
  1884. XJOURNAL? \fB\\jacm\fP
  1885. XYEAR? \fB1978\fP
  1886. XVOLUME (optional)? \fB21\fP
  1887. XNUMBER (optional)? \fB7\fP
  1888. XPAGES (optional)? \fB558--565\fP
  1889. XMONTH (optional)? \fB\\jul\fP
  1890. XNOTE (optional)? 
  1891. XKEY (optional)? 
  1892. XCOMMENT (optional)? 
  1893. XCROSS-REFERENCE (optional)? 
  1894. XUSR_FIELD1 (optional)? \fB?\fP
  1895. XYou asked for it, buster, so you figure it out...
  1896. XUSR_FIELD1 (optional)? \fBThis wasn't in the jacm, sigh\fP
  1897. XUSR_FIELD2 (optional)? \fB?\fP
  1898. XBah Humbug
  1899. XUSR_FIELD2 (optional)? \fBThere we go, it was in the cacm, so we can EDIT and change the entry\fP
  1900. X @ARTICLE { LAM78 ,
  1901. X    AUTHOR = "Lamport, Leslie" ,
  1902. X    JOURNAL =   jacm  ,
  1903. X    MONTH =   jul  ,
  1904. X    NUMBER = "7" ,
  1905. X    PAGES = "558--565" ,
  1906. X    TITLE = "Time, Clocks, and the Ordering of Events in a Distributed System" ,
  1907. X    VOLUME = "21" ,
  1908. X    YEAR = "1978" ,
  1909. X    USR_FIELD1 = "This wasn't in the jacm, sigh" ,
  1910. X    USR_FIELD2 = "There we go, it was in the cacm, so we can EDIT and change the entry"
  1911. X    }
  1912. X
  1913. XWhat kind of record would you like to enter (one of the following)?
  1914. X    article        book        booklet        conference
  1915. X    inbook        incollection    inproceedings    manual
  1916. X    mastersthesis    msthesis    misc        phdthesis
  1917. X    proceedings    techreport    unpublished
  1918. Xor    EDIT        quit
  1919. X\fB^D\fP
  1920. Xcheops Bibcreate. \fBshbib lam78 foo.bib\fP
  1921. X@ARTICLE { LAM78 ,
  1922. X    AUTHOR = "Lamport, Leslie" ,
  1923. X    JOURNAL =   jacm  ,
  1924. X    MONTH =   jul  ,
  1925. X    NUMBER = "7" ,
  1926. X    PAGES = "558--565" ,
  1927. X    TITLE = "Time, Clocks, and the Ordering of Events in a Distributed System" ,
  1928. X    VOLUME = "21" ,
  1929. X    YEAR = "1978" ,
  1930. X    USR_FIELD1 = "This wasn't in the jacm, sigh" ,
  1931. X    USR_FIELD2 = "There we go, it was in the cacm, so we can EDIT and change the entry"
  1932. X    }
  1933. Xcheops Bibcreate. 
  1934. X
  1935. Xscript done on Sun Dec  3 00:57:11 1989
  1936. X.fi
  1937. X
  1938. X.sp1
  1939. X.SH BUGS
  1940. X.sp1
  1941. XThe order of entries in the bib file will not be the same as one had
  1942. Xoriginally started out with if one uses the \fB-r -l\fP option to
  1943. X\fIshbib\fP, or uses the \fB-l\fP option to \fIrmbib\fP.
  1944. X
  1945. XOne might like to have a tool for sorting entries in a file based on
  1946. Xsome specified keys.
  1947. X
  1948. XExiting in the middle of a entering a record via \fBbibc\fP causes some
  1949. Xunnecessary garbage to appear on the screen.  The output file is always
  1950. Xconsistent though.
  1951. X
  1952. XThese tools may crash if the bib files specified are not complete and
  1953. Xconsistent.
  1954. X
  1955. XThe method of delineating records is to locate a '\\n@', ie, a newline
  1956. Xfollowed by an '@' as the next character.
  1957. X
  1958. XThe \fB-i\fP option to \fIbibc\fP and \fIrmbib\fP will cause the record
  1959. Xto be seemingly displayed twice.  This is not so.  The first time, the
  1960. Xwrite is to stderr, the final write is to stdout.  This is so one can
  1961. Xredirect stdout to correct places, such as doing
  1962. X
  1963. X.nf
  1964. X        \fBrmbib -g -i -s Concurrency bib-files > concurrency.bib\fP
  1965. X.fi
  1966. X
  1967. XHopefully, not much else.
  1968. X
  1969. X.sp1
  1970. X.SH AUTHOR
  1971. X.sp1
  1972. X.LP
  1973. X.nf
  1974. X    Kannan Varadhan  - kannan@osc.edu
  1975. X.fi
  1976. X.sp1
  1977. X.SH SEE ALSO
  1978. X.sp1
  1979. X.nf
  1980. X\fBegrep(1)\fP, \fBmh(1)\fP, \fBprompter(1)\fP, \fBaddbib(1)\fP, \fPlookbib(1)\fP
  1981. X.fi
  1982. EOFile bibtools.man
  1983. chmod u=rw+,g=+++,o=+++ bibtools.man
  1984. echo '...done' 1>&2
  1985. if [ ! -d . ] ; then
  1986.     echo -n Directory . not found. Creating....
  1987.     mkdir .
  1988.     if [ ! -d . ] ; then
  1989.         echo ...failed
  1990.         echo unable to create directory ..  Please create the directory and try again
  1991.         exit
  1992.     fi
  1993.     echo ...done
  1994. fi
  1995. echo -n "bibv.c..." 1>&2
  1996. if test -f bibv.c
  1997. then
  1998.     case $# in 
  1999.     0)
  2000.         echo 'exists, `sh filename -o'\'' to overwrite'
  2001.         exit 0;;
  2002.     esac
  2003.     case $1 in 
  2004.     -o)    ;;
  2005.     *)
  2006.         echo 'exists, `sh filename -o'\'' to overwrite'
  2007.         exit 0;;
  2008.     esac
  2009. fi
  2010. sed 's/^X//' << 'EOFile bibv.c' > bibv.c
  2011. X/*
  2012. X * This program has been written by Kannan Varadhan.  You are welcome to
  2013. X * use, copy, modify, or circulate as you please, provided you do not
  2014. X * charge any fee for any of it, and you do not remove these header
  2015. X * comments from any of these files.
  2016. X *
  2017. X *        -- kva    Mon Dec  4 11:26:37 EST 1989
  2018. X */
  2019. X
  2020. X#define    GLOBALS
  2021. X#include "bibv.h"
  2022. X
  2023. Xmain (argc, argv)
  2024. Xint    argc;
  2025. Xchar    *argv[];
  2026. X
  2027. X{
  2028. Xextern    int    process_record();
  2029. X
  2030. X    if (process_args (argc, argv) == -1)
  2031. X      return -1    /* EXIT */;
  2032. X    
  2033. X    (void) set_signals_bibv ();
  2034. X
  2035. X    Fprintf (texfile, PREAMBLE, style, userid);
  2036. X    (void) process_bibfiles (_O_flist, process_record, (int (*)()) NULL);
  2037. X    (void) finish_up ();
  2038. X    if (execute (OUTFILE) >= 0)
  2039. X      Fprintf (stderr, "Now printout %s.dvi to see the output\n", OUTFILE);
  2040. X    (void) cleanup (OUTFILE);
  2041. X    return 0;
  2042. X}
  2043. X
  2044. X
  2045. Xfinish_up ()
  2046. X
  2047. X{
  2048. Xchar    *temp;
  2049. X
  2050. X    Fprintf (stderr, "FILE %s has %d records\n", _O_file, ctr);
  2051. X    temp = Rindex (bibrecd, ',');
  2052. X    *temp = '\0';
  2053. X    Fprintf (texfile, EPILOGUE, bibrecd);
  2054. X    fflush (texfile);
  2055. X    return 0;
  2056. X}
  2057. X
  2058. X
  2059. Xprocess_record (file, string)
  2060. Xchar    *file, *string;
  2061. X
  2062. X{
  2063. Xchar    *temp, *key;
  2064. X
  2065. X    if (_O_file != file)
  2066. X      {
  2067. X      if (ctr)
  2068. X        Fprintf (stderr, "FILE %s has %d records\n", _O_file, ctr);
  2069. X      Fprintf (texfile, SECTIONHDR, file);
  2070. X      if (Strcmp ((file + strlen (file) - 4), ".bib") == SAME)
  2071. X        Strncat (bibrecd, file, (strlen(file) - 4));
  2072. X      else
  2073. X        Strcat (bibrecd, file);
  2074. X      Strcat (bibrecd, ",");
  2075. X      _O_file = file;
  2076. X      ctr = 0;
  2077. X      }
  2078. X
  2079. X    if (REGMATCH (regprog, string) == 1)
  2080. X      {
  2081. X      temp = Index (string, OPEN_BRACE) + 1;
  2082. X      while ((*temp == ' ') || (*temp == '\t') || (*temp == '\n'))
  2083. X        temp++;
  2084. X      key = temp;
  2085. X      while ((*temp != ' ') && (*temp != '\t') && (*temp != '\n') &&
  2086. X                    (*temp != ','))
  2087. X        temp++;
  2088. X      *temp = '\0';
  2089. X      Fprintf (texfile, CITE, key);
  2090. X      ctr++;
  2091. X      }
  2092. X
  2093. X    return 0;
  2094. X}
  2095. X
  2096. X
  2097. Xprocess_args (argc, argv)
  2098. Xint    argc;
  2099. Xchar    *argv[];
  2100. X
  2101. X{
  2102. Xint    opt, count, i;
  2103. Xextern    char    *optarg;
  2104. Xextern    int    optind;
  2105. Xchar    **temp;
  2106. Xchar    outfile[100];
  2107. X
  2108. X    if (argc <= 1)
  2109. X      _O_help = TRUE;
  2110. X
  2111. X    while ((opt = getopt (argc, argv, "hs:")) != EOF)
  2112. X      switch (opt) {
  2113. X        case 'h':
  2114. X        _O_help = TRUE;
  2115. X        break;
  2116. X        case 's':
  2117. X        style = optarg;
  2118. X        break;
  2119. X        case '?':
  2120. X        default:
  2121. X        _O_help = TRUE;
  2122. X        }
  2123. X    
  2124. X    if (_O_help)
  2125. X      {
  2126. X      usage ();
  2127. X      return -1;
  2128. X      }
  2129. X    
  2130. X    _O_files = (char **) malloc ((unsigned) (sizeof (char *) * (argc - optind + 1)));
  2131. X    if (_O_files == (char **) NULL)
  2132. X      {
  2133. X      perror (PROGSTR);
  2134. X      exit (-2);
  2135. X      }
  2136. X
  2137. X    count = 1;
  2138. X    temp = _O_flist = _O_files;
  2139. X    for (i = optind; i < argc; i++)
  2140. X      {
  2141. X      *temp = argv[i];
  2142. X      count += Strlen (*temp) + 1;
  2143. X      temp++;
  2144. X      }
  2145. X    *temp = (char *) NULL;
  2146. X    bibrecd = (char *) malloc ((unsigned) count);
  2147. X    bzero (bibrecd, count);
  2148. X
  2149. X    pwentry = getpwuid (getuid());
  2150. X    userid = pwentry->pw_name;
  2151. X
  2152. X    Sprintf (outfile, "%s.tex", OUTFILE);
  2153. X    texfile = fopen (outfile, "w");
  2154. X
  2155. X    regprog = (REGEXP *) REGCOMP (KEYS);
  2156. X    return 0;
  2157. X}
  2158. X      
  2159. X
  2160. Xusage ()
  2161. X
  2162. X{
  2163. XFprintf (stderr, "usage: %s [-s style-file] [-h] [ filename ... ]\n", PROGSTR);
  2164. Xreturn 0;
  2165. X}
  2166. X
  2167. X
  2168. Xexecute (outfile)
  2169. Xchar    *outfile;
  2170. X
  2171. X{
  2172. X    if (run (LATEX, "latex", outfile, TRUE) < 0)
  2173. X      return -1;
  2174. X    if (run (BIBTEX, "bibtex", outfile, FALSE) < 0)
  2175. X      return -1;
  2176. X    if (run (LATEX, "latex", outfile, TRUE) < 0)
  2177. X      return -1;
  2178. X    if (run (LATEX, "latex", outfile, FALSE) < 0)
  2179. X      return -1;
  2180. X    return 0;
  2181. X}
  2182. X
  2183. X
  2184. Xcleanup (outfile)
  2185. Xchar    *outfile;
  2186. X
  2187. X{
  2188. Xchar    fn[100];
  2189. X
  2190. X    Sprintf (fn, "%s.bbl", outfile); unlink (fn);
  2191. X    Sprintf (fn, "%s.aux", outfile); unlink (fn);
  2192. X    Sprintf (fn, "%s.log", outfile); unlink (fn);
  2193. X    Sprintf (fn, "%s.blg", outfile); unlink (fn);
  2194. X    return 0;
  2195. X}
  2196. X
  2197. Xrun (progname, arg0, filename, fdstatus)
  2198. Xchar    *progname, *arg0, *filename;
  2199. Xint    fdstatus;
  2200. X
  2201. X{
  2202. Xint    pid;
  2203. Xchar    emsg[100];
  2204. Xunion    wait    status;
  2205. X
  2206. X    Sprintf (emsg, "Cannot run %s .. Aborting", arg0);
  2207. X    pid = vfork();
  2208. X    if (pid < 0)        /* ERROR */
  2209. X      {
  2210. X      perror ("fork");
  2211. X      return -1;
  2212. X      }
  2213. X    else if (pid == 0)    /* CHILD */
  2214. X      {
  2215. X      if (fdstatus)
  2216. X        {
  2217. X        close (0); open ("/dev/null", O_RDONLY);
  2218. X        close (1); open ("/dev/null", O_WRONLY);
  2219. X        close (2); open ("/dev/null", O_WRONLY);
  2220. X        }
  2221. X      execlp (progname, progname, filename, 0);
  2222. X      perror (emsg);
  2223. X      return -1;
  2224. X      }
  2225. X    else
  2226. X      (void) wait4 (pid, &status, 0, (struct rusage *) NULL);
  2227. X
  2228. X    if (status.w_termsig != 0)
  2229. X      {
  2230. X      Fprintf (stderr, "%s error, signal %2d %s\n", arg0,
  2231. X                status.w_termsig,
  2232. X                (status.w_coredump ? ", core dumped" : "")
  2233. X          );
  2234. X      return -1;
  2235. X      }
  2236. X    return 0;
  2237. X}
  2238. X
  2239. Xset_signals_bibv ()
  2240. X
  2241. X{
  2242. Xextern    int    hangup_bibv(), abort_bibv();
  2243. X
  2244. X    signal (SIGHUP, hangup_bibv);
  2245. X    signal (SIGINT, hangup_bibv);
  2246. X    signal (SIGQUIT, hangup_bibv);
  2247. X    signal (SIGTERM, hangup_bibv);
  2248. X
  2249. X    signal (SIGILL, abort_bibv);
  2250. X    signal (SIGBUS, abort_bibv);
  2251. X    signal (SIGSEGV, abort_bibv);
  2252. X    signal (SIGSYS, abort_bibv);
  2253. X    signal (SIGPIPE, abort_bibv);
  2254. X    return -1;
  2255. X}
  2256. X
  2257. Xhangup_bibv ()
  2258. X/*
  2259. X * Nothing to do but cleanout bibtex.* files, and exit
  2260. X */
  2261. X
  2262. X{
  2263. Xchar    fn[100];
  2264. X
  2265. X    Sprintf (fn, "%s.tex", OUTFILE); unlink (fn);
  2266. X    Sprintf (fn, "%s.dvi", OUTFILE); unlink (fn);
  2267. X    Sprintf (fn, "%s.bbl", OUTFILE); unlink (fn);
  2268. X    Sprintf (fn, "%s.aux", OUTFILE); unlink (fn);
  2269. X    Sprintf (fn, "%s.log", OUTFILE); unlink (fn);
  2270. X    Sprintf (fn, "%s.blg", OUTFILE); unlink (fn);
  2271. X    exit (-1);
  2272. X}
  2273. X
  2274. X
  2275. Xabort_bibv (sig, code, scp)
  2276. X/*
  2277. X * First print out a small message, then hangup_bibv()
  2278. X */
  2279. X
  2280. X{
  2281. XFprintf (stderr, "Unexpected error signal %d received..aborting\n", sig);
  2282. Xhangup_bibv ();
  2283. X/*NOT REACHED*/
  2284. X}
  2285. EOFile bibv.c
  2286. chmod u=rw+,g=r++,o=r++ bibv.c
  2287. echo '...done' 1>&2
  2288. if [ ! -d . ] ; then
  2289.     echo -n Directory . not found. Creating....
  2290.     mkdir .
  2291.     if [ ! -d . ] ; then
  2292.         echo ...failed
  2293.         echo unable to create directory ..  Please create the directory and try again
  2294.         exit
  2295.     fi
  2296.     echo ...done
  2297. fi
  2298. echo -n "bibv.h..." 1>&2
  2299. if test -f bibv.h
  2300. then
  2301.     case $# in 
  2302.     0)
  2303.         echo 'exists, `sh filename -o'\'' to overwrite'
  2304.         exit 0;;
  2305.     esac
  2306.     case $1 in 
  2307.     -o)    ;;
  2308.     *)
  2309.         echo 'exists, `sh filename -o'\'' to overwrite'
  2310.         exit 0;;
  2311.     esac
  2312. fi
  2313. sed 's/^X//' << 'EOFile bibv.h' > bibv.h
  2314. X/*
  2315. X * This program has been written by Kannan Varadhan.  You are welcome to
  2316. X * use, copy, modify, or circulate as you please, provided you do not
  2317. X * charge any fee for any of it, and you do not remove these header
  2318. X * comments from any of these files.
  2319. X *
  2320. X *        -- kva    Mon Dec  4 11:26:37 EST 1989
  2321. X */
  2322. X
  2323. X#include    "includes.h"
  2324. X#include    <pwd.h>
  2325. X
  2326. X#define    PROGSTR    "bibv"
  2327. X
  2328. XREGEXP    *REGCOMP();
  2329. X
  2330. XDCLX (char, **_O_files);
  2331. XDCLX (char, **_O_flist);
  2332. XDCL  (char, *_O_file, (char *) NULL);
  2333. XDCL  (char, *bibrecd, (char *) NULL);
  2334. XDCL  (char, *style, STYLE);
  2335. XDCLX (struct passwd, *pwentry);
  2336. XDCLX (char, *userid);
  2337. XDCL  (int, ctr, 0);
  2338. X
  2339. XDCLX (REGEXP, *regprog);
  2340. XDCLX (FILE, *texfile);
  2341. X
  2342. XDCL  (char, _O_help, FALSE);
  2343. X
  2344. X#define    PREAMBLE    "\\documentstyle{article}\n\
  2345. X\\begin{document}\n\
  2346. X\\bibliographystyle{%s}\n\
  2347. X\\title{Verifying Biblio files}\n\
  2348. X\\author{%s}\n\
  2349. X\\date{\\today}\n\
  2350. X\\maketitle\n"
  2351. X
  2352. X#define    SECTIONHDR    "\\section{FILE %s}\n\nCiting:\n"
  2353. X#define    CITE    "\\cite {%s}\n"
  2354. X#define    COMMENTS    "\
  2355. X%\n\
  2356. X% This is a sample tex file sillustrating, and verifying all the bib\n\
  2357. X% bib entries you have in the bib files you have specified.\n\
  2358. X%"
  2359. X
  2360. X#define    EPILOGUE    "\\bibliography{%s}\n\\end{document}"
  2361. X
  2362. X#define    KEYS    "@arti|@book|@conf|@inbo|@inco|@inpr|@manu|@mast|@misc|@phdt|@proc|@tech|@unpu"
  2363. EOFile bibv.h
  2364. chmod u=rw+,g=r++,o=r++ bibv.h
  2365. echo '...done' 1>&2
  2366. if [ ! -d . ] ; then
  2367.     echo -n Directory . not found. Creating....
  2368.     mkdir .
  2369.     if [ ! -d . ] ; then
  2370.         echo ...failed
  2371.         echo unable to create directory ..  Please create the directory and try again
  2372.         exit
  2373.     fi
  2374.     echo ...done
  2375. fi
  2376. echo -n "config.h..." 1>&2
  2377. if test -f config.h
  2378. then
  2379.     case $# in 
  2380.     0)
  2381.         echo 'exists, `sh filename -o'\'' to overwrite'
  2382.         exit 0;;
  2383.     esac
  2384.     case $1 in 
  2385.     -o)    ;;
  2386.     *)
  2387.         echo 'exists, `sh filename -o'\'' to overwrite'
  2388.         exit 0;;
  2389.     esac
  2390. fi
  2391. sed 's/^X//' << 'EOFile config.h' > config.h
  2392. X/*
  2393. X * This program has been written by Kannan Varadhan.  You are welcome to
  2394. X * use, copy, modify, or circulate as you please, provided you do not
  2395. X * charge any fee for any of it, and you do not remove these header
  2396. X * comments from any of these files.
  2397. X *
  2398. X *        -- kva    Mon Dec  4 11:26:37 EST 1989
  2399. X */
  2400. X
  2401. X/*
  2402. X * SAFE turns off the -pester flag by default, set it to TRUE unless
  2403. X * you have absolutely pained users like me, who think they know what
  2404. X * what they are doing....As to whether they (or I) actually know or
  2405. X * not is not the issue here, is it? :-)
  2406. X */
  2407. X#ifndef SAFE
  2408. X#define    SAFE    TRUE
  2409. X#endif
  2410. X
  2411. X/* maximum size of string a user is permitted to input        */
  2412. X#define    MAXLEN        391
  2413. X
  2414. X/* The number of fields a user can define for himself...    */
  2415. X#define    USR_DEFNS_MAX    5
  2416. X
  2417. X/* hmmm.....                             */
  2418. X#define    DEFAULT_EDITOR    "/usr/ucb/vi"
  2419. X
  2420. X/*
  2421. X * If a user defines his own fields, but no help prompts, this is 
  2422. X * What I'd say    ... ;-)
  2423. X */
  2424. X#define    DEFAULT_USERHLP    "You asked for it, buster, so you figure it out..."
  2425. X
  2426. X/*
  2427. X * bibv definitions
  2428. X */
  2429. X/* style file to use for bibv                    */
  2430. X#define    STYLE    "specl"
  2431. X
  2432. X/* locations of latex and bibtex                */
  2433. X#define    LATEX    "/usr/local/bin/latex"
  2434. X#define    BIBTEX    "/usr/local/bin/bibtex"
  2435. X
  2436. X/* wait4() equivalent, if you don't have it            */
  2437. X#define    wait4(PID,STATUS,OPTS,RUSAGE)    wait3 (STATUS, OPTS, RUSAGE) /* sigh */
  2438. X
  2439. X/* Name of file output by bibv                    */
  2440. X#define    OUTFILE        "bibtex"
  2441. X
  2442. X/*
  2443. X * REGULAR EXPRESSION HANDLING
  2444. X *
  2445. X * entry handling routines only, shent and rment
  2446. X */
  2447. X
  2448. X#define    BUFSIZE    8000
  2449. X#define    RECSIZE     800
  2450. X
  2451. X#define    NOCASE    /* Perform caseless regular expression matching    */
  2452. X/*
  2453. X * Caseless regular expression matching is done simply by converting
  2454. X * all strings to lower case, and then performing the comparison.
  2455. X */
  2456. X
  2457. X/*
  2458. X * There are three defines
  2459. X *    REGEXP        defines type of regular expression
  2460. X *    REGCOMP        compile the r. e. into one of type REGEXP
  2461. X *    REGMATCH    it to perform the match
  2462. X */
  2463. X#define    REGEXP    regexp
  2464. X
  2465. X#ifdef    NOCASE
  2466. X#define    REGCOMP        my_rcomp
  2467. X#define    REGMATCH    my_rexec
  2468. X#else
  2469. X#define    REGCOMP        regcomp
  2470. X#define    REGMATCH    regexec
  2471. X#endif
  2472. X
  2473. X
  2474. X/*
  2475. X * What routine to use for gets().  gets() has flaws in it's handling.
  2476. X * I prefer to simulate gets() functionality using my_gets(), in gets.c
  2477. X *
  2478. X * If you don't trust it, you could use, gets() directly.
  2479. X */
  2480. X
  2481. X/*#define    GETS(BUFF,SIZE)    gets (BUFF)        /* Rather not    */
  2482. X#define    GETS(BUFF,SIZE)    my_gets (BUFF, SIZE)        /* preferred    */
  2483. EOFile config.h
  2484. chmod u=rw+,g=r++,o=r++ config.h
  2485. echo '...done' 1>&2
  2486. if [ ! -d . ] ; then
  2487.     echo -n Directory . not found. Creating....
  2488.     mkdir .
  2489.     if [ ! -d . ] ; then
  2490.         echo ...failed
  2491.         echo unable to create directory ..  Please create the directory and try again
  2492.         exit
  2493.     fi
  2494.     echo ...done
  2495. fi
  2496. echo -n "foo.bib..." 1>&2
  2497. if test -f foo.bib
  2498. then
  2499.     case $# in 
  2500.     0)
  2501.         echo 'exists, `sh filename -o'\'' to overwrite'
  2502.         exit 0;;
  2503.     esac
  2504.     case $1 in 
  2505.     -o)    ;;
  2506.     *)
  2507.         echo 'exists, `sh filename -o'\'' to overwrite'
  2508.         exit 0;;
  2509.     esac
  2510. fi
  2511. sed 's/^X//' << 'EOFile foo.bib' > foo.bib
  2512. X@INBOOK { NAR88 ,
  2513. X    AUTHOR = "Narayan, R. K." ,
  2514. X    PAGES = "164--166" ,
  2515. X    PUBLISHER = "Penguin Books" ,
  2516. X    TITLE = "A Writer's Nightmare" ,
  2517. X    VOLUME = "1" ,
  2518. X    YEAR = "1988"
  2519. X    }
  2520. X@ARTICLE { LAM78 ,
  2521. X    AUTHOR = "Lamport, Leslie" ,
  2522. X    JOURNAL =   jacm  ,
  2523. X    MONTH =   jul  ,
  2524. X    NUMBER = "7" ,
  2525. X    PAGES = "558--565" ,
  2526. X    TITLE = "Time, Clocks, and the Ordering of Events in a Distributed System" ,
  2527. X    VOLUME = "21" ,
  2528. X    YEAR = "1978"
  2529. X    }
  2530. X@ARTICLE { lam23 ,
  2531. X    AUTHOR = "asd" ,
  2532. X    JOURNAL = "asd" ,
  2533. X    TITLE = "asd" ,
  2534. X    YEAR = "asd"
  2535. X    }
  2536. X@ARTICLE { asd ,
  2537. X    AUTHOR = "asd" ,
  2538. X    JOURNAL = "fd" ,
  2539. X    TITLE = "adsf" ,
  2540. X    YEAR = "fsd" ,
  2541. X    USR_FIELD2 = "help"
  2542. X    }
  2543. EOFile foo.bib
  2544. chmod u=rw+,g=r++,o=r++ foo.bib
  2545. echo '...done' 1>&2
  2546. if [ ! -d . ] ; then
  2547.     echo -n Directory . not found. Creating....
  2548.     mkdir .
  2549.     if [ ! -d . ] ; then
  2550.         echo ...failed
  2551.         echo unable to create directory ..  Please create the directory and try again
  2552.         exit
  2553.     fi
  2554.     echo ...done
  2555. fi
  2556. echo -n "gen_lex_file..." 1>&2
  2557. if test -f gen_lex_file
  2558. then
  2559.     case $# in 
  2560.     0)
  2561.         echo 'exists, `sh filename -o'\'' to overwrite'
  2562.         exit 0;;
  2563.     esac
  2564.     case $1 in 
  2565.     -o)    ;;
  2566.     *)
  2567.         echo 'exists, `sh filename -o'\'' to overwrite'
  2568.         exit 0;;
  2569.     esac
  2570. fi
  2571. sed 's/^X//' << 'EOFile gen_lex_file' > gen_lex_file
  2572. X#! /bin/sh
  2573. X
  2574. X# /*
  2575. X#  * This program has been written by Kannan Varadhan.  You are welcome to
  2576. X# * use, copy, modify, or circulate as you please, provided you do not
  2577. X# * charge any fee for any of it, and you do not remove these header
  2578. X# * comments from any of these files.
  2579. X# *
  2580. X# *        -- kva    Mon Dec  4 11:26:37 EST 1989
  2581. X# */
  2582. X
  2583. Xcase $# in
  2584. X0|1|2)
  2585. Xecho usage: `basename $0` preamble_file rules_file postscript_file outputfile
  2586. Xexit ;;
  2587. Xesac
  2588. X
  2589. Xtrap 'rm $tmpfil; exit' 1 2 3 6 9 15
  2590. X
  2591. Xpreamble=$1;
  2592. Xrules=$2;
  2593. Xpostscript=$3;
  2594. Xoutput=$4;
  2595. X
  2596. Xcat $preamble
  2597. Xegrep -v '^#' $rules | awk '
  2598. XBEGIN { printf "\n%%%%\n" ; }
  2599. X{    token = $1;
  2600. X    min = length ($2);
  2601. X    max = length ($3);
  2602. X    key = $3;
  2603. X    for (i = min; i <= max; i++)
  2604. X      printf "\"%s!\"\t\treturn %s;\n", substr (key, 1, i), token
  2605. X    }'
  2606. X
  2607. Xcat $postscript
  2608. Xexit
  2609. EOFile gen_lex_file
  2610. chmod u=rwx,g=r+x,o=r+x gen_lex_file
  2611. echo '...done' 1>&2
  2612. if [ ! -d . ] ; then
  2613.     echo -n Directory . not found. Creating....
  2614.     mkdir .
  2615.     if [ ! -d . ] ; then
  2616.         echo ...failed
  2617.         echo unable to create directory ..  Please create the directory and try again
  2618.         exit
  2619.     fi
  2620.     echo ...done
  2621. fi
  2622. echo -n "header..." 1>&2
  2623. if test -f header
  2624. then
  2625.     case $# in 
  2626.     0)
  2627.         echo 'exists, `sh filename -o'\'' to overwrite'
  2628.         exit 0;;
  2629.     esac
  2630.     case $1 in 
  2631.     -o)    ;;
  2632.     *)
  2633.         echo 'exists, `sh filename -o'\'' to overwrite'
  2634.         exit 0;;
  2635.     esac
  2636. fi
  2637. sed 's/^X//' << 'EOFile header' > header
  2638. X/*
  2639. X * This program has been written by Kannan Varadhan.  You are welcome to
  2640. X * use, copy, modify, or circulate as you please, provided you do not
  2641. X * charge any fee for any of it, and you do not remove these header
  2642. X * comments from any of these files.
  2643. X *
  2644. X *        -- kva    Mon Dec  4 11:26:37 EST 1989
  2645. X */
  2646. EOFile header
  2647. chmod u=rw+,g=r++,o=r++ header
  2648. echo '...done' 1>&2
  2649. if [ ! -d . ] ; then
  2650.     echo -n Directory . not found. Creating....
  2651.     mkdir .
  2652.     if [ ! -d . ] ; then
  2653.         echo ...failed
  2654.         echo unable to create directory ..  Please create the directory and try again
  2655.         exit
  2656.     fi
  2657.     echo ...done
  2658. fi
  2659. echo -n "includes.h..." 1>&2
  2660. if test -f includes.h
  2661. then
  2662.     case $# in 
  2663.     0)
  2664.         echo 'exists, `sh filename -o'\'' to overwrite'
  2665.         exit 0;;
  2666.     esac
  2667.     case $1 in 
  2668.     -o)    ;;
  2669.     *)
  2670.         echo 'exists, `sh filename -o'\'' to overwrite'
  2671.         exit 0;;
  2672.     esac
  2673. fi
  2674. sed 's/^X//' << 'EOFile includes.h' > includes.h
  2675. X/*
  2676. X * This program has been written by Kannan Varadhan.  You are welcome to
  2677. X * use, copy, modify, or circulate as you please, provided you do not
  2678. X * charge any fee for any of it, and you do not remove these header
  2679. X * comments from any of these files.
  2680. X *
  2681. X *        -- kva    Mon Dec  4 11:26:37 EST 1989
  2682. X */
  2683. X
  2684. X#include <stdio.h>
  2685. X#include <sys/types.h>
  2686. X#include <sys/file.h>
  2687. X#include <sys/stat.h>
  2688. X#include <ctype.h>
  2689. X#include <assert.h>
  2690. X#include <errno.h>
  2691. X#include <signal.h>
  2692. X#include <sys/wait.h>
  2693. X#include <sys/time.h>
  2694. X#include <sys/resource.h>
  2695. X#include "strings.h"
  2696. X#include "config.h"
  2697. X#include "regexp.h"
  2698. X
  2699. Xextern    int    errno;
  2700. X#ifdef    GLOBALS
  2701. X#define    DCL(TYPE,VAR,VAL)    TYPE    VAR = VAL
  2702. X#define    DCLX(TYPE,VAR)        TYPE    VAR
  2703. X#else
  2704. X#define    DCL(TYPE,VAR,VAL)    extern    TYPE    VAR
  2705. X#define    DCLX(TYPE,VAR)        extern    TYPE    VAR
  2706. X#endif
  2707. X
  2708. X#define    FALSE    0
  2709. X#define    TRUE    ! FALSE
  2710. X
  2711. X#define    SAME    0
  2712. X
  2713. X#ifdef    EBUG
  2714. X#define    DEBUG
  2715. X#endif
  2716. X
  2717. X#ifdef DEBUG
  2718. X#define    WRITE(STRING)    write(2,STRING,strlen(STRING));write(2,"\n",1)
  2719. X#define    PRINT(FMT,VAR)    fprintf (stderr, FMT, VAR)
  2720. X#define    DASSERT(COND)    assert (COND)
  2721. X#else
  2722. X#define    WRITE(STRING)
  2723. X#define    PRINT(FMT,VAR)
  2724. X#define    DASSERT(COND)
  2725. X#endif
  2726. X
  2727. X#define    QUOTE_CHAR    '"'
  2728. X#define    OPEN_BRACE    '{'
  2729. X#define    CLOSE_BRACE    '}'
  2730. X#define    BSLASH        '\\'
  2731. X
  2732. X#define    YES    'y'
  2733. X#define    NO    'n'
  2734. X
  2735. X
  2736. EOFile includes.h
  2737. chmod u=rw+,g=r++,o=r++ includes.h
  2738. echo '...done' 1>&2
  2739. if [ ! -d . ] ; then
  2740.     echo -n Directory . not found. Creating....
  2741.     mkdir .
  2742.     if [ ! -d . ] ; then
  2743.         echo ...failed
  2744.         echo unable to create directory ..  Please create the directory and try again
  2745.         exit
  2746.     fi
  2747.     echo ...done
  2748. fi
  2749. echo -n "inits.c..." 1>&2
  2750. if test -f inits.c
  2751. then
  2752.     case $# in 
  2753.     0)
  2754.         echo 'exists, `sh filename -o'\'' to overwrite'
  2755.         exit 0;;
  2756.     esac
  2757.     case $1 in 
  2758.     -o)    ;;
  2759.     *)
  2760.         echo 'exists, `sh filename -o'\'' to overwrite'
  2761.         exit 0;;
  2762.     esac
  2763. fi
  2764. sed 's/^X//' << 'EOFile inits.c' > inits.c
  2765. X/*
  2766. X * This program has been written by Kannan Varadhan.  You are welcome to
  2767. X * use, copy, modify, or circulate as you please, provided you do not
  2768. X * charge any fee for any of it, and you do not remove these header
  2769. X * comments from any of these files.
  2770. X *
  2771. X *        -- kva    Mon Dec  4 11:26:37 EST 1989
  2772. X */
  2773. X
  2774. X#include "bibc.h"
  2775. X
  2776. Xresetall (bibitem)
  2777. Xbibrec    *bibitem;
  2778. X
  2779. X{
  2780. Xint    i;
  2781. X
  2782. X    RESET (bibitem, rectype);
  2783. X    RESET (bibitem, citekey);
  2784. X    RESET (bibitem, address);
  2785. X    RESET (bibitem, annote);
  2786. X    RESET (bibitem, author);
  2787. X    RESET (bibitem,    booktitle);
  2788. X    RESET (bibitem,    chapter);
  2789. X    RESET (bibitem,    edition);
  2790. X    RESET (bibitem,    edition);
  2791. X    RESET (bibitem,    editor);
  2792. X    RESET (bibitem,    howpublished);
  2793. X    RESET (bibitem,    institution);
  2794. X    RESET (bibitem,    journal);
  2795. X    RESET (bibitem,    key);
  2796. X    RESET (bibitem,    month);
  2797. X    RESET (bibitem,    note);
  2798. X    RESET (bibitem,    number);
  2799. X    RESET (bibitem,    organisation);
  2800. X    RESET (bibitem,    pages);
  2801. X    RESET (bibitem,    publisher);
  2802. X    RESET (bibitem,    school);
  2803. X    RESET (bibitem,    series);
  2804. X    RESET (bibitem,    title);
  2805. X    RESET (bibitem,    type);
  2806. X    RESET (bibitem,    volume);
  2807. X    RESET (bibitem,    year);
  2808. X    RESET (bibitem, comment);
  2809. X    RESET (bibitem, cross_ref);
  2810. X    for (i = 0; i != usr_defns_ctr; i++)
  2811. X      RESET (bibitem, usr_defns[i]);
  2812. X
  2813. X    return 0;
  2814. X}
  2815. X
  2816. X
  2817. Xinitialise (bibitem)
  2818. Xbibrec    *bibitem;
  2819. X
  2820. X{
  2821. Xchar    *BIBCINIT, *getenv();
  2822. Xchar    *qmark, *colon, *userhlp, *userkey, *nextkey;
  2823. X
  2824. X    resetall (bibitem);
  2825. X
  2826. X#define    STORHELP(VAR,FIELD,VALUE,HELP)         \
  2827. X    {                    \
  2828. X    Strcpy ((VAR)->FIELD.prompt, VALUE);    \
  2829. X    Strcpy ((VAR)->FIELD.helpstring, HELP);    \
  2830. X    }
  2831. X
  2832. X    STORHELP (bibitem,    rectype,    "",    ""    );
  2833. X    STORHELP (bibitem,    citekey,    "CITEKEY",
  2834. X"The key used to cross reference with the \cite command in the\n\
  2835. X main text."                            );
  2836. X    STORHELP (bibitem,    address,    "ADDRESS",
  2837. X"Publisher's address.For major publishing houses, just the city\n\
  2838. X is given, for smaller publishers, you might choose to give the\n\
  2839. X full address."                            );
  2840. X    STORHELP (bibitem,    author,        "AUTHOR",
  2841. X"The name(s) of the author(s).  Separate multiple authors by the\n\
  2842. X keyword 'and'.  See the LaTeX manual for more help."        );
  2843. X    STORHELP (bibitem,    annote,        "ANNOTE",
  2844. X"An annotation. Not used in the standard bibliography styles, but\n\
  2845. X may be used by others."                    );
  2846. X    STORHELP (bibitem,    booktitle,    "BOOKTITLE",
  2847. X"Title of the book, part of which is being cited."        );
  2848. X    STORHELP (bibitem,    chapter,    "CHAPTER",
  2849. X"A chapter number."                        );
  2850. X    STORHELP (bibitem,    edition,    "EDITION",
  2851. X"The edition of the book--for example, 'second'."        );
  2852. X    STORHELP (bibitem,    editor,        "EDITOR",
  2853. X"Name(s) of editor(s), typed as in the author field.  If the author\n\
  2854. X is also indicated, then this field gives the editor of the book or\n\
  2855. X collection in which the refernce appears."            );
  2856. X    STORHELP (bibitem,    howpublished,    "HOWPUBLISHED",
  2857. X"How something strange has been published."            );
  2858. X    STORHELP (bibitem,    institution,    "INSTITUTION",
  2859. X"The institution that published the work."            );
  2860. X    STORHELP (bibitem,    journal,    "JOURNAL",
  2861. X"The name of a journal."                    );
  2862. X    STORHELP (bibitem,    key,        "KEY",
  2863. X"Used for alphabetising and creating a label when the author and\n\
  2864. X editor fields are missing."                    );
  2865. X    STORHELP (bibitem,    month,        "MONTH",
  2866. X"The month in which the work was published.  For an unpublished\n\
  2867. X work, the month in which it was written."            );
  2868. X    STORHELP (bibitem,    note,        "NOTE",
  2869. X"Any additional information that can help the reader."        );
  2870. X    STORHELP (bibitem,    number,        "NUMBER",
  2871. X"The number of a journal, magazine or technical report."    );
  2872. X    STORHELP (bibitem,    organisation,    "ORGANISATION",
  2873. X"The organisation sponsoring the conference."            );
  2874. X    STORHELP (bibitem,    pages,        "PAGES",
  2875. X"One or more page numbers, or range of page numbers, as 42--111,\n\
  2876. X or 7,41,73--97."                        );
  2877. X    STORHELP (bibitem,    publisher,    "PUBLISHER",
  2878. X"The publisher's name."                        );
  2879. X    STORHELP (bibitem,    school,        "SCHOOL",
  2880. X"The name of the school in which the thesis was written."    );
  2881. X    STORHELP (bibitem,    series,        "SERIES",
  2882. X"The name of a series or set of books."                );
  2883. X    STORHELP (bibitem,    title,        "TITLE",
  2884. X"The work's title"                        );
  2885. X    STORHELP (bibitem,    type,        "TYPE",
  2886. X"The type of a technical report, for example, 'Research Note'."    );
  2887. X    STORHELP (bibitem,    volume,        "VOLUME",
  2888. X"The volume of a journal or multivolume work."            );
  2889. X    STORHELP (bibitem,    year,        "YEAR",
  2890. X"The year of publication, or for an unpublished work, the year in\n\
  2891. X which it was written."                        );
  2892. X    STORHELP (bibitem,    comment,    "COMMENT",
  2893. X"Any relevant info associated with this record that you would like\n\
  2894. X to store herein."                        );
  2895. X    STORHELP (bibitem,    cross_ref,    "CROSS-REFERENCE",
  2896. X"used to fill in missing field info in this record from the\n\
  2897. X cross-referenced bib-record..see BiBTeXing manual for more help.");
  2898. X/*
  2899. X * Now that the standard fields are defined, see if the user would like
  2900. X * to define specific fields for themselves.  Such fields are specified
  2901. X * by the user in tthe BIBCINIT environment variables.  The format of
  2902. X * his variable shall be similiar to the MAILPATH variable used by the
  2903. X * korn shell, as....
  2904. X *    <fieldname>?<optional help string>
  2905. X * multiple fields shall be separated by <COLON>s, ':'
  2906. X * A maximum of USR_DEFNS_MAX is taken....
  2907. X */
  2908. X    BIBCINIT = getenv ("BIBCINIT");
  2909. X    if (BIBCINIT)
  2910. X      {
  2911. X      userkey = BIBCINIT;
  2912. X      while (userkey != (char *) NULL)
  2913. X        {
  2914. X        nextkey = (char *) NULL;
  2915. X        userhlp = DEFAULT_USERHLP;
  2916. X        if ((colon = Index (userkey, ':')) != (char *) NULL)
  2917. X          {
  2918. X          nextkey = colon + 1;
  2919. X          *colon = '\0';
  2920. X          }
  2921. X        if ((qmark = Index (userkey, '?')) != (char *) NULL)
  2922. X          {
  2923. X          userhlp = qmark + 1;
  2924. X          *qmark = '\0';
  2925. X          }
  2926. X        STORHELP (bibitem, usr_defns[usr_defns_ctr], userkey, userhlp);
  2927. X        usr_defns_ctr++;
  2928. X        if (usr_defns_ctr < USR_DEFNS_MAX)
  2929. X          userkey = nextkey;
  2930. X        else
  2931. X          userkey = (char *) NULL /* quit while we are ahead ;-) */;
  2932. X        if (qmark != (char *) NULL) *qmark = '?';
  2933. X        if (colon != (char *) NULL) *colon = ':';
  2934. X        qmark = colon = (char *) NULL;
  2935. X        }   
  2936. X      }
  2937. X#undef    STORHELP
  2938. X    return 0;
  2939. X}
  2940. X
  2941. X
  2942. Xprocess_args (argc, argv)
  2943. Xint    argc;
  2944. Xchar    *argv[];
  2945. X
  2946. X{
  2947. X#define    SHIFT    i++
  2948. X#define    args(str) (! Strcmp (argv[i], str))
  2949. X
  2950. Xint    i;
  2951. Xchar    error[80];
  2952. X
  2953. X    for (i = 1; i < argc; SHIFT)
  2954. X      {
  2955. X      if (args ("-i") || args ("-verify"))
  2956. X        { _O_verify = _O_verbose = TRUE; continue; }
  2957. X      if args ("-verbose")
  2958. X        { _O_verbose = FALSE; continue; }
  2959. X      if args ("+verbose")
  2960. X        { _O_verbose = TRUE; continue; }
  2961. X      if args ("-pester")
  2962. X        { _O_pester_usr = FALSE; continue; }
  2963. X      if args ("+pester")
  2964. X        { _O_pester_usr = TRUE; continue; }
  2965. X      if args ("-help")
  2966. X        { _O_help = TRUE; continue; }
  2967. X      if args ("-file")
  2968. X        { SHIFT;
  2969. X          outfile = (FILE *) fopen (argv[i], "a");
  2970. X          if (outfile)
  2971. X            Strcpy (_O_outfilename, argv[i]);
  2972. X          else
  2973. X        {
  2974. X        Sprintf (error, "bibc: file %s could not be opened", argv[i]);
  2975. X        perror (error);
  2976. X        outfile = stdout;
  2977. X        }
  2978. X          continue;
  2979. X        }
  2980. X      /* default: */
  2981. X        {
  2982. X        Fprintf (stderr, "bibc: %s is an invalid argument\n", argv[i]);
  2983. X        _O_help = TRUE;
  2984. X        continue;
  2985. X        }
  2986. X      }
  2987. X    if (_O_help)
  2988. X      {
  2989. X      (void) usage ();
  2990. X      exit (0);
  2991. X      }
  2992. X    return 0;
  2993. X#undef SHIFT
  2994. X#undef args
  2995. X}
  2996. X#define    USAGE    "Usage: bibc [-i|-verify] [+|-verbose] [+|-pester] [-file <filename>] [-help]\n"
  2997. X
  2998. X
  2999. Xusage ()
  3000. X
  3001. X{
  3002. X    Fprintf (stderr, USAGE);
  3003. XFprintf (stderr, "\t-i\t\t\tInquire whether to commit a record\n");
  3004. XFprintf (stderr, "\t-verify\t\t\tSame as above, a duplicate form\n");
  3005. XFprintf (stderr, "\t-verbose\t\tTurn off verbose flag\n");
  3006. XFprintf (stderr, "\t+verbose\t\tTurn on verbose flag\n");
  3007. XFprintf (stderr, "\t-pester\t\t\tDo not insist, even for required fields\n");
  3008. XFprintf (stderr, "\t+pester\t\t\tInsist once for required fields\n");
  3009. XFprintf (stderr, "\t-file <filename>\tOutput bib entries to <filename>\n");
  3010. XFprintf (stderr, "\t-help\t\t\tPrint this help output\n");
  3011. X    return 0;
  3012. X}
  3013. X
  3014. EOFile inits.c
  3015. chmod u=rw+,g=rw+,o=r++ inits.c
  3016. echo '...done' 1>&2
  3017. if [ ! -d . ] ; then
  3018.     echo -n Directory . not found. Creating....
  3019.     mkdir .
  3020.     if [ ! -d . ] ; then
  3021.         echo ...failed
  3022.         echo unable to create directory ..  Please create the directory and try again
  3023.         exit
  3024.     fi
  3025.     echo ...done
  3026. fi
  3027. echo -n "lex.yy.c..." 1>&2
  3028. if test -f lex.yy.c
  3029. then
  3030.     case $# in 
  3031.     0)
  3032.         echo 'exists, `sh filename -o'\'' to overwrite'
  3033.         exit 0;;
  3034.     esac
  3035.     case $1 in 
  3036.     -o)    ;;
  3037.     *)
  3038.         echo 'exists, `sh filename -o'\'' to overwrite'
  3039.         exit 0;;
  3040.     esac
  3041. fi
  3042. sed 's/^X//' << 'EOFile lex.yy.c' > lex.yy.c
  3043. X#define FLEX_COMPRESSED
  3044. X/* A lexical scanner generated by flex */
  3045. X
  3046. X/* scanner skeleton version:
  3047. X * $Header: flex.skel,v 1.1 89/05/24 00:32:10 vern Locked $
  3048. X */
  3049. X
  3050. X#include <stdio.h>
  3051. X
  3052. X#define FLEX_SCANNER
  3053. X
  3054. X/* returned upon end-of-file */
  3055. X#define YY_END_TOK 0
  3056. X
  3057. X/* amount of stuff to slurp up with each read */
  3058. X#define YY_READ_BUF_SIZE 8192
  3059. X
  3060. X#define YY_BUF_SIZE (YY_READ_BUF_SIZE * 2) /* size of input buffer */
  3061. X
  3062. X/* number of characters one rule can match.  One less than YY_BUF_SIZE to make
  3063. X * sure we never access beyond the end of an array
  3064. X */
  3065. X#define YY_BUF_MAX (YY_BUF_SIZE - 1)
  3066. X
  3067. X/* copy whatever the last rule matched to the standard output */
  3068. X
  3069. X#define ECHO fputs( yytext, yyout )
  3070. X
  3071. X/* gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
  3072. X * is returned in "result".
  3073. X */
  3074. X#define YY_INPUT(buf,result,max_size) \
  3075. X    if ( (result = read( fileno(yyin), buf, max_size )) < 0 ) \
  3076. X        YY_FATAL_ERROR( "read() in flex scanner failed" );
  3077. X#define YY_NULL 0
  3078. X
  3079. X/* report a fatal error */
  3080. X#define YY_FATAL_ERROR(msg) \
  3081. X    { \
  3082. X    fputs( msg, stderr ); \
  3083. X    putc( '\n', stderr ); \
  3084. X    exit( 1 ); \
  3085. X    }
  3086. X
  3087. X/* default yywrap function - always treat EOF as an EOF */
  3088. X#define yywrap() 1
  3089. X
  3090. X/* enter a start condition.  This macro really ought to take a parameter,
  3091. X * but we do it the disgusting crufty way that old Unix-lex does it
  3092. X */
  3093. X#define BEGIN yy_start = 1 +
  3094. X
  3095. X/* default declaration of generated scanner - a define so the user can
  3096. X * easily add parameters
  3097. X */
  3098. X#define YY_DECL int yylex()
  3099. X
  3100. X/* code executed at the end of each rule */
  3101. X#define YY_BREAK break;
  3102. X
  3103. X#define YY_END_OF_BUFFER_CHAR 0
  3104. X
  3105. X/* done after the current pattern has been matched and before the
  3106. X * corresponding action - sets up yytext
  3107. X */
  3108. X#define YY_DO_BEFORE_ACTION \
  3109. X    yytext = yy_bp; \
  3110. X    yy_hold_char = *yy_cp; \
  3111. X    *yy_cp = '\0'; \
  3112. X    yy_c_buf_p = yy_cp;
  3113. X
  3114. X/* returns the length of the matched text */
  3115. X#define yyleng (yy_cp - yy_bp)
  3116. X
  3117. X#define EOB_ACT_RESTART_SCAN 0
  3118. X#define EOB_ACT_END_OF_FILE 1
  3119. X#define EOB_ACT_LAST_MATCH 2
  3120. X
  3121. X/* return all but the first 'n' matched characters back to the input stream */
  3122. X#define yyless(n) \
  3123. X    { \
  3124. X    *yy_cp = yy_hold_char; /* undo effects of setting up yytext */ \
  3125. X    yy_c_buf_p = yy_cp = yy_bp + n; \
  3126. X    YY_DO_BEFORE_ACTION; /* set up yytext again */ \
  3127. X    }
  3128. X
  3129. X#define unput(c) yyunput( c, yy_bp )
  3130. X
  3131. X#define YY_USER_ACTION
  3132. X
  3133. X# line 1 "bibl.l"
  3134. X#define INITIAL 0
  3135. X# line 2 "bibl.l"
  3136. X
  3137. X/*
  3138. X * This program has been written by Kannan Varadhan.  You are welcome to
  3139. X * use, copy, modify, or circulate as you please, provided you do not
  3140. X * charge any fee for any of it, and you do not remove these header
  3141. X * comments from any of these files.
  3142. X *
  3143. X *        -- kva    Mon Dec  4 11:26:37 EST 1989
  3144. X */
  3145. X
  3146. X#include    "bibc.h"
  3147. X#undef    YY_INPUT
  3148. X#define    YY_INPUT(buf,reslt,msize)    my_input (buf, &reslt, msize)
  3149. X
  3150. Xmy_input (buf,reslt, size)
  3151. Xchar    *buf;
  3152. Xint    *reslt;
  3153. Xint    size;
  3154. X
  3155. X{
  3156. Xchar    inputln[80];
  3157. X
  3158. X    bzero (inputln, 80);
  3159. X    if (! GETS (inputln, 80))
  3160. X      Strcpy (buf, "EOF");
  3161. X    else
  3162. X      Strncpy (buf, inputln, size);
  3163. X    Strcat (buf, "!");
  3164. X#ifdef    FLEX_DEBUG
  3165. X    Fprintf (stderr, "buf contains: %s\n", buf);
  3166. X#endif
  3167. X    return *reslt = strlen (buf);
  3168. X}
  3169. X
  3170. X
  3171. Xmy_yylex ()
  3172. X
  3173. X{
  3174. X#define    PROMPTSTR            "\
  3175. XWhat kind of record would you like to enter (one of the following)?\n\
  3176. X    article        book        booklet        conference\n\
  3177. X    inbook        incollection    inproceedings    manual\n\
  3178. X    mastersthesis    msthesis    misc        phdthesis\n\
  3179. X    proceedings    techreport    unpublished\n\
  3180. Xor    EDIT        quit\n"
  3181. X    
  3182. X    Fprintf (stderr, PROMPTSTR);
  3183. X    return yylex ();
  3184. X}
  3185. X
  3186. X# line 54 "bibl.l"
  3187. X#define YY_END_OF_BUFFER 116
  3188. Xtypedef int yy_state_type;
  3189. Xstatic short int yy_accept[251] =
  3190. X    {   0,
  3191. X        0,    0,  116,  115,  114,  115,  115,  115,  115,  115,
  3192. X      115,  115,  115,  115,  115,  115,  114,    0,    0,    0,
  3193. X        1,    0,    0,   12,    0,    0,    0,    0,    0,    0,
  3194. X        0,    0,   90,    0,  100,    0,    0,    0,    2,    0,
  3195. X        0,   13,    0,    0,    0,    0,    0,    0,   69,    0,
  3196. X       62,    0,   72,    0,   80,    0,    0,   91,    0,  101,
  3197. X        0,    0,  112,    3,    0,    0,   14,    0,   22,    0,
  3198. X       26,    0,   36,    0,   47,    0,   51,    0,   70,    0,
  3199. X       63,    0,   73,    0,   81,    0,    0,   92,    0,  102,
  3200. X        0,  113,    4,    0,    8,    0,   15,    0,   23,    0,
  3201. X
  3202. X       27,    0,   37,    0,   48,    0,   52,    0,   71,   64,
  3203. X        0,   74,    0,   82,    0,  111,   93,    0,  103,    0,
  3204. X        5,    0,    9,    0,   16,    0,   24,    0,   28,    0,
  3205. X       38,    0,   49,    0,   53,    0,   65,    0,   75,    0,
  3206. X       83,    0,   94,    0,  104,    0,    6,    0,   10,    0,
  3207. X       17,    0,   25,   29,    0,   39,    0,   50,   54,    0,
  3208. X       66,    0,   76,    0,   84,    0,   95,    0,  105,    0,
  3209. X        7,   11,   18,    0,   30,    0,   40,    0,   55,    0,
  3210. X       67,    0,   77,    0,   85,    0,   96,    0,  106,    0,
  3211. X       19,    0,   31,    0,   41,    0,   56,    0,   68,   78,
  3212. X
  3213. X        0,   86,    0,   97,    0,  107,    0,   20,    0,   32,
  3214. X        0,   42,    0,   57,    0,   79,   87,    0,   98,    0,
  3215. X      108,    0,   21,   33,    0,   43,    0,   58,    0,   88,
  3216. X        0,   99,  109,    0,   34,    0,   44,    0,   59,    0,
  3217. X       89,  110,   35,   45,    0,   60,    0,   46,   61,    0
  3218. X    } ;
  3219. X
  3220. Xstatic char yy_ec[128] =
  3221. X    {   0,
  3222. X        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  3223. X        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  3224. X        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  3225. X        1,    1,    2,    1,    1,    1,    1,    1,    1,    1,
  3226. X        1,    1,    1,    1,    1,    1,    1,    3,    3,    3,
  3227. X        3,    3,    3,    3,    3,    3,    3,    1,    1,    1,
  3228. X        1,    1,    1,    1,    3,    3,    3,    4,    5,    6,
  3229. X        3,    3,    7,    3,    3,    3,    3,    3,    8,    3,
  3230. X        3,    3,    3,    9,    3,    3,    3,    3,    3,    3,
  3231. X        1,    1,    1,    1,    1,    1,   10,   11,   12,   13,
  3232. X
  3233. X       14,   15,   16,   17,   18,    3,   19,   20,   21,   22,
  3234. X       23,   24,   25,   26,   27,   28,   29,    3,    3,    3,
  3235. X        3,    3,    1,    1,    1,    1,    1
  3236. X    } ;
  3237. X
  3238. Xstatic char yy_meta[30] =
  3239. X    {   0,
  3240. X        1,    2,    2,    2,    2,    2,    2,    2,    2,    2,
  3241. X        2,    2,    2,    2,    2,    2,    2,    2,    2,    2,
  3242. X        2,    2,    2,    2,    2,    2,    2,    2,    2
  3243. X    } ;
  3244. X
  3245. Xstatic short int yy_base[252] =
  3246. X    {   0,
  3247. X        0,    0,  279,  280,  280,  276,   28,   29,   31,   33,
  3248. X       35,   32,   36,   37,   38,   39,  280,  275,   41,   43,
  3249. X      280,   42,   44,  280,   49,   61,   56,   62,   58,   63,
  3250. X       45,   72,  280,   67,  280,   73,   75,  274,  280,   78,
  3251. X       79,  280,   80,   85,   86,   89,   90,   92,  280,   91,
  3252. X      280,   97,  280,   98,  280,   99,  100,  280,  104,  280,
  3253. X      102,  273,  280,  280,  105,  103,  280,  108,  280,  110,
  3254. X      280,  114,  280,  116,  280,  122,  280,  111,  280,  272,
  3255. X      280,  127,  280,  125,  280,  133,  269,  280,  128,  280,
  3256. X      134,  280,  280,  135,  280,  136,  280,  138,  280,  141,
  3257. X
  3258. X      280,  142,  280,  144,  280,  146,  280,  147,  280,  280,
  3259. X      149,  280,  151,  280,  155,  280,  280,  156,  280,  157,
  3260. X      280,  161,  280,  150,  280,  165,  280,  268,  280,  166,
  3261. X      280,  169,  280,  267,  280,  159,  280,  170,  280,  172,
  3262. X      280,  179,  280,  180,  280,  182,  280,  266,  280,  265,
  3263. X      280,  183,  280,  280,  185,  280,  187,  280,  280,  188,
  3264. X      280,  190,  280,  189,  280,  191,  280,  192,  280,  193,
  3265. X      280,  280,  280,  196,  280,  194,  280,  200,  280,  201,
  3266. X      280,  264,  280,  208,  280,  209,  280,  210,  280,  212,
  3267. X      280,  219,  280,  221,  280,  222,  280,  223,  280,  280,
  3268. X
  3269. X      263,  280,  225,  280,  217,  280,  224,  280,  262,  280,
  3270. X      226,  280,  228,  280,  230,  280,  280,  232,  280,  259,
  3271. X      280,  240,  280,  280,  241,  280,  242,  280,  244,  280,
  3272. X      258,  280,  280,  254,  280,  253,  280,  245,  280,  246,
  3273. X      280,  280,  280,  280,  252,  280,  250,  280,  280,  280,
  3274. X      249
  3275. X    } ;
  3276. X
  3277. Xstatic short int yy_def[252] =
  3278. X    {   0,
  3279. X      250,    1,  250,  250,  250,  251,  251,  251,  251,  251,
  3280. X      251,  251,  251,  251,  251,  251,  250,  251,  251,  251,
  3281. X      250,  251,  251,  250,  251,  251,  251,  251,  251,  251,
  3282. X      251,  251,  250,  251,  250,  251,  251,  251,  250,  251,
  3283. X      251,  250,  251,  251,  251,  251,  251,  251,  250,  251,
  3284. X      250,  251,  250,  251,  250,  251,  251,  250,  251,  250,
  3285. X      251,  251,  250,  250,  251,  251,  250,  251,  250,  251,
  3286. X      250,  251,  250,  251,  250,  251,  250,  251,  250,  251,
  3287. X      250,  251,  250,  251,  250,  251,  251,  250,  251,  250,
  3288. X      251,  250,  250,  251,  250,  251,  250,  251,  250,  251,
  3289. X
  3290. X      250,  251,  250,  251,  250,  251,  250,  251,  250,  250,
  3291. X      251,  250,  251,  250,  251,  250,  250,  251,  250,  251,
  3292. X      250,  251,  250,  251,  250,  251,  250,  251,  250,  251,
  3293. X      250,  251,  250,  251,  250,  251,  250,  251,  250,  251,
  3294. X      250,  251,  250,  251,  250,  251,  250,  251,  250,  251,
  3295. X      250,  251,  250,  250,  251,  250,  251,  250,  250,  251,
  3296. X      250,  251,  250,  251,  250,  251,  250,  251,  250,  251,
  3297. X      250,  250,  250,  251,  250,  251,  250,  251,  250,  251,
  3298. X      250,  251,  250,  251,  250,  251,  250,  251,  250,  251,
  3299. X      250,  251,  250,  251,  250,  251,  250,  251,  250,  250,
  3300. X
  3301. X      251,  250,  251,  250,  251,  250,  251,  250,  251,  250,
  3302. X      251,  250,  251,  250,  251,  250,  250,  251,  250,  251,
  3303. X      250,  251,  250,  250,  251,  250,  251,  250,  251,  250,
  3304. X      251,  250,  250,  251,  250,  251,  250,  251,  250,  251,
  3305. X      250,  250,  250,  250,  251,  250,  251,  250,  250,    0,
  3306. X      250
  3307. X    } ;
  3308. X
  3309. Xstatic short int yy_nxt[310] =
  3310. X    {   0,
  3311. X        4,    5,    6,    6,    7,    6,    6,    6,    6,    8,
  3312. X        9,   10,    6,    6,    6,    6,    6,   11,    6,    6,
  3313. X       12,    6,    6,   13,   14,    6,    6,   15,   16,   17,
  3314. X       21,   19,   17,   17,   24,   20,   17,   17,   17,   33,
  3315. X       35,   27,   17,   39,   17,   17,   55,   37,   38,   28,
  3316. X       42,   34,   30,   23,   22,   25,   26,   17,   29,   51,
  3317. X       36,   31,   17,   49,   53,   32,   41,   56,   58,   40,
  3318. X       43,   44,   45,   17,   60,   54,   17,   47,   59,   64,
  3319. X       17,   67,   48,   62,   46,   52,   69,   71,   50,   57,
  3320. X       73,   75,   79,   77,   68,   65,   61,   66,   81,   83,
  3321. X
  3322. X       85,   17,   80,   90,   95,   88,   93,   70,   72,   97,
  3323. X       86,   99,  107,   82,   74,  101,   94,  103,   76,   78,
  3324. X       89,   98,   96,  105,  108,   84,  112,   87,  110,  117,
  3325. X       91,  106,  100,  102,  114,  119,  121,  123,  104,  125,
  3326. X      111,  113,  127,  129,  120,  131,  115,  133,  135,  124,
  3327. X      137,  149,  139,  118,  122,  132,  141,  143,  145,  128,
  3328. X      159,  130,  147,  126,  140,  134,  151,  154,  142,  144,
  3329. X      156,  161,  136,  163,  148,  138,  146,  150,  152,  155,
  3330. X      165,  167,  157,  169,  173,  160,  175,  162,  177,  179,
  3331. X      183,  181,  185,  187,  189,  193,  176,  191,  164,  170,
  3332. X
  3333. X      178,  195,  197,  168,  174,  166,  184,  192,  186,  200,
  3334. X      202,  204,  196,  206,  188,  180,  182,  198,  219,  190,
  3335. X      208,  194,  210,  212,  214,  221,  217,  224,  207,  226,
  3336. X      203,  228,  209,  230,  201,  205,  215,  222,  211,  213,
  3337. X      218,  233,  235,  237,  220,  239,  244,  246,  225,  227,
  3338. X       18,  249,  234,  248,  243,  242,  229,  238,  231,  241,
  3339. X      232,  240,  236,  223,  216,  199,  172,  171,  158,  153,
  3340. X      116,  245,  247,  109,   92,   63,   17,   17,  250,    3,
  3341. X      250,  250,  250,  250,  250,  250,  250,  250,  250,  250,
  3342. X      250,  250,  250,  250,  250,  250,  250,  250,  250,  250,
  3343. X
  3344. X      250,  250,  250,  250,  250,  250,  250,  250,  250
  3345. X    } ;
  3346. X
  3347. Xstatic short int yy_chk[310] =
  3348. X    {   0,
  3349. X        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  3350. X        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  3351. X        1,    1,    1,    1,    1,    1,    1,    1,    1,    7,
  3352. X        8,    7,    9,   12,   10,    7,   11,   13,   14,   15,
  3353. X       16,   12,   19,   22,   20,   23,   31,   19,   20,   12,
  3354. X       25,   15,   13,    9,    8,   10,   11,   27,   12,   29,
  3355. X       16,   13,   26,   28,   30,   14,   23,   31,   34,   22,
  3356. X       25,   26,   26,   32,   36,   30,   37,   27,   34,   40,
  3357. X       41,   43,   27,   37,   26,   29,   44,   45,   28,   32,
  3358. X       46,   47,   50,   48,   43,   40,   36,   41,   52,   54,
  3359. X
  3360. X       56,   57,   50,   61,   66,   59,   65,   44,   45,   68,
  3361. X       56,   70,   78,   52,   46,   72,   65,   74,   47,   48,
  3362. X       59,   68,   66,   76,   78,   54,   84,   57,   82,   89,
  3363. X       61,   76,   70,   72,   86,   91,   94,   96,   74,   98,
  3364. X       82,   84,  100,  102,   91,  104,   86,  106,  108,   96,
  3365. X      111,  124,  113,   89,   94,  104,  115,  118,  120,  100,
  3366. X      136,  102,  122,   98,  113,  106,  126,  130,  115,  118,
  3367. X      132,  138,  108,  140,  122,  111,  120,  124,  126,  130,
  3368. X      142,  144,  132,  146,  152,  136,  155,  138,  157,  160,
  3369. X      164,  162,  166,  168,  170,  176,  155,  174,  140,  146,
  3370. X
  3371. X      157,  178,  180,  144,  152,  142,  164,  174,  166,  184,
  3372. X      186,  188,  178,  190,  168,  160,  162,  180,  205,  170,
  3373. X      192,  176,  194,  196,  198,  207,  203,  211,  190,  213,
  3374. X      186,  215,  192,  218,  184,  188,  198,  207,  194,  196,
  3375. X      203,  222,  225,  227,  205,  229,  238,  240,  211,  213,
  3376. X      251,  247,  222,  245,  236,  234,  215,  227,  218,  231,
  3377. X      220,  229,  225,  209,  201,  182,  150,  148,  134,  128,
  3378. X       87,  238,  240,   80,   62,   38,   18,    6,    3,  250,
  3379. X      250,  250,  250,  250,  250,  250,  250,  250,  250,  250,
  3380. X      250,  250,  250,  250,  250,  250,  250,  250,  250,  250,
  3381. X
  3382. X      250,  250,  250,  250,  250,  250,  250,  250,  250
  3383. X    } ;
  3384. X
  3385. X/* the intent behind this definition is that it'll catch
  3386. X * any uses of REJECT which flex missed
  3387. X */
  3388. X#define REJECT reject_used_but_not_detected
  3389. X
  3390. XFILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
  3391. X
  3392. X/* these variables are all declared out here so that section 3 code can
  3393. X * manipulate them
  3394. X */
  3395. Xstatic char *yy_c_buf_p;    /* points to current character in buffer */
  3396. Xstatic int yy_init = 1;        /* whether we need to initialize */
  3397. Xstatic int yy_start = 0;    /* start state number */
  3398. X
  3399. X/* true when we've seen an EOF for the current input file */
  3400. Xstatic int yy_eof_has_been_seen;
  3401. X
  3402. Xstatic int yy_n_chars;        /* number of characters read into yy_ch_buf */
  3403. X
  3404. X/* yy_ch_buf has to be 2 characters longer than YY_BUF_SIZE because we need
  3405. X * to put in 2 end-of-buffer characters (this is explained where it is
  3406. X * done) at the end of yy_ch_buf
  3407. X */
  3408. Xstatic char yy_ch_buf[YY_BUF_SIZE + 2];
  3409. X
  3410. X/* yy_hold_char holds the character lost when yytext is formed */
  3411. Xstatic char yy_hold_char;
  3412. Xchar *yytext;
  3413. X
  3414. Xstatic yy_state_type yy_last_accepting_state;
  3415. Xstatic char *yy_last_accepting_cpos;
  3416. X
  3417. Xstatic yy_state_type yy_get_previous_state();
  3418. Xstatic int yy_get_next_buffer();
  3419. X
  3420. Xstatic yyunput();
  3421. Xstatic input();
  3422. X
  3423. XYY_DECL
  3424. X    {
  3425. X    register yy_state_type yy_current_state;
  3426. X    register char *yy_cp, *yy_bp;
  3427. X    register int yy_act;
  3428. X
  3429. X
  3430. X
  3431. X    if ( yy_init )
  3432. X    {
  3433. X    if ( ! yy_start )
  3434. X        yy_start = 1;    /* first start state */
  3435. X
  3436. X    if ( ! yyin )
  3437. X        yyin = stdin;
  3438. X
  3439. X    if ( ! yyout )
  3440. X        yyout = stdout;
  3441. X
  3442. Xnew_file:
  3443. X    /* this is where we enter upon encountering an end-of-file and
  3444. X     * yywrap() indicating that we should continue processing
  3445. X     */
  3446. X
  3447. X    /* we put in the '\n' and start reading from [1] so that an
  3448. X     * initial match-at-newline will be true.
  3449. X     */
  3450. X
  3451. X    yy_ch_buf[0] = '\n';
  3452. X    yy_n_chars = 1;
  3453. X
  3454. X    /* we always need two end-of-buffer characters.  The first causes
  3455. X     * a transition to the end-of-buffer state.  The second causes
  3456. X     * a jam in that state.
  3457. X     */
  3458. X    yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
  3459. X    yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
  3460. X
  3461. X    yy_eof_has_been_seen = 0;
  3462. X
  3463. X    yytext = yy_c_buf_p = &yy_ch_buf[1];
  3464. X    yy_hold_char = *yy_c_buf_p;
  3465. X    yy_init = 0;
  3466. X    }
  3467. X
  3468. X    while ( 1 )        /* loops until end-of-file is reached */
  3469. X    {
  3470. X    yy_cp = yy_c_buf_p;
  3471. X
  3472. X    /* support of yytext */
  3473. X    *yy_cp = yy_hold_char;
  3474. X
  3475. X    /* yy_bp points to the position in yy_ch_buf of the start of the
  3476. X     * current run.
  3477. X     */
  3478. X    yy_bp = yy_cp;
  3479. X
  3480. X    yy_current_state = yy_start;
  3481. X    do
  3482. X        {
  3483. X        register char yy_c = yy_ec[*yy_cp];
  3484. X        if ( yy_accept[yy_current_state] )
  3485. X        {
  3486. X        yy_last_accepting_state = yy_current_state;
  3487. X        yy_last_accepting_cpos = yy_cp;
  3488. X        }
  3489. X        while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  3490. X        {
  3491. X        yy_current_state = yy_def[yy_current_state];
  3492. X        if ( yy_current_state >= 251 )
  3493. X            yy_c = yy_meta[yy_c];
  3494. X        }
  3495. X        yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
  3496. X        ++yy_cp;
  3497. X        }
  3498. X    while ( yy_base[yy_current_state] != 280 );
  3499. X
  3500. X    /* bogus while loop to let YY_BACK_TRACK and EOB_ACT_LAST_MATCH
  3501. X     * actions branch here without introducing an optimizer-daunting
  3502. X     * goto
  3503. X     */
  3504. X    while ( 1 )
  3505. X        {
  3506. X        yy_act = yy_accept[yy_current_state];
  3507. X
  3508. X        YY_DO_BEFORE_ACTION;
  3509. X        YY_USER_ACTION;
  3510. X
  3511. X#ifdef FLEX_DEBUG
  3512. X        fprintf( stderr, "--accepting rule #%d (\"%s\")\n",
  3513. X             yy_act, yytext );
  3514. X#endif
  3515. X        switch ( yy_act )
  3516. X        {
  3517. X        case 0: /* must backtrack */
  3518. X        /* undo the effects of YY_DO_BEFORE_ACTION */
  3519. X        *yy_cp = yy_hold_char;
  3520. X        yy_cp = yy_last_accepting_cpos;
  3521. X        yy_current_state = yy_last_accepting_state;
  3522. X        continue; /* go to "YY_DO_BEFORE_ACTION" */
  3523. X
  3524. Xcase 1:
  3525. X# line 55 "bibl.l"
  3526. Xreturn ARTICLE;
  3527. X    YY_BREAK
  3528. Xcase 2:
  3529. X# line 56 "bibl.l"
  3530. Xreturn ARTICLE;
  3531. X    YY_BREAK
  3532. Xcase 3:
  3533. X# line 57 "bibl.l"
  3534. Xreturn ARTICLE;
  3535. X    YY_BREAK
  3536. Xcase 4:
  3537. X# line 58 "bibl.l"
  3538. Xreturn ARTICLE;
  3539. X    YY_BREAK
  3540. Xcase 5:
  3541. X# line 59 "bibl.l"
  3542. Xreturn ARTICLE;
  3543. X    YY_BREAK
  3544. Xcase 6:
  3545. X# line 60 "bibl.l"
  3546. Xreturn ARTICLE;
  3547. X    YY_BREAK
  3548. Xcase 7:
  3549. X# line 61 "bibl.l"
  3550. Xreturn ARTICLE;
  3551. X    YY_BREAK
  3552. Xcase 8:
  3553. X# line 62 "bibl.l"
  3554. Xreturn BOOK;
  3555. X    YY_BREAK
  3556. Xcase 9:
  3557. X# line 63 "bibl.l"
  3558. Xreturn BOOKLET;
  3559. X    YY_BREAK
  3560. Xcase 10:
  3561. X# line 64 "bibl.l"
  3562. Xreturn BOOKLET;
  3563. X    YY_BREAK
  3564. Xcase 11:
  3565. X# line 65 "bibl.l"
  3566. Xreturn BOOKLET;
  3567. X    YY_BREAK
  3568. Xcase 12:
  3569. X# line 66 "bibl.l"
  3570. Xreturn CONFERENCE;
  3571. X    YY_BREAK
  3572. Xcase 13:
  3573. X# line 67 "bibl.l"
  3574. Xreturn CONFERENCE;
  3575. X    YY_BREAK
  3576. Xcase 14:
  3577. X# line 68 "bibl.l"
  3578. Xreturn CONFERENCE;
  3579. X    YY_BREAK
  3580. Xcase 15:
  3581. X# line 69 "bibl.l"
  3582. Xreturn CONFERENCE;
  3583. X    YY_BREAK
  3584. Xcase 16:
  3585. X# line 70 "bibl.l"
  3586. Xreturn CONFERENCE;
  3587. X    YY_BREAK
  3588. Xcase 17:
  3589. X# line 71 "bibl.l"
  3590. Xreturn CONFERENCE;
  3591. X    YY_BREAK
  3592. Xcase 18:
  3593. X# line 72 "bibl.l"
  3594. Xreturn CONFERENCE;
  3595. X    YY_BREAK
  3596. Xcase 19:
  3597. X# line 73 "bibl.l"
  3598. Xreturn CONFERENCE;
  3599. X    YY_BREAK
  3600. Xcase 20:
  3601. X# line 74 "bibl.l"
  3602. Xreturn CONFERENCE;
  3603. X    YY_BREAK
  3604. Xcase 21:
  3605. X# line 75 "bibl.l"
  3606. Xreturn CONFERENCE;
  3607. X    YY_BREAK
  3608. Xcase 22:
  3609. X# line 76 "bibl.l"
  3610. Xreturn INBOOK;
  3611. X    YY_BREAK
  3612. Xcase 23:
  3613. X# line 77 "bibl.l"
  3614. Xreturn INBOOK;
  3615. X    YY_BREAK
  3616. Xcase 24:
  3617. X# line 78 "bibl.l"
  3618. Xreturn INBOOK;
  3619. X    YY_BREAK
  3620. Xcase 25:
  3621. X# line 79 "bibl.l"
  3622. Xreturn INBOOK;
  3623. X    YY_BREAK
  3624. Xcase 26:
  3625. X# line 80 "bibl.l"
  3626. Xreturn INCOLLECTION;
  3627. X    YY_BREAK
  3628. Xcase 27:
  3629. X# line 81 "bibl.l"
  3630. Xreturn INCOLLECTION;
  3631. X    YY_BREAK
  3632. Xcase 28:
  3633. X# line 82 "bibl.l"
  3634. Xreturn INCOLLECTION;
  3635. X    YY_BREAK
  3636. Xcase 29:
  3637. X# line 83 "bibl.l"
  3638. Xreturn INCOLLECTION;
  3639. X    YY_BREAK
  3640. Xcase 30:
  3641. X# line 84 "bibl.l"
  3642. Xreturn INCOLLECTION;
  3643. X    YY_BREAK
  3644. Xcase 31:
  3645. X# line 85 "bibl.l"
  3646. Xreturn INCOLLECTION;
  3647. X    YY_BREAK
  3648. Xcase 32:
  3649. X# line 86 "bibl.l"
  3650. Xreturn INCOLLECTION;
  3651. X    YY_BREAK
  3652. Xcase 33:
  3653. X# line 87 "bibl.l"
  3654. Xreturn INCOLLECTION;
  3655. X    YY_BREAK
  3656. Xcase 34:
  3657. X# line 88 "bibl.l"
  3658. Xreturn INCOLLECTION;
  3659. X    YY_BREAK
  3660. Xcase 35:
  3661. X# line 89 "bibl.l"
  3662. Xreturn INCOLLECTION;
  3663. X    YY_BREAK
  3664. Xcase 36:
  3665. X# line 90 "bibl.l"
  3666. Xreturn INPROCEEDINGS;
  3667. X    YY_BREAK
  3668. Xcase 37:
  3669. X# line 91 "bibl.l"
  3670. Xreturn INPROCEEDINGS;
  3671. X    YY_BREAK
  3672. Xcase 38:
  3673. X# line 92 "bibl.l"
  3674. Xreturn INPROCEEDINGS;
  3675. X    YY_BREAK
  3676. Xcase 39:
  3677. X# line 93 "bibl.l"
  3678. Xreturn INPROCEEDINGS;
  3679. X    YY_BREAK
  3680. Xcase 40:
  3681. X# line 94 "bibl.l"
  3682. Xreturn INPROCEEDINGS;
  3683. X    YY_BREAK
  3684. Xcase 41:
  3685. X# line 95 "bibl.l"
  3686. Xreturn INPROCEEDINGS;
  3687. X    YY_BREAK
  3688. Xcase 42:
  3689. X# line 96 "bibl.l"
  3690. Xreturn INPROCEEDINGS;
  3691. X    YY_BREAK
  3692. Xcase 43:
  3693. X# line 97 "bibl.l"
  3694. Xreturn INPROCEEDINGS;
  3695. X    YY_BREAK
  3696. Xcase 44:
  3697. X# line 98 "bibl.l"
  3698. Xreturn INPROCEEDINGS;
  3699. X    YY_BREAK
  3700. Xcase 45:
  3701. X# line 99 "bibl.l"
  3702. Xreturn INPROCEEDINGS;
  3703. X    YY_BREAK
  3704. Xcase 46:
  3705. X# line 100 "bibl.l"
  3706. Xreturn INPROCEEDINGS;
  3707. X    YY_BREAK
  3708. Xcase 47:
  3709. X# line 101 "bibl.l"
  3710. Xreturn MANUAL;
  3711. X    YY_BREAK
  3712. Xcase 48:
  3713. X# line 102 "bibl.l"
  3714. Xreturn MANUAL;
  3715. X    YY_BREAK
  3716. Xcase 49:
  3717. X# line 103 "bibl.l"
  3718. Xreturn MANUAL;
  3719. X    YY_BREAK
  3720. Xcase 50:
  3721. X# line 104 "bibl.l"
  3722. Xreturn MANUAL;
  3723. X    YY_BREAK
  3724. Xcase 51:
  3725. X# line 105 "bibl.l"
  3726. Xreturn MASTERSTHESIS;
  3727. X    YY_BREAK
  3728. Xcase 52:
  3729. X# line 106 "bibl.l"
  3730. Xreturn MASTERSTHESIS;
  3731. X    YY_BREAK
  3732. Xcase 53:
  3733. X# line 107 "bibl.l"
  3734. Xreturn MASTERSTHESIS;
  3735. X    YY_BREAK
  3736. Xcase 54:
  3737. X# line 108 "bibl.l"
  3738. Xreturn MASTERSTHESIS;
  3739. X    YY_BREAK
  3740. Xcase 55:
  3741. X# line 109 "bibl.l"
  3742. Xreturn MASTERSTHESIS;
  3743. X    YY_BREAK
  3744. Xcase 56:
  3745. X# line 110 "bibl.l"
  3746. Xreturn MASTERSTHESIS;
  3747. X    YY_BREAK
  3748. Xcase 57:
  3749. X# line 111 "bibl.l"
  3750. Xreturn MASTERSTHESIS;
  3751. X    YY_BREAK
  3752. Xcase 58:
  3753. X# line 112 "bibl.l"
  3754. Xreturn MASTERSTHESIS;
  3755. X    YY_BREAK
  3756. Xcase 59:
  3757. X# line 113 "bibl.l"
  3758. Xreturn MASTERSTHESIS;
  3759. X    YY_BREAK
  3760. Xcase 60:
  3761. X# line 114 "bibl.l"
  3762. Xreturn MASTERSTHESIS;
  3763. X    YY_BREAK
  3764. Xcase 61:
  3765. X# line 115 "bibl.l"
  3766. Xreturn MASTERSTHESIS;
  3767. X    YY_BREAK
  3768. Xcase 62:
  3769. X# line 116 "bibl.l"
  3770. Xreturn MASTERSTHESIS;
  3771. X    YY_BREAK
  3772. Xcase 63:
  3773. X# line 117 "bibl.l"
  3774. Xreturn MASTERSTHESIS;
  3775. X    YY_BREAK
  3776. Xcase 64:
  3777. X# line 118 "bibl.l"
  3778. Xreturn MASTERSTHESIS;
  3779. X    YY_BREAK
  3780. Xcase 65:
  3781. X# line 119 "bibl.l"
  3782. Xreturn MASTERSTHESIS;
  3783. X    YY_BREAK
  3784. Xcase 66:
  3785. X# line 120 "bibl.l"
  3786. Xreturn MASTERSTHESIS;
  3787. X    YY_BREAK
  3788. Xcase 67:
  3789. X# line 121 "bibl.l"
  3790. Xreturn MASTERSTHESIS;
  3791. X    YY_BREAK
  3792. Xcase 68:
  3793. X# line 122 "bibl.l"
  3794. Xreturn MASTERSTHESIS;
  3795. X    YY_BREAK
  3796. Xcase 69:
  3797. X# line 123 "bibl.l"
  3798. Xreturn MISC;
  3799. X    YY_BREAK
  3800. Xcase 70:
  3801. X# line 124 "bibl.l"
  3802. Xreturn MISC;
  3803. X    YY_BREAK
  3804. Xcase 71:
  3805. X# line 125 "bibl.l"
  3806. Xreturn MISC;
  3807. X    YY_BREAK
  3808. Xcase 72:
  3809. X# line 126 "bibl.l"
  3810. Xreturn PHDTHESIS;
  3811. X    YY_BREAK
  3812. Xcase 73:
  3813. X# line 127 "bibl.l"
  3814. Xreturn PHDTHESIS;
  3815. X    YY_BREAK
  3816. Xcase 74:
  3817. X# line 128 "bibl.l"
  3818. Xreturn PHDTHESIS;
  3819. X    YY_BREAK
  3820. Xcase 75:
  3821. X# line 129 "bibl.l"
  3822. Xreturn PHDTHESIS;
  3823. X    YY_BREAK
  3824. Xcase 76:
  3825. X# line 130 "bibl.l"
  3826. Xreturn PHDTHESIS;
  3827. X    YY_BREAK
  3828. Xcase 77:
  3829. X# line 131 "bibl.l"
  3830. Xreturn PHDTHESIS;
  3831. X    YY_BREAK
  3832. Xcase 78:
  3833. X# line 132 "bibl.l"
  3834. Xreturn PHDTHESIS;
  3835. X    YY_BREAK
  3836. Xcase 79:
  3837. X# line 133 "bibl.l"
  3838. Xreturn PHDTHESIS;
  3839. X    YY_BREAK
  3840. Xcase 80:
  3841. X# line 134 "bibl.l"
  3842. Xreturn PROCEEDINGS;
  3843. X    YY_BREAK
  3844. Xcase 81:
  3845. X# line 135 "bibl.l"
  3846. Xreturn PROCEEDINGS;
  3847. X    YY_BREAK
  3848. Xcase 82:
  3849. X# line 136 "bibl.l"
  3850. Xreturn PROCEEDINGS;
  3851. X    YY_BREAK
  3852. Xcase 83:
  3853. X# line 137 "bibl.l"
  3854. Xreturn PROCEEDINGS;
  3855. X    YY_BREAK
  3856. Xcase 84:
  3857. X# line 138 "bibl.l"
  3858. Xreturn PROCEEDINGS;
  3859. X    YY_BREAK
  3860. Xcase 85:
  3861. X# line 139 "bibl.l"
  3862. Xreturn PROCEEDINGS;
  3863. X    YY_BREAK
  3864. Xcase 86:
  3865. X# line 140 "bibl.l"
  3866. Xreturn PROCEEDINGS;
  3867. X    YY_BREAK
  3868. Xcase 87:
  3869. X# line 141 "bibl.l"
  3870. Xreturn PROCEEDINGS;
  3871. X    YY_BREAK
  3872. Xcase 88:
  3873. X# line 142 "bibl.l"
  3874. Xreturn PROCEEDINGS;
  3875. X    YY_BREAK
  3876. Xcase 89:
  3877. X# line 143 "bibl.l"
  3878. Xreturn PROCEEDINGS;
  3879. X    YY_BREAK
  3880. Xcase 90:
  3881. X# line 144 "bibl.l"
  3882. Xreturn TECHREPORT;
  3883. X    YY_BREAK
  3884. Xcase 91:
  3885. X# line 145 "bibl.l"
  3886. Xreturn TECHREPORT;
  3887. X    YY_BREAK
  3888. Xcase 92:
  3889. X# line 146 "bibl.l"
  3890. Xreturn TECHREPORT;
  3891. X    YY_BREAK
  3892. Xcase 93:
  3893. X# line 147 "bibl.l"
  3894. Xreturn TECHREPORT;
  3895. X    YY_BREAK
  3896. Xcase 94:
  3897. X# line 148 "bibl.l"
  3898. Xreturn TECHREPORT;
  3899. X    YY_BREAK
  3900. Xcase 95:
  3901. X# line 149 "bibl.l"
  3902. Xreturn TECHREPORT;
  3903. X    YY_BREAK
  3904. Xcase 96:
  3905. X# line 150 "bibl.l"
  3906. Xreturn TECHREPORT;
  3907. X    YY_BREAK
  3908. Xcase 97:
  3909. X# line 151 "bibl.l"
  3910. Xreturn TECHREPORT;
  3911. X    YY_BREAK
  3912. Xcase 98:
  3913. X# line 152 "bibl.l"
  3914. Xreturn TECHREPORT;
  3915. X    YY_BREAK
  3916. Xcase 99:
  3917. X# line 153 "bibl.l"
  3918. Xreturn TECHREPORT;
  3919. X    YY_BREAK
  3920. Xcase 100:
  3921. X# line 154 "bibl.l"
  3922. Xreturn UNPUBLISHED;
  3923. X    YY_BREAK
  3924. Xcase 101:
  3925. X# line 155 "bibl.l"
  3926. Xreturn UNPUBLISHED;
  3927. X    YY_BREAK
  3928. Xcase 102:
  3929. X# line 156 "bibl.l"
  3930. Xreturn UNPUBLISHED;
  3931. X    YY_BREAK
  3932. Xcase 103:
  3933. X# line 157 "bibl.l"
  3934. Xreturn UNPUBLISHED;
  3935. X    YY_BREAK
  3936. Xcase 104:
  3937. X# line 158 "bibl.l"
  3938. Xreturn UNPUBLISHED;
  3939. X    YY_BREAK
  3940. Xcase 105:
  3941. X# line 159 "bibl.l"
  3942. Xreturn UNPUBLISHED;
  3943. X    YY_BREAK
  3944. Xcase 106:
  3945. X# line 160 "bibl.l"
  3946. Xreturn UNPUBLISHED;
  3947. X    YY_BREAK
  3948. Xcase 107:
  3949. X# line 161 "bibl.l"
  3950. Xreturn UNPUBLISHED;
  3951. X    YY_BREAK
  3952. Xcase 108:
  3953. X# line 162 "bibl.l"
  3954. Xreturn UNPUBLISHED;
  3955. X    YY_BREAK
  3956. Xcase 109:
  3957. X# line 163 "bibl.l"
  3958. Xreturn UNPUBLISHED;
  3959. X    YY_BREAK
  3960. Xcase 110:
  3961. X# line 164 "bibl.l"
  3962. Xreturn UNPUBLISHED;
  3963. X    YY_BREAK
  3964. Xcase 111:
  3965. X# line 165 "bibl.l"
  3966. Xreturn FLD_NULL;
  3967. X    YY_BREAK
  3968. Xcase 112:
  3969. X# line 166 "bibl.l"
  3970. Xreturn FLD_NULL;
  3971. X    YY_BREAK
  3972. Xcase 113:
  3973. X# line 167 "bibl.l"
  3974. Xreturn FLD_EDITOR;
  3975. X    YY_BREAK
  3976. Xcase 114:
  3977. X# line 168 "bibl.l"
  3978. Xreturn FLD_ERROR;
  3979. X    YY_BREAK
  3980. Xcase 115:
  3981. X# line 169 "bibl.l"
  3982. XECHO;
  3983. X    YY_BREAK
  3984. X
  3985. X        case YY_END_OF_BUFFER:
  3986. X            /* undo the effects of YY_DO_BEFORE_ACTION */
  3987. X            *yy_cp = yy_hold_char;
  3988. X
  3989. X            yytext = yy_bp;
  3990. X
  3991. X            switch ( yy_get_next_buffer() )
  3992. X            {
  3993. X            case EOB_ACT_END_OF_FILE:
  3994. X                {
  3995. X                if ( yywrap() )
  3996. X                {
  3997. X                /* note: because we've taken care in
  3998. X                 * yy_get_next_buffer() to have set up yytext,
  3999. X                 * we can now set up yy_c_buf_p so that if some
  4000. X                 * total hoser (like flex itself) wants
  4001. X                 * to call the scanner after we return the
  4002. X                 * YY_NULL, it'll still work - another YY_NULL
  4003. X                 * will get returned.
  4004. X                 */
  4005. X                yy_c_buf_p = yytext;
  4006. X                return ( YY_NULL );
  4007. X                }
  4008. X
  4009. X                else
  4010. X                goto new_file;
  4011. X                }
  4012. X                break;
  4013. X
  4014. X            case EOB_ACT_RESTART_SCAN:
  4015. X                yy_c_buf_p = yytext;
  4016. X                yy_hold_char = *yy_c_buf_p;
  4017. X                break;
  4018. X
  4019. X            case EOB_ACT_LAST_MATCH:
  4020. X                yy_c_buf_p = &yy_ch_buf[yy_n_chars];
  4021. X
  4022. X                yy_current_state = yy_get_previous_state();
  4023. X
  4024. X                yy_cp = yy_c_buf_p;
  4025. X                yy_bp = yytext;
  4026. X                continue; /* go to "YY_DO_BEFORE_ACTION" */
  4027. X            }
  4028. X            break;
  4029. X
  4030. X        default:
  4031. X            printf( "action # %d\n", yy_act );
  4032. X            YY_FATAL_ERROR( "fatal flex scanner internal error" );
  4033. X        }
  4034. X
  4035. X        break; /* exit bogus while loop */
  4036. X        }
  4037. X    }
  4038. X    }
  4039. X
  4040. X
  4041. X/* yy_get_next_buffer - try to read in new buffer
  4042. X *
  4043. X * synopsis
  4044. X *     int yy_get_next_buffer();
  4045. X *     
  4046. X * returns a code representing an action
  4047. X *     EOB_ACT_LAST_MATCH - 
  4048. X *     EOB_ACT_RESTART_SCAN - restart the scanner
  4049. X *     EOB_ACT_END_OF_FILE - end of file
  4050. X */
  4051. X
  4052. Xstatic int yy_get_next_buffer()
  4053. X
  4054. X    {
  4055. X    if ( yy_c_buf_p != &yy_ch_buf[yy_n_chars + 1] )
  4056. X    {
  4057. X    YY_FATAL_ERROR( "NULL in input" );
  4058. X    /*NOTREACHED*/
  4059. X    }
  4060. X
  4061. X    else
  4062. X    { /* try to read more data */
  4063. X    register char *dest = yy_ch_buf;
  4064. X    register char *source = yytext - 1; /* copy prev. char, too */
  4065. X    register int number_to_move, i;
  4066. X    int ret_val;
  4067. X    
  4068. X    /* first move last chars to start of buffer */
  4069. X    number_to_move = yy_c_buf_p - yytext;
  4070. X
  4071. X    for ( i = 0; i < number_to_move; ++i )
  4072. X        *(dest++) = *(source++);
  4073. X
  4074. X    if ( yy_eof_has_been_seen )
  4075. X        /* don't do the read, it's not guaranteed to return an EOF,
  4076. X         * just force an EOF
  4077. X         */
  4078. X        yy_n_chars = 0;
  4079. X
  4080. X    else
  4081. X        /* read in more data */
  4082. X        YY_INPUT( (&yy_ch_buf[number_to_move]), yy_n_chars,
  4083. X              YY_BUF_SIZE - number_to_move - 1 );
  4084. X
  4085. X    if ( yy_n_chars == 0 )
  4086. X        {
  4087. X        if ( number_to_move == 1 )
  4088. X        ret_val = EOB_ACT_END_OF_FILE;
  4089. X        else
  4090. X        ret_val = EOB_ACT_LAST_MATCH;
  4091. X
  4092. X        yy_eof_has_been_seen = 1;
  4093. X        }
  4094. X
  4095. X    else
  4096. X        ret_val = EOB_ACT_RESTART_SCAN;
  4097. X
  4098. X    yy_n_chars += number_to_move;
  4099. X    yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
  4100. X    yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
  4101. X
  4102. X    /* yytext begins at the second character in
  4103. X     * yy_ch_buf; the first character is the one which
  4104. X     * preceded it before reading in the latest buffer;
  4105. X     * it needs to be kept around in case it's a
  4106. X     * newline, so yy_get_previous_state() will have
  4107. X     * with '^' rules active
  4108. X     */
  4109. X
  4110. X    yytext = &yy_ch_buf[1];
  4111. X
  4112. X    return ( ret_val );
  4113. X    }
  4114. X    }
  4115. X
  4116. X
  4117. X/* yy_get_previous_state - get the state just before the EOB char was reached
  4118. X *
  4119. X * synopsis
  4120. X *     yy_state_type yy_get_previous_state();
  4121. X */
  4122. X
  4123. Xstatic yy_state_type yy_get_previous_state()
  4124. X
  4125. X    {
  4126. X    register yy_state_type yy_current_state;
  4127. X    register char *yy_cp;
  4128. X
  4129. X    yy_current_state = yy_start;
  4130. X
  4131. X    for ( yy_cp = yytext; yy_cp < yy_c_buf_p; ++yy_cp )
  4132. X    {
  4133. X    register char yy_c = yy_ec[*yy_cp];
  4134. X    if ( yy_accept[yy_current_state] )
  4135. X        {
  4136. X        yy_last_accepting_state = yy_current_state;
  4137. X        yy_last_accepting_cpos = yy_cp;
  4138. X        }
  4139. X    while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  4140. X        {
  4141. X        yy_current_state = yy_def[yy_current_state];
  4142. X        if ( yy_current_state >= 251 )
  4143. X        yy_c = yy_meta[yy_c];
  4144. X        }
  4145. X    yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
  4146. X    }
  4147. X
  4148. X    return ( yy_current_state );
  4149. X    }
  4150. X
  4151. X
  4152. Xstatic yyunput( c, yy_bp )
  4153. Xint c;
  4154. Xregister char *yy_bp;
  4155. X
  4156. X    {
  4157. X    register char *yy_cp = yy_c_buf_p;
  4158. X
  4159. X    *yy_cp = yy_hold_char; /* undo effects of setting up yytext */
  4160. X
  4161. X    if ( yy_cp < yy_ch_buf + 2 )
  4162. X    { /* need to shift things up to make room */
  4163. X    register int number_to_move = yy_n_chars + 2; /* +2 for EOB chars */
  4164. X    register char *dest = &yy_ch_buf[YY_BUF_SIZE + 2];
  4165. X    register char *source = &yy_ch_buf[number_to_move];
  4166. X
  4167. X    while ( source > yy_ch_buf )
  4168. X        *--dest = *--source;
  4169. X
  4170. X    yy_cp += dest - source;
  4171. X    yy_bp += dest - source;
  4172. X
  4173. X    if ( yy_cp < yy_ch_buf + 2 )
  4174. X        YY_FATAL_ERROR( "flex scanner push-back overflow" );
  4175. X    }
  4176. X
  4177. X    if ( yy_cp > yy_bp && yy_cp[-1] == '\n' )
  4178. X    yy_cp[-2] = '\n';
  4179. X
  4180. X    *--yy_cp = c;
  4181. X
  4182. X    YY_DO_BEFORE_ACTION; /* set up yytext again */
  4183. X    }
  4184. X
  4185. X
  4186. Xstatic int input()
  4187. X
  4188. X    {
  4189. X    int c;
  4190. X    char *yy_cp = yy_c_buf_p;
  4191. X
  4192. X    *yy_cp = yy_hold_char;
  4193. X
  4194. X    if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
  4195. X    { /* need more input */
  4196. X    yytext = yy_c_buf_p;
  4197. X    ++yy_c_buf_p;
  4198. X
  4199. X    switch ( yy_get_next_buffer() )
  4200. X        {
  4201. X        /* this code, unfortunately, is somewhat redundant with
  4202. X         * that above
  4203. X         */
  4204. X        case EOB_ACT_END_OF_FILE:
  4205. X        {
  4206. X        if ( yywrap() )
  4207. X            {
  4208. X            yy_c_buf_p = yytext;
  4209. X            return ( EOF );
  4210. X            }
  4211. X
  4212. X        yy_ch_buf[0] = '\n';
  4213. X        yy_n_chars = 1;
  4214. X        yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
  4215. X        yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
  4216. X        yy_eof_has_been_seen = 0;
  4217. X        yytext = yy_c_buf_p = &yy_ch_buf[1];
  4218. X        yy_hold_char = *yy_c_buf_p;
  4219. X
  4220. X        return ( input() );
  4221. X        }
  4222. X        break;
  4223. X
  4224. X        case EOB_ACT_RESTART_SCAN:
  4225. X        yy_c_buf_p = yytext;
  4226. X        break;
  4227. X
  4228. X        case EOB_ACT_LAST_MATCH:
  4229. X        YY_FATAL_ERROR( "unexpected last match in input()" );
  4230. X        }
  4231. X    }
  4232. X
  4233. X    c = *yy_c_buf_p;
  4234. X    yy_hold_char = *++yy_c_buf_p;
  4235. X
  4236. X    return ( c );
  4237. X    }
  4238. X# line 169 "bibl.l"
  4239. X
  4240. X
  4241. EOFile lex.yy.c
  4242. chmod u=rw+,g=r++,o=r++ lex.yy.c
  4243. echo '...done' 1>&2
  4244. if [ ! -d . ] ; then
  4245.     echo -n Directory . not found. Creating....
  4246.     mkdir .
  4247.     if [ ! -d . ] ; then
  4248.         echo ...failed
  4249.         echo unable to create directory ..  Please create the directory and try again
  4250.         exit
  4251.     fi
  4252.     echo ...done
  4253. fi
  4254. echo -n "lexstrings.lex..." 1>&2
  4255. if test -f lexstrings.lex
  4256. then
  4257.     case $# in 
  4258.     0)
  4259.         echo 'exists, `sh filename -o'\'' to overwrite'
  4260.         exit 0;;
  4261.     esac
  4262.     case $1 in 
  4263.     -o)    ;;
  4264.     *)
  4265.         echo 'exists, `sh filename -o'\'' to overwrite'
  4266.         exit 0;;
  4267.     esac
  4268. fi
  4269. sed 's/^X//' << 'EOFile lexstrings.lex' > lexstrings.lex
  4270. XARTICLE        a        article
  4271. XBOOK        book        book
  4272. XBOOKLET        bookl        booklet
  4273. XCONFERENCE    c        conference
  4274. XINBOOK        inb        inbook
  4275. XINCOLLECTION    inc        incollection
  4276. XINPROCEEDINGS    inp        inproceedings
  4277. XMANUAL        man        manual
  4278. XMASTERSTHESIS    mas        mastersthesis
  4279. XMASTERSTHESIS    ms        msthesis
  4280. XMISC        mi        misc
  4281. XPHDTHESIS    ph        phdthesis
  4282. XPROCEEDINGS    pr        proceesings
  4283. XTECHREPORT    t        techreport
  4284. XUNPUBLISHED    u        unpublished
  4285. EOFile lexstrings.lex
  4286. chmod u=rw+,g=r++,o=r++ lexstrings.lex
  4287. echo '...done' 1>&2
  4288. if [ ! -d . ] ; then
  4289.     echo -n Directory . not found. Creating....
  4290.     mkdir .
  4291.     if [ ! -d . ] ; then
  4292.         echo ...failed
  4293.         echo unable to create directory ..  Please create the directory and try again
  4294.         exit
  4295.     fi
  4296.     echo ...done
  4297. fi
  4298. echo -n "lib_bib.c..." 1>&2
  4299. if test -f lib_bib.c
  4300. then
  4301.     case $# in 
  4302.     0)
  4303.         echo 'exists, `sh filename -o'\'' to overwrite'
  4304.         exit 0;;
  4305.     esac
  4306.     case $1 in 
  4307.     -o)    ;;
  4308.     *)
  4309.         echo 'exists, `sh filename -o'\'' to overwrite'
  4310.         exit 0;;
  4311.     esac
  4312. fi
  4313. sed 's/^X//' << 'EOFile lib_bib.c' > lib_bib.c
  4314. X/*
  4315. X * This program has been written by Kannan Varadhan.  You are welcome to
  4316. X * use, copy, modify, or circulate as you please, provided you do not
  4317. X * charge any fee for any of it, and you do not remove these header
  4318. X * comments from any of these files.
  4319. X *
  4320. X *        -- kva    Mon Dec  4 11:26:37 EST 1989
  4321. X */
  4322. X
  4323. X#include    "includes.h"
  4324. X
  4325. Xchar    *curfile;
  4326. Xchar    **bibflist;
  4327. Xchar    *get_atsign();
  4328. X
  4329. Xchar    *
  4330. Xmy_gets (buffer, size)
  4331. X/*
  4332. X * This is an emulation of gets() using fgets.3
  4333. X * This routine reads everything upto a newline, using fgets.3
  4334. X * 
  4335. X * OUTPUT: Returns buffer on exit, (char *) NULL on error
  4336. X * The contents of buffer are the input string, a max of (size -1)
  4337. X * characters are filled on exit,
  4338. X * The buffer is zeroed and returned on EOF.
  4339. X *
  4340. X * This routine only deals with EOF as an error cleanly.  On any other 
  4341. X * error returned by fgets.3, this routine will return will return
  4342. X * (char *) NULL and a partially filled buffer....*sigh*
  4343. X *
  4344. X * if EMUL_GETS is turned on, (it probably should, neh? :-) then
  4345. X * it converts any trailing NEWLINE character ('\n') to a NIL ('\0')
  4346. X * character, else, it leaves them alone
  4347. X */
  4348. Xchar    *buffer;
  4349. Xint    size;
  4350. X
  4351. X#ifdef BUFSIZE
  4352. X#undef BUFSIZE
  4353. X#endif
  4354. X#define    BUFSIZE    512
  4355. X#define    EMUL_GETS
  4356. X
  4357. X{
  4358. Xint    sizeleft, cursize;
  4359. Xchar    lbuf[BUFSIZE];    /* These figures are unimportant...leave well alone */
  4360. Xchar    *foo, *answer;
  4361. Xint    done;
  4362. X
  4363. X    sizeleft = size - 1;
  4364. X    bzero (buffer, size);
  4365. X    answer = buffer;
  4366. X    done = 0;
  4367. X
  4368. X    while (done != 1)
  4369. X      {
  4370. X      if (fgets (lbuf, BUFSIZE, stdin) == (char *) NULL)
  4371. X        {
  4372. X        done = 1    /* EOF or ERROR    */    ;
  4373. X        answer = (char *) NULL;
  4374. X        }
  4375. X      else if ((foo = Index (lbuf, '\n')) != (char *) NULL)
  4376. X        {            /* DONE */
  4377. X        if (sizeleft > 0)
  4378. X          Strncat (answer, lbuf, sizeleft);
  4379. X        done = 1;
  4380. X        }
  4381. X      else if (sizeleft > 0)
  4382. X        {            /* COPY    */
  4383. X        cursize = strlen (lbuf);
  4384. X        if (cursize <= sizeleft)
  4385. X          {
  4386. X          Strncat (answer, lbuf, cursize);
  4387. X          sizeleft -= cursize;
  4388. X          }
  4389. X        else
  4390. X          {
  4391. X          Strncat (answer, lbuf, sizeleft);
  4392. X          sizeleft = 0;
  4393. X          }
  4394. X        }
  4395. X      }
  4396. X
  4397. X#ifdef EMUL_GETS
  4398. X    if ((foo = Index (answer, '\n')) != (char *) NULL)
  4399. X      *foo = '\0';
  4400. X#endif
  4401. X    return answer;
  4402. X}
  4403. X
  4404. X
  4405. Xanswer (string, resp)
  4406. X/*
  4407. X * Display string, query user....return TRUE if answer = resp
  4408. X */
  4409. Xchar    *string;
  4410. Xchar    resp;
  4411. X
  4412. X{
  4413. Xchar    buff[5];
  4414. X
  4415. X    Fprintf (stderr, "%s [%c|%c] ", string, YES, NO);
  4416. X    fflush (stderr);
  4417. X    (void) GETS (buff, 5);
  4418. X    return ((*buff == resp) ? TRUE : FALSE );
  4419. X}
  4420. X
  4421. X
  4422. Xprocess_bibfiles (files, process_recd, onerror)
  4423. X/*
  4424. X * For each file in files, 
  4425. X *    delineate_next_record
  4426. X *    process_record (file, record);
  4427. X *        if process_record() indicates error,
  4428. X *            onerror (open_file_descriptor);
  4429. X *            lseek to EOF
  4430. X *            cause exit()
  4431. X */
  4432. Xchar    **files;
  4433. Xint    (*process_recd)(), (*onerror)();
  4434. X
  4435. X{
  4436. Xchar    *delineate_recd();
  4437. Xint    rdfd1;
  4438. Xchar    buffer[BUFSIZE+2], excess[RECSIZE], wkbuf[BUFSIZE + RECSIZE];
  4439. Xint    done, cc;
  4440. Xchar    *start, *next;
  4441. X
  4442. X    done = FALSE;
  4443. X    bibflist = files;
  4444. X    rdfd1 = -1;
  4445. X
  4446. X    Strcpy (excess, "");
  4447. X    while (! done)
  4448. X      {
  4449. X      bzero (buffer, sizeof(buffer));
  4450. X      if ((cc = read (rdfd1, buffer, BUFSIZE)) <=0)
  4451. X        {
  4452. X        if ((rdfd1 = get_next_file (rdfd1)) <= 0)
  4453. X          done = TRUE;
  4454. X        DASSERT (*excess == '\0');
  4455. X        continue;
  4456. X        }
  4457. X      Strcpy (wkbuf, excess);
  4458. X      Strncat (wkbuf, buffer, cc);
  4459. X      start = wkbuf;
  4460. X      while ((next = delineate_recd (start)) != (char *) NULL)
  4461. X        {
  4462. X        if ((*process_recd) (curfile, start) < 0)
  4463. X          {
  4464. X          (void) lseek (rdfd1, (long) (-1 * Strlen(next)), L_INCR);
  4465. X          if (onerror)
  4466. X            (*onerror) (rdfd1);
  4467. X          (void) lseek (rdfd1, 0L, L_XTND);
  4468. X          next = (char *) NULL;
  4469. X          done = TRUE;    /* Abort; go to final cleanup, if any    */
  4470. X          }
  4471. X        start = next;
  4472. X        }
  4473. X      Strcpy (excess, (start ? start : ""));
  4474. X      }
  4475. X    return 0;
  4476. X}
  4477. X
  4478. X
  4479. Xget_next_file (curfd)
  4480. X/*
  4481. X * Close current file descriptor;
  4482. X * get next bib file from bibflist
  4483. X * open file, and return new file descriptor;
  4484. X */
  4485. Xint    curfd;
  4486. X
  4487. X{
  4488. Xint    retfd;
  4489. X
  4490. X    close (curfd);
  4491. X    curfile = *bibflist++;
  4492. X    if (! curfile)
  4493. X      retfd = -1;
  4494. X    else if (Strcmp (curfile, "-") == SAME)
  4495. X      retfd = 0    /* stdin */;
  4496. X    else
  4497. X      retfd = open (curfile, O_RDONLY);
  4498. X    
  4499. X    return retfd;
  4500. X}
  4501. X
  4502. X
  4503. Xchar    *
  4504. Xlcase (string)
  4505. X/*
  4506. X * Lower case the given string
  4507. X */
  4508. Xchar    *string;
  4509. X
  4510. X{
  4511. Xchar    *str, c;
  4512. X
  4513. X    for (str = string ; *str; str++)
  4514. X      if (isupper (*str))
  4515. X        {
  4516. X        c = tolower (*str);    /* I dunno, just being paranoid, I guess */
  4517. X        *str = c;
  4518. X        }
  4519. X    return string;
  4520. X}
  4521. X
  4522. X
  4523. Xchar    *
  4524. Xreplstr (str)
  4525. X/*
  4526. X * replicate the given string.  get storage, and return the new string.
  4527. X */
  4528. Xchar    *str;
  4529. X
  4530. X{
  4531. Xchar    *temp, *malloc();
  4532. X
  4533. X    temp = (char *) malloc ((unsigned) (Strlen (str) + 1));
  4534. X    Strcpy (temp, str);
  4535. X    return temp;
  4536. X}
  4537. X
  4538. X
  4539. Xchar    *
  4540. Xdelineate_recd (string)
  4541. X/*
  4542. X * Get next record, using '\n@' as a flag per record.
  4543. X * Match all braces, 
  4544. X * If record found, delineate current record by placing '\0' at end of
  4545. X *    current record, and return address of next record.
  4546. X * else return (char *) NULL;
  4547. X */
  4548. Xchar    *string;
  4549. X
  4550. X{
  4551. Xchar    *atsign, *start, *end;
  4552. Xchar    acount;
  4553. X
  4554. X    if ((! string) || (! *string))
  4555. X      return (char *) NULL;
  4556. X
  4557. X    start = Index (string, '@') + 1;
  4558. X    end = (char *) NULL;
  4559. X    atsign = get_atsign (start);
  4560. X    if (atsign)
  4561. X      *atsign = '\0';
  4562. X
  4563. X    acount = strcount (start, OPEN_BRACE);
  4564. X    if (acount && (acount == strcount (start, CLOSE_BRACE)))
  4565. X      {
  4566. X      end = Rindex (start, CLOSE_BRACE) + 1;
  4567. X      *end = '\0';
  4568. X      if (atsign)
  4569. X        {
  4570. X        *atsign = '@';
  4571. X        end = atsign;
  4572. X        }
  4573. X      }
  4574. X    else
  4575. X      {
  4576. X      DASSERT (atsign == (char *) NULL);
  4577. X      }
  4578. X    return end;
  4579. X}
  4580. X
  4581. Xstrcount (str, c)
  4582. X/*
  4583. X * Count the number of occurences of character 'c' in string "str"
  4584. X */
  4585. Xchar    *str;
  4586. Xchar    c;
  4587. X
  4588. X{
  4589. Xchar    *temp;
  4590. Xint    count;
  4591. X
  4592. X    temp = str;
  4593. X    count = 0;
  4594. X
  4595. X    while (temp = Index (temp +1, c))
  4596. X      count++;
  4597. X    
  4598. X    return count;
  4599. X}
  4600. X
  4601. X
  4602. Xchar    *
  4603. Xget_atsign (str)
  4604. X/*
  4605. X * Get an atsign, check if it is preceeded by a newline
  4606. X *    If yes, return value,
  4607. X *    else repeat search
  4608. X */
  4609. Xchar    *str;
  4610. X
  4611. X{
  4612. Xchar    *answer;
  4613. X
  4614. X    answer = str;
  4615. X    while (answer = Index (answer, '@'))
  4616. X      if (*(answer-1) == '\n')
  4617. X        return answer;
  4618. X      else
  4619. X        answer++;
  4620. X    return answer;
  4621. X}
  4622. X
  4623. X
  4624. X#ifdef    NOCASE
  4625. XREGEXP    *
  4626. Xmy_rcomp (re)
  4627. X/*
  4628. X * STRATEGY: lcase the string inplace, and feed to regcomp(), return the
  4629. X * value returned as is...
  4630. X */
  4631. Xchar    *re;
  4632. X
  4633. X{
  4634. X    return regcomp (lcase (re));
  4635. X}
  4636. X
  4637. X
  4638. Xmy_rexec (prog, str)
  4639. Xregexp    *prog;
  4640. X/*
  4641. X * my_rexec = TRUE, if lcase (copy of str) contains given re
  4642. X *        = FALSE otherwise.
  4643. X */
  4644. Xchar    *str;
  4645. X
  4646. X{
  4647. Xchar    *temp;
  4648. Xint    retval;
  4649. X
  4650. X    temp = (char *) replstr (str);
  4651. X    (void) lcase (temp);
  4652. X    retval = regexec (prog, temp);
  4653. X    free (temp);
  4654. X    return retval;
  4655. X}
  4656. X#endif NOCASE
  4657. X
  4658. EOFile lib_bib.c
  4659. chmod u=rw+,g=r++,o=r++ lib_bib.c
  4660. echo '...done' 1>&2
  4661. if [ ! -d . ] ; then
  4662.     echo -n Directory . not found. Creating....
  4663.     mkdir .
  4664.     if [ ! -d . ] ; then
  4665.         echo ...failed
  4666.         echo unable to create directory ..  Please create the directory and try again
  4667.         exit
  4668.     fi
  4669.     echo ...done
  4670. fi
  4671. echo -n "misc/..." 1>&2
  4672. if test -f misc/
  4673. then
  4674.     case $# in 
  4675.     0)
  4676.         echo 'exists, `sh filename -o'\'' to overwrite'
  4677.         exit 0;;
  4678.     esac
  4679.     case $1 in 
  4680.     -o)    ;;
  4681.     *)
  4682.         echo 'exists, `sh filename -o'\'' to overwrite'
  4683.         exit 0;;
  4684.     esac
  4685. fi
  4686. sed 's/^X//' << 'EOFile misc/' > misc/
  4687. EOFile misc/
  4688. chmod otal 36
  4689. u=rw+,g=r++,o=r++
  4690. u=rw+,g=r++,o=r++
  4691. u=rwx,g=r+x,o=r+x
  4692. u=rw+,g=r++,o=r++ misc/
  4693. echo '...done' 1>&2
  4694. if [ ! -d . ] ; then
  4695.     echo -n Directory . not found. Creating....
  4696.     mkdir .
  4697.     if [ ! -d . ] ; then
  4698.         echo ...failed
  4699.         echo unable to create directory ..  Please create the directory and try again
  4700.         exit
  4701.     fi
  4702.     echo ...done
  4703. fi
  4704. echo -n "omega.lex..." 1>&2
  4705. if test -f omega.lex
  4706. then
  4707.     case $# in 
  4708.     0)
  4709.         echo 'exists, `sh filename -o'\'' to overwrite'
  4710.         exit 0;;
  4711.     esac
  4712.     case $1 in 
  4713.     -o)    ;;
  4714.     *)
  4715.         echo 'exists, `sh filename -o'\'' to overwrite'
  4716.         exit 0;;
  4717.     esac
  4718. fi
  4719. sed 's/^X//' << 'EOFile omega.lex' > omega.lex
  4720. X"quit!"            return FLD_NULL;
  4721. X"EOF!"            return FLD_NULL;
  4722. X"EDIT!"            return FLD_EDITOR;
  4723. X[a-zA-Z0-9]*!        return FLD_ERROR;
  4724. X%%
  4725. X
  4726. EOFile omega.lex
  4727. chmod u=rw+,g=r++,o=r++ omega.lex
  4728. echo '...done' 1>&2
  4729. if [ ! -d . ] ; then
  4730.     echo -n Directory . not found. Creating....
  4731.     mkdir .
  4732.     if [ ! -d . ] ; then
  4733.         echo ...failed
  4734.         echo unable to create directory ..  Please create the directory and try again
  4735.         exit
  4736.     fi
  4737.     echo ...done
  4738. fi
  4739. echo -n "pyr.regexp.a..." 1>&2
  4740. if test -f pyr.regexp.a
  4741. then
  4742.     case $# in 
  4743.     0)
  4744.         echo 'exists, `sh filename -o'\'' to overwrite'
  4745.         exit 0;;
  4746.     esac
  4747.     case $1 in 
  4748.     -o)    ;;
  4749.     *)
  4750.         echo 'exists, `sh filename -o'\'' to overwrite'
  4751.         exit 0;;
  4752.     esac
  4753. fi
  4754. sed 's/^X//' << 'EOFile pyr.regexp.a' > pyr.regexp.a
  4755. X!<arch>
  4756. Xregexp.o        621975704   1112  198   100644  9213      `
  4757. XP` $hpp@p$!0 @@@>P@!" 1@"$1"0A"(",!0@@~p1$1P0@@~h@ 0p$P@!F"0p,!0 P@@>P@A0"0$0`@@> #@cp$!0 `@@>P@!" 1@"$ApR\!",!0@@~@p1$1P0@@~(@ 0p$P@1#P1#Q1#T1#XAp`]0@@~2  p$3Ap 2 p$a#Pp     2 Sp$B SQS"@cQ    #p"!p 2 p$Ap0@@>ppAp"Ap0@@> !0@@~h  @ p$k!#T!cXPP@P@aQ@pF"$p,!0 p@@>P@A""$A"$S!@"$Ap0@@~ H #p #p0$0D@@~4  @ p$P@@cpp1@@~ ,p #R#p$1R#~QS#1TQQp "A" R!" p0$0D@@~  @ p$P@p1@@~ S#p$1S#~QQR#1TQA" 2 T&|pZ@pAp0p 0@@~
  4758. X| $p    1@@~ `p     0    1@@~ 0@@~\  @ p$w@pA" TS!@" 2 &)p!0 |@@>P@p @p$A" 2 TpA" 2 T&)p$!0! @@>P@p !0!@@>P@PP@P@a0@@~    l #"p p0$0D@@~L  @ p$P@S#1QP@"p$R#1Qp 01@@~
  4759. X"A" 2 TpA" 2 T&|pA" 2 T&)p$S@"p$p@@~PP@P@p0$0H@@~  @ p$P@A" 2 a S&*p  S&+p S&?pQP@#p$  S&?p!0!(@@>P@ S&+pp SQP R&*p$
  4760. X#p01@@~<p l R&*p$01@@~p@@~` 10@@~    01@@~x0@@~4 10@@~Tp@@~ 10@@~8p J R&+p$
  4761. X#pp1@@~p = R&+p$0@@~4 #0q@@~Pp@@~1@@~80@@~| 1p@@~p@@~` 10@@~p  R&?p$01@@~X0@@~  10@@~@p@@~ #0q@@~ 0q@@~A" R!" 2 T&*pA" 2 T&+pA" 2 T&?p$!0!D@@>P@P@P@aA" TS!@" 2 pp 'p@@~0 $p F0@@~ $p Ap@@~ $1#QPp 8A" 2 &^p$ p@@~L $A" R!" p 0@@~$ $A" 2 T&]pA" 2 T&-p$
  4762. XA" TS!@" 2 0@@~,p BA" 2 T&-p$3A" S!@" R2 &]pA" 2 p$!0-@@~Hp A" B ~`A" 2!ApR p!0!P@@>P@p 0@@~l``p{A" R!" p 
  4763. XA" TS!@" 2 0@@~$A" 2 TpA" 2 T&]p$60@@~pA" 2 T&]p!0!d@@>P@A" S!@" 1#Qp *p1$1Tp@@~v $@    $p$P@    S#1QPp !0!t@@>P@p !0!@@>P@p 
  4764. A" 2 p$!0!@@>P@0@@~ $A" R!" 2 0@@~<0@@~01#Qp kA"  S!@" p!1!$@@~   "@"p,!0!0@@>P@A" 1r$2 #bp R&*p     R&+p R&?p$ b1#Qbp$1#QP0@@~p $p  A" R!" 2 0@@~$ b@"p,u0@@~ p &p %0p &0$p~[&0(pt&0)p&0*p&0+p&0.p~Q&0?p~&0[p~T&0\p&0^p~;&0|pkp     P@P@A ",&P "(p$A"0R!"0P@!R@!aa!aa!a!@",P@P@!"(FP",p    A",TS!@",R@p A"0S!@"0P@!"(FP",p$A"0R!"0P@A ",A",S!@",ap  a `!P`p,|bR@"ba"ba"bP@&P"(p$P@!p@@~P  @ p$p !p x2 RRp$b bp b b0#"@!#"@!P@@p&P"(p2 pP@Ap0q@@~HP@@p@Qp$!0!D@@>P@B\&p!0!T@@>P@A@Tp`p  0A1TA2X@@>@ 0p$p 
  4765. X`AT2 10@@>@  p$n@ p$P@!@"8B Qp0q@@~$ P@`B Ppp 
  4766. X01@@~x@ 0pPP@`B 1P0@@>@  p$qp 01@@~4@ 0pPP@`2 p$uP@P@!@"41p!"<Ap(!@"@1p!Ap"( p a!!a"" `@ p,zAp0]@@~8@ 0pQPa"4(PP@p P@P@!p xp@@~  2 R0p hfP"8"4pP@p iA"42 pP@p bA"42 p$P@A"4R!"4p VAph2 
  4767. XA"42 SpP@
  4768. X0@@> 'gp 
  4769. X0A1"4    r@@>@ 0pP@    SD"4!@"4p 6A"42 p
  4770. XA"42 1App@@>@ 0p$P@A"4R!"4p !A"42 Tp
  4771. XA"42 qApp@@>@ 0pP@A"4S!@"4p  p  p 
  4772. 2 c #A%"40@@~~0@ 0p A"<1J4p$A"<Q
  4773. X9RPP@p P@p t2 d$A&"40@@~}X@ 0p A"@1JDp$A"@Q
  4774. XIPP@p P@p ^2 pAp`p A,"4App@@~}l@ 0pPP@! "4p@@~T !@ap2 RplP@p @"2 p$B "2 Rp$+p kA*"4App@@~d )p  pA"42  p$0@@~|(@ 0pPP@ i1r!"4
  4775. Xip(lP@p PP@p !0!h@@>P@p 
  4776. Xp     0pw&0'p,tA 0 0 !@ap$!0!|@@>P@P@"A "4Ap!2 pp .0@@> "  p /p b`2 S2 p{p 'p b`2 p2 1p@@>@ 0p$wp p b`2 p2 1p@@>@ 0pwp !0"@@>"p     p ppx0p,vA 0 0 !"4P@P@&P"(p$P@B  #  B #`@ p$P@2 Sp$@1q4P@p 1rP@P@"!p `p     2 S`2 Sp$P@2 p$wba2 Sp$qP@P@ 8TXd0,\\444444444          X888NULL argumentregexp too bigout of spacetoo many ()unmatched ()unmatched ()junk on end*+ operand could be emptynested *?+invalid [] rangeunmatched []internal urp?+* follows nothingtrailing \^$.[()|?+*\internal disasterNULL parametercorrupted programmemory corruptioncorrupted pointersinternal foulup 
  4777. X $,4<@
  4778. X ,< PX
  4779. X hpp  `lt
  4780. X  @LDHXpx
  4781. X $<D
  4782. X X`
  4783. X  8
  4784. X $@Xpx
  4785. X         (        0    <    X    p
  4786. X
  4787. X
  4788. X0
  4789. XH
  4790. XT
  4791. Xp
  4792. X
  4793. X(
  4794. XD
  4795. XL
  4796. X
  4797. Xx     4 D h 
  4798. X  $  
  4799. X $ ,
  4800. X @ P X
  4801. X x  < H T p x
  4802. X  px<PXdt$0<HP\ 0t|
  4803. X  (
  4804. X `  ( htX $<Xp|4 LX t|, DP\l $@\l4D(8t$
  4805. X Php
  4806. X ( x ( <D
  4807. X ht  $(,048<@DHLPTX\`dhlptx|  $(,04" "$"(!",*"03"4="8E"<P"@YblLrLwlx$-$8lB    KVx_`hqxdx
  4808. X_regparse_regnpar_regdummy_regcode_regsize_reginput_regbol_regstartp_regendp_regcomp_regerror_regc_reg_malloc_regnext_strlen_regnode_regbranch_regtail_regoptail_regpiece_regatom_reginsert_strcspn_regexec_strncmp_index_regtry_regmatch_regrepeat
  4809. Xregsub.o        621975707   1112  198   100644  667       `
  4810. XP `$8@p@Qp@p$!0@@>P@B\&p!0@@>P@`"p H S&&p$$p  S&\p$2 &0p 2 &9p,`2 d$$Pp d@    $p( S&\p$ 2 &\p2 &&p$2 !`R@bbp 1JDpAp(1JDTpAp(1
  4811. XDc1
  4812. XD c01
  4813. XD1r@@>b@cp    B p$!04@@>P@2 !` Sp$6a"bP@NULL parm to regsubdamaged regexp fed to regsubdamaged match string$ DL L lt  _regsub_regerror_strncpy
  4814. Xregerror.o      622057384   1112  198   100644  243       `
  4815. XP@ 0 Ap0(!12@@>p@@>P@regexp(3): %s  $ #_regerror__iob_fprintf_exit
  4816. EOFile pyr.regexp.a
  4817. chmod u=rw+,g=r++,o=r++ pyr.regexp.a
  4818. echo '...done' 1>&2
  4819. if [ ! -d . ] ; then
  4820.     echo -n Directory . not found. Creating....
  4821.     mkdir .
  4822.     if [ ! -d . ] ; then
  4823.         echo ...failed
  4824.         echo unable to create directory ..  Please create the directory and try again
  4825.         exit
  4826.     fi
  4827.     echo ...done
  4828. fi
  4829. echo -n "specl.bst..." 1>&2
  4830. if test -f specl.bst
  4831. then
  4832.     case $# in 
  4833.     0)
  4834.         echo 'exists, `sh filename -o'\'' to overwrite'
  4835.         exit 0;;
  4836.     esac
  4837.     case $1 in 
  4838.     -o)    ;;
  4839.     *)
  4840.         echo 'exists, `sh filename -o'\'' to overwrite'
  4841.         exit 0;;
  4842.     esac
  4843. fi
  4844. sed 's/^X//' << 'EOFile specl.bst' > specl.bst
  4845. X% BibTeX `plain' family
  4846. X% BibTeX style: spec(ia)l 
  4847. X% specl.bst is a special bst file, which is used for keeping a private
  4848. X% hardcopy of your bib file.  Every bibitem that is generated has the same
  4849. X% identity as the original \cite-key that is in the bib
  4850. X% file...ferinstance...
  4851. X% 
  4852. X% If the bib file contained..
  4853. X% 
  4854. X%    @BOOK{kn:gnus,
  4855. X%         foo,
  4856. X%         bar,
  4857. X%         baz}
  4858. X% 
  4859. X% The bibitem record would look as
  4860. X% 
  4861. X%    \bibitem[kn:gnus]{rest of the stuff here}
  4862. X% 
  4863. X% Hacked/Concieved/Designed by Kannan Varadhan        22/JUN/89
  4864. X% email:  kannan@cis.ohio-state.edu     or    ...{backbone}!osu-cis!kannan
  4865. X% voice:  {Res.} (614) 297-8720 | {Off.} (614) 292-8234 or 4-9099 on campus
  4866. X% snail:  Kannan Varadhan 306, W. Lane Ave., # 15, Columbus, OH 43201
  4867. X%
  4868. X%
  4869. X    % version 0.99a for BibTeX versions 0.99a or later, LaTeX version 2.09.
  4870. X    % Copyright (C) 1985, all rights reserved.
  4871. X    % Copying of this file is authorized only if either
  4872. X    % (1) you make absolutely no changes to your copy, including name, or
  4873. X    % (2) if you do make changes, you name it something other than
  4874. X    % btxbst.doc, plain.bst, unsrt.bst, alpha.bst, and abbrv.bst.
  4875. X    % This restriction helps ensure that all standard styles are identical.
  4876. X    % The file btxbst.doc has the documentation for this style.
  4877. X
  4878. X
  4879. X
  4880. XENTRY
  4881. X  { address
  4882. X    author
  4883. X    booktitle
  4884. X    chapter
  4885. X    edition
  4886. X    editor
  4887. X    howpublished
  4888. X    institution
  4889. X    journal
  4890. X    key
  4891. X    month
  4892. X    note
  4893. X    number
  4894. X    organization
  4895. X    pages
  4896. X    publisher
  4897. X    school
  4898. X    series
  4899. X    title
  4900. X    type
  4901. X    volume
  4902. X    year
  4903. X  }
  4904. X  {}
  4905. X  { label extra.label sort.label }
  4906. X
  4907. XINTEGERS { output.state before.all mid.sentence after.sentence after.block }
  4908. X
  4909. XFUNCTION {init.state.consts}
  4910. X{ #0 'before.all :=
  4911. X  #1 'mid.sentence :=
  4912. X  #2 'after.sentence :=
  4913. X  #3 'after.block :=
  4914. X}
  4915. X
  4916. X
  4917. XSTRINGS { s t }
  4918. X
  4919. XFUNCTION {output.nonnull}
  4920. X{ 's :=
  4921. X  output.state mid.sentence =
  4922. X    { ", " * write$ }
  4923. X    { output.state after.block =
  4924. X    { add.period$ write$
  4925. X      newline$
  4926. X      "\newblock " write$
  4927. X    }
  4928. X    { output.state before.all =
  4929. X        'write$
  4930. X        { add.period$ " " * write$ }
  4931. X      if$
  4932. X    }
  4933. X      if$
  4934. X      mid.sentence 'output.state :=
  4935. X    }
  4936. X  if$
  4937. X  s
  4938. X}
  4939. X
  4940. XFUNCTION {output}
  4941. X{ duplicate$ empty$
  4942. X    'pop$
  4943. X    'output.nonnull
  4944. X  if$
  4945. X}
  4946. X
  4947. XFUNCTION {output.check}
  4948. X{ 't :=
  4949. X  duplicate$ empty$
  4950. X    { pop$ "empty " t * " in " * cite$ * warning$ }
  4951. X    'output.nonnull
  4952. X  if$
  4953. X}
  4954. X
  4955. XFUNCTION {output.bibitem}
  4956. X{ newline$
  4957. X
  4958. X      "\bibitem[" write$
  4959. X      label write$
  4960. X      "]{" write$
  4961. X
  4962. X  cite$ write$
  4963. X  "}" write$
  4964. X  newline$
  4965. X  ""
  4966. X  before.all 'output.state :=
  4967. X}
  4968. X
  4969. X
  4970. XFUNCTION {fin.entry}
  4971. X{ add.period$
  4972. X  write$
  4973. X  newline$
  4974. X}
  4975. X
  4976. XFUNCTION {new.block}
  4977. X{ output.state before.all =
  4978. X    'skip$
  4979. X    { after.block 'output.state := }
  4980. X  if$
  4981. X}
  4982. X
  4983. XFUNCTION {new.sentence}
  4984. X{ output.state after.block =
  4985. X    'skip$
  4986. X    { output.state before.all =
  4987. X    'skip$
  4988. X    { after.sentence 'output.state := }
  4989. X      if$
  4990. X    }
  4991. X  if$
  4992. X}
  4993. X
  4994. X
  4995. XFUNCTION {not}
  4996. X{   { #0 }
  4997. X    { #1 }
  4998. X  if$
  4999. X}
  5000. X
  5001. XFUNCTION {and}
  5002. X{   'skip$
  5003. X    { pop$ #0 }
  5004. X  if$
  5005. X}
  5006. X
  5007. XFUNCTION {or}
  5008. X{   { pop$ #1 }
  5009. X    'skip$
  5010. X  if$
  5011. X}
  5012. X
  5013. X
  5014. XFUNCTION {new.block.checka}
  5015. X{ empty$
  5016. X    'skip$
  5017. X    'new.block
  5018. X  if$
  5019. X}
  5020. X
  5021. XFUNCTION {new.block.checkb}
  5022. X{ empty$
  5023. X  swap$ empty$
  5024. X  and
  5025. X    'skip$
  5026. X    'new.block
  5027. X  if$
  5028. X}
  5029. X
  5030. X
  5031. XFUNCTION {new.sentence.checka}
  5032. X{ empty$
  5033. X    'skip$
  5034. X    'new.sentence
  5035. X  if$
  5036. X}
  5037. X
  5038. XFUNCTION {new.sentence.checkb}
  5039. X{ empty$
  5040. X  swap$ empty$
  5041. X  and
  5042. X    'skip$
  5043. X    'new.sentence
  5044. X  if$
  5045. X}
  5046. X
  5047. X
  5048. XFUNCTION {field.or.null}
  5049. X{ duplicate$ empty$
  5050. X    { pop$ "" }
  5051. X    'skip$
  5052. X  if$
  5053. X}
  5054. X
  5055. XFUNCTION {emphasize}
  5056. X{ duplicate$ empty$
  5057. X    { pop$ "" }
  5058. X    { "{\em " swap$ * "}" * }
  5059. X  if$
  5060. X}
  5061. X
  5062. XINTEGERS { nameptr namesleft numnames }
  5063. X
  5064. XFUNCTION {format.names}
  5065. X{ 's :=
  5066. X  #1 'nameptr :=
  5067. X  s num.names$ 'numnames :=
  5068. X  numnames 'namesleft :=
  5069. X    { namesleft #0 > }
  5070. X
  5071. X    { s nameptr "{ff~}{vv~}{ll}{, jj}" format.name$ 't :=
  5072. X
  5073. X      nameptr #1 >
  5074. X    { namesleft #1 >
  5075. X        { ", " * t * }
  5076. X        { numnames #2 >
  5077. X        { "," * }
  5078. X        'skip$
  5079. X          if$
  5080. X          t "others" =
  5081. X        { " et~al." * }
  5082. X        { " and " * t * }
  5083. X          if$
  5084. X        }
  5085. X      if$
  5086. X    }
  5087. X    't
  5088. X      if$
  5089. X      nameptr #1 + 'nameptr :=
  5090. X      namesleft #1 - 'namesleft :=
  5091. X    }
  5092. X  while$
  5093. X}
  5094. X
  5095. XFUNCTION {format.authors}
  5096. X{ author empty$
  5097. X    { "" }
  5098. X    { author format.names }
  5099. X  if$
  5100. X}
  5101. X
  5102. XFUNCTION {format.editors}
  5103. X{ editor empty$
  5104. X    { "" }
  5105. X    { editor format.names
  5106. X      editor num.names$ #1 >
  5107. X    { ", editors" * }
  5108. X    { ", editor" * }
  5109. X      if$
  5110. X    }
  5111. X  if$
  5112. X}
  5113. X
  5114. X
  5115. XFUNCTION {format.title}
  5116. X{ title empty$
  5117. X    { "" }
  5118. X
  5119. X    { title "t" change.case$ }
  5120. X
  5121. X  if$
  5122. X}
  5123. X
  5124. X
  5125. X
  5126. XFUNCTION {n.dashify}
  5127. X{ 't :=
  5128. X  ""
  5129. X    { t empty$ not }
  5130. X    { t #1 #1 substring$ "-" =
  5131. X    { t #1 #2 substring$ "--" = not
  5132. X        { "--" *
  5133. X          t #2 global.max$ substring$ 't :=
  5134. X        }
  5135. X        {   { t #1 #1 substring$ "-" = }
  5136. X        { "-" *
  5137. X          t #2 global.max$ substring$ 't :=
  5138. X        }
  5139. X          while$
  5140. X        }
  5141. X      if$
  5142. X    }
  5143. X    { t #1 #1 substring$ *
  5144. X      t #2 global.max$ substring$ 't :=
  5145. X    }
  5146. X      if$
  5147. X    }
  5148. X  while$
  5149. X}
  5150. X
  5151. X
  5152. XFUNCTION {format.date}
  5153. X{ year empty$
  5154. X    { month empty$
  5155. X    { "" }
  5156. X    { "there's a month but no year in " cite$ * warning$
  5157. X      month
  5158. X    }
  5159. X      if$
  5160. X    }
  5161. X    { month empty$
  5162. X    'year
  5163. X    { month " " * year * }
  5164. X      if$
  5165. X    }
  5166. X  if$
  5167. X}
  5168. X
  5169. X
  5170. XFUNCTION {format.btitle}
  5171. X{ title emphasize
  5172. X}
  5173. X
  5174. X
  5175. XFUNCTION {tie.or.space.connect}
  5176. X{ duplicate$ text.length$ #3 <
  5177. X    { "~" }
  5178. X    { " " }
  5179. X  if$
  5180. X  swap$ * *
  5181. X}
  5182. X
  5183. X
  5184. XFUNCTION {either.or.check}
  5185. X{ empty$
  5186. X    'pop$
  5187. X    { "can't use both " swap$ * " fields in " * cite$ * warning$ }
  5188. X  if$
  5189. X}
  5190. X
  5191. X
  5192. XFUNCTION {format.bvolume}
  5193. X{ volume empty$
  5194. X    { "" }
  5195. X    { "volume" volume tie.or.space.connect
  5196. X      series empty$
  5197. X    'skip$
  5198. X    { " of " * series emphasize * }
  5199. X      if$
  5200. X      "volume and number" number either.or.check
  5201. X    }
  5202. X  if$
  5203. X}
  5204. X
  5205. X
  5206. XFUNCTION {format.number.series}
  5207. X{ volume empty$
  5208. X    { number empty$
  5209. X    { series field.or.null }
  5210. X    { output.state mid.sentence =
  5211. X        { "number" }
  5212. X        { "Number" }
  5213. X      if$
  5214. X      number tie.or.space.connect
  5215. X      series empty$
  5216. X        { "there's a number but no series in " cite$ * warning$ }
  5217. X        { " in " * series * }
  5218. X      if$
  5219. X    }
  5220. X      if$
  5221. X    }
  5222. X    { "" }
  5223. X  if$
  5224. X}
  5225. X
  5226. X
  5227. XFUNCTION {format.edition}
  5228. X{ edition empty$
  5229. X    { "" }
  5230. X    { output.state mid.sentence =
  5231. X    { edition "l" change.case$ " edition" * }
  5232. X    { edition "t" change.case$ " edition" * }
  5233. X      if$
  5234. X    }
  5235. X  if$
  5236. X}
  5237. X
  5238. X
  5239. XINTEGERS { multiresult }
  5240. X
  5241. XFUNCTION {multi.page.check}
  5242. X{ 't :=
  5243. X  #0 'multiresult :=
  5244. X    { multiresult not
  5245. X      t empty$ not
  5246. X      and
  5247. X    }
  5248. X    { t #1 #1 substring$
  5249. X      duplicate$ "-" =
  5250. X      swap$ duplicate$ "," =
  5251. X      swap$ "+" =
  5252. X      or or
  5253. X    { #1 'multiresult := }
  5254. X    { t #2 global.max$ substring$ 't := }
  5255. X      if$
  5256. X    }
  5257. X  while$
  5258. X  multiresult
  5259. X}
  5260. X
  5261. X
  5262. XFUNCTION {format.pages}
  5263. X{ pages empty$
  5264. X    { "" }
  5265. X    { pages multi.page.check
  5266. X    { "pages" pages n.dashify tie.or.space.connect }
  5267. X    { "page" pages tie.or.space.connect }
  5268. X      if$
  5269. X    }
  5270. X  if$
  5271. X}
  5272. X
  5273. X
  5274. XFUNCTION {format.vol.num.pages}
  5275. X{ volume field.or.null
  5276. X  number empty$
  5277. X    'skip$
  5278. X    { "(" number * ")" * *
  5279. X      volume empty$
  5280. X    { "there's a number but no volume in " cite$ * warning$ }
  5281. X    'skip$
  5282. X      if$
  5283. X    }
  5284. X  if$
  5285. X  pages empty$
  5286. X    'skip$
  5287. X    { duplicate$ empty$
  5288. X    { pop$ format.pages }
  5289. X    { ":" * pages n.dashify * }
  5290. X      if$
  5291. X    }
  5292. X  if$
  5293. X}
  5294. X
  5295. X
  5296. X
  5297. XFUNCTION {format.chapter.pages}
  5298. X{ chapter empty$
  5299. X    'format.pages
  5300. X    { type empty$
  5301. X    { "chapter" }
  5302. X    { type "l" change.case$ }
  5303. X      if$
  5304. X      chapter tie.or.space.connect
  5305. X      pages empty$
  5306. X    'skip$
  5307. X    { ", " * format.pages * }
  5308. X      if$
  5309. X    }
  5310. X  if$
  5311. X}
  5312. X
  5313. X
  5314. XFUNCTION {format.in.ed.booktitle}
  5315. X{ booktitle empty$
  5316. X    { "" }
  5317. X    { editor empty$
  5318. X    { "In " booktitle emphasize * }
  5319. X    { "In " format.editors * ", " * booktitle emphasize * }
  5320. X      if$
  5321. X    }
  5322. X  if$
  5323. X}
  5324. X
  5325. X
  5326. XFUNCTION {empty.misc.check}
  5327. X{ author empty$ title empty$ howpublished empty$
  5328. X  month empty$ year empty$ note empty$
  5329. X  and and and and and
  5330. X
  5331. X  key empty$ not and
  5332. X
  5333. X    { "all relevant fields are empty in " cite$ * warning$ }
  5334. X    'skip$
  5335. X  if$
  5336. X}
  5337. X
  5338. X
  5339. XFUNCTION {format.thesis.type}
  5340. X{ type empty$
  5341. X    'skip$
  5342. X    { pop$
  5343. X      type "t" change.case$
  5344. X    }
  5345. X  if$
  5346. X}
  5347. X
  5348. X
  5349. XFUNCTION {format.tr.number}
  5350. X{ type empty$
  5351. X    { "Technical Report" }
  5352. X    'type
  5353. X  if$
  5354. X  number empty$
  5355. X    { "t" change.case$ }
  5356. X    { number tie.or.space.connect }
  5357. X  if$
  5358. X}
  5359. X
  5360. X
  5361. XFUNCTION {format.article.crossref}
  5362. X{ key empty$
  5363. X    { journal empty$
  5364. X    { "need key or journal for " cite$ * " to crossref " * crossref *
  5365. X      warning$
  5366. X      ""
  5367. X    }
  5368. X    { "In {\em " journal * "\/}" * }
  5369. X      if$
  5370. X    }
  5371. X    { "In " key * }
  5372. X  if$
  5373. X  " \cite{" * crossref * "}" *
  5374. X}
  5375. X
  5376. X
  5377. XFUNCTION {format.crossref.editor}
  5378. X{ editor #1 "{vv~}{ll}" format.name$
  5379. X  editor num.names$ duplicate$
  5380. X  #2 >
  5381. X    { pop$ " et~al." * }
  5382. X    { #2 <
  5383. X    'skip$
  5384. X    { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
  5385. X        { " et~al." * }
  5386. X        { " and " * editor #2 "{vv~}{ll}" format.name$ * }
  5387. X      if$
  5388. X    }
  5389. X      if$
  5390. X    }
  5391. X  if$
  5392. X}
  5393. X
  5394. X
  5395. XFUNCTION {format.book.crossref}
  5396. X{ volume empty$
  5397. X    { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
  5398. X      "In "
  5399. X    }
  5400. X    { "Volume" volume tie.or.space.connect
  5401. X      " of " *
  5402. X    }
  5403. X  if$
  5404. X  editor empty$
  5405. X  editor field.or.null author field.or.null =
  5406. X  or
  5407. X    { key empty$
  5408. X    { series empty$
  5409. X        { "need editor, key, or series for " cite$ * " to crossref " *
  5410. X          crossref * warning$
  5411. X          "" *
  5412. X        }
  5413. X        { "{\em " * series * "\/}" * }
  5414. X      if$
  5415. X    }
  5416. X    { key * }
  5417. X      if$
  5418. X    }
  5419. X    { format.crossref.editor * }
  5420. X  if$
  5421. X  " \cite{" * crossref * "}" *
  5422. X}
  5423. X
  5424. X
  5425. XFUNCTION {format.incoll.inproc.crossref}
  5426. X{ editor empty$
  5427. X  editor field.or.null author field.or.null =
  5428. X  or
  5429. X    { key empty$
  5430. X    { booktitle empty$
  5431. X        { "need editor, key, or booktitle for " cite$ * " to crossref " *
  5432. X          crossref * warning$
  5433. X          ""
  5434. X        }
  5435. X        { "In {\em " booktitle * "\/}" * }
  5436. X      if$
  5437. X    }
  5438. X    { "In " key * }
  5439. X      if$
  5440. X    }
  5441. X    { "In " format.crossref.editor * }
  5442. X  if$
  5443. X  " \cite{" * crossref * "}" *
  5444. X}
  5445. X
  5446. X
  5447. XFUNCTION {article}
  5448. X{ output.bibitem
  5449. X  format.authors "author" output.check
  5450. X  new.block
  5451. X  format.title "title" output.check
  5452. X  new.block
  5453. X  crossref missing$
  5454. X    { journal emphasize "journal" output.check
  5455. X      format.vol.num.pages output
  5456. X      format.date "year" output.check
  5457. X    }
  5458. X    { format.article.crossref output.nonnull
  5459. X      format.pages output
  5460. X    }
  5461. X  if$
  5462. X  new.block
  5463. X  note output
  5464. X  fin.entry
  5465. X}
  5466. X
  5467. XFUNCTION {book}
  5468. X{ output.bibitem
  5469. X  author empty$
  5470. X    { format.editors "author and editor" output.check }
  5471. X    { format.authors output.nonnull
  5472. X      crossref missing$
  5473. X    { "author and editor" editor either.or.check }
  5474. X    'skip$
  5475. X      if$
  5476. X    }
  5477. X  if$
  5478. X  new.block
  5479. X  format.btitle "title" output.check
  5480. X  crossref missing$
  5481. X    { format.bvolume output
  5482. X      new.block
  5483. X      format.number.series output
  5484. X      new.sentence
  5485. X      publisher "publisher" output.check
  5486. X      address output
  5487. X    }
  5488. X    { new.block
  5489. X      format.book.crossref output.nonnull
  5490. X    }
  5491. X  if$
  5492. X  format.edition output
  5493. X  format.date "year" output.check
  5494. X  new.block
  5495. X  note output
  5496. X  fin.entry
  5497. X}
  5498. X
  5499. X
  5500. XFUNCTION {booklet}
  5501. X{ output.bibitem
  5502. X  format.authors output
  5503. X  new.block
  5504. X  format.title "title" output.check
  5505. X  howpublished address new.block.checkb
  5506. X  howpublished output
  5507. X  address output
  5508. X  format.date output
  5509. X  new.block
  5510. X  note output
  5511. X  fin.entry
  5512. X}
  5513. X
  5514. X
  5515. X
  5516. XFUNCTION {inbook}
  5517. X{ output.bibitem
  5518. X  author empty$
  5519. X    { format.editors "author and editor" output.check }
  5520. X    { format.authors output.nonnull
  5521. X      crossref missing$
  5522. X    { "author and editor" editor either.or.check }
  5523. X    'skip$
  5524. X      if$
  5525. X    }
  5526. X  if$
  5527. X  new.block
  5528. X  format.btitle "title" output.check
  5529. X  crossref missing$
  5530. X    { format.bvolume output
  5531. X      format.chapter.pages "chapter and pages" output.check
  5532. X      new.block
  5533. X      format.number.series output
  5534. X      new.sentence
  5535. X      publisher "publisher" output.check
  5536. X      address output
  5537. X    }
  5538. X    { format.chapter.pages "chapter and pages" output.check
  5539. X      new.block
  5540. X      format.book.crossref output.nonnull
  5541. X    }
  5542. X  if$
  5543. X  format.edition output
  5544. X  format.date "year" output.check
  5545. X  new.block
  5546. X  note output
  5547. X  fin.entry
  5548. X}
  5549. X
  5550. X
  5551. XFUNCTION {incollection}
  5552. X{ output.bibitem
  5553. X  format.authors "author" output.check
  5554. X  new.block
  5555. X  format.title "title" output.check
  5556. X  new.block
  5557. X  crossref missing$
  5558. X    { format.in.ed.booktitle "booktitle" output.check
  5559. X      format.bvolume output
  5560. X      format.number.series output
  5561. X      format.chapter.pages output
  5562. X      new.sentence
  5563. X      publisher "publisher" output.check
  5564. X      address output
  5565. X      format.edition output
  5566. X      format.date "year" output.check
  5567. X    }
  5568. X    { format.incoll.inproc.crossref output.nonnull
  5569. X      format.chapter.pages output
  5570. X    }
  5571. X  if$
  5572. X  new.block
  5573. X  note output
  5574. X  fin.entry
  5575. X}
  5576. X
  5577. X
  5578. XFUNCTION {inproceedings}
  5579. X{ output.bibitem
  5580. X  format.authors "author" output.check
  5581. X  new.block
  5582. X  format.title "title" output.check
  5583. X  new.block
  5584. X  crossref missing$
  5585. X    { format.in.ed.booktitle "booktitle" output.check
  5586. X      format.bvolume output
  5587. X      format.number.series output
  5588. X      format.pages output
  5589. X      address empty$
  5590. X    { organization publisher new.sentence.checkb
  5591. X      organization output
  5592. X      publisher output
  5593. X      format.date "year" output.check
  5594. X    }
  5595. X    { address output.nonnull
  5596. X      format.date "year" output.check
  5597. X      new.sentence
  5598. X      organization output
  5599. X      publisher output
  5600. X    }
  5601. X      if$
  5602. X    }
  5603. X    { format.incoll.inproc.crossref output.nonnull
  5604. X      format.pages output
  5605. X    }
  5606. X  if$
  5607. X  new.block
  5608. X  note output
  5609. X  fin.entry
  5610. X}
  5611. X
  5612. X
  5613. XFUNCTION {conference} { inproceedings }
  5614. X
  5615. X
  5616. XFUNCTION {manual}
  5617. X{ output.bibitem
  5618. X  author empty$
  5619. X    { organization empty$
  5620. X    'skip$
  5621. X    { organization output.nonnull
  5622. X      address output
  5623. X    }
  5624. X      if$
  5625. X    }
  5626. X    { format.authors output.nonnull }
  5627. X  if$
  5628. X  new.block
  5629. X  format.btitle "title" output.check
  5630. X  author empty$
  5631. X    { organization empty$
  5632. X    { address new.block.checka
  5633. X      address output
  5634. X    }
  5635. X    'skip$
  5636. X      if$
  5637. X    }
  5638. X    { organization address new.block.checkb
  5639. X      organization output
  5640. X      address output
  5641. X    }
  5642. X  if$
  5643. X  format.edition output
  5644. X  format.date output
  5645. X  new.block
  5646. X  note output
  5647. X  fin.entry
  5648. X}
  5649. X
  5650. X
  5651. XFUNCTION {mastersthesis}
  5652. X{ output.bibitem
  5653. X  format.authors "author" output.check
  5654. X  new.block
  5655. X  format.title "title" output.check
  5656. X  new.block
  5657. X  "Master's thesis" format.thesis.type output.nonnull
  5658. X  school "school" output.check
  5659. X  address output
  5660. X  format.date "year" output.check
  5661. X  new.block
  5662. X  note output
  5663. X  fin.entry
  5664. X}
  5665. X
  5666. X
  5667. XFUNCTION {misc}
  5668. X{ output.bibitem
  5669. X  format.authors output
  5670. X  title howpublished new.block.checkb
  5671. X  format.title output
  5672. X  howpublished new.block.checka
  5673. X  howpublished output
  5674. X  format.date output
  5675. X  new.block
  5676. X  note output
  5677. X  fin.entry
  5678. X  empty.misc.check
  5679. X}
  5680. X
  5681. X
  5682. XFUNCTION {phdthesis}
  5683. X{ output.bibitem
  5684. X  format.authors "author" output.check
  5685. X  new.block
  5686. X  format.btitle "title" output.check
  5687. X  new.block
  5688. X  "PhD thesis" format.thesis.type output.nonnull
  5689. X  school "school" output.check
  5690. X  address output
  5691. X  format.date "year" output.check
  5692. X  new.block
  5693. X  note output
  5694. X  fin.entry
  5695. X}
  5696. X
  5697. X
  5698. XFUNCTION {proceedings}
  5699. X{ output.bibitem
  5700. X  editor empty$
  5701. X    { organization output }
  5702. X    { format.editors output.nonnull }
  5703. X  if$
  5704. X  new.block
  5705. X  format.btitle "title" output.check
  5706. X  format.bvolume output
  5707. X  format.number.series output
  5708. X  address empty$
  5709. X    { editor empty$
  5710. X    { publisher new.sentence.checka }
  5711. X    { organization publisher new.sentence.checkb
  5712. X      organization output
  5713. X    }
  5714. X      if$
  5715. X      publisher output
  5716. X      format.date "year" output.check
  5717. X    }
  5718. X    { address output.nonnull
  5719. X      format.date "year" output.check
  5720. X      new.sentence
  5721. X      editor empty$
  5722. X    'skip$
  5723. X    { organization output }
  5724. X      if$
  5725. X      publisher output
  5726. X    }
  5727. X  if$
  5728. X  new.block
  5729. X  note output
  5730. X  fin.entry
  5731. X}
  5732. X
  5733. X
  5734. XFUNCTION {techreport}
  5735. X{ output.bibitem
  5736. X  format.authors "author" output.check
  5737. X  new.block
  5738. X  format.title "title" output.check
  5739. X  new.block
  5740. X  format.tr.number output.nonnull
  5741. X  institution "institution" output.check
  5742. X  address output
  5743. X  format.date "year" output.check
  5744. X  new.block
  5745. X  note output
  5746. X  fin.entry
  5747. X}
  5748. X
  5749. X
  5750. XFUNCTION {unpublished}
  5751. X{ output.bibitem
  5752. X  format.authors "author" output.check
  5753. X  new.block
  5754. X  format.title "title" output.check
  5755. X  new.block
  5756. X  note "note" output.check
  5757. X  format.date output
  5758. X  fin.entry
  5759. X}
  5760. X
  5761. X
  5762. XFUNCTION {default.type} { misc }
  5763. X
  5764. X
  5765. X
  5766. X
  5767. XMACRO {jan} {"January"}
  5768. X
  5769. XMACRO {feb} {"February"}
  5770. X
  5771. XMACRO {mar} {"March"}
  5772. X
  5773. XMACRO {apr} {"April"}
  5774. X
  5775. XMACRO {may} {"May"}
  5776. X
  5777. XMACRO {jun} {"June"}
  5778. X
  5779. XMACRO {jul} {"July"}
  5780. X
  5781. XMACRO {aug} {"August"}
  5782. X
  5783. XMACRO {sep} {"September"}
  5784. X
  5785. XMACRO {oct} {"October"}
  5786. X
  5787. XMACRO {nov} {"November"}
  5788. X
  5789. XMACRO {dec} {"December"}
  5790. X
  5791. X
  5792. X
  5793. X
  5794. X
  5795. X
  5796. XMACRO {acmcs} {"ACM Computing Surveys"}
  5797. X
  5798. XMACRO {acta} {"Acta Informatica"}
  5799. X
  5800. XMACRO {cacm} {"Communications of the ACM"}
  5801. X
  5802. XMACRO {ibmjrd} {"IBM Journal of Research and Development"}
  5803. X
  5804. XMACRO {ibmsj} {"IBM Systems Journal"}
  5805. X
  5806. XMACRO {ieeese} {"IEEE Transactions on Software Engineering"}
  5807. X
  5808. XMACRO {ieeetc} {"IEEE Transactions on Computers"}
  5809. X
  5810. XMACRO {ieeetcad}
  5811. X {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
  5812. X
  5813. XMACRO {ipl} {"Information Processing Letters"}
  5814. X
  5815. XMACRO {jacm} {"Journal of the ACM"}
  5816. X
  5817. XMACRO {jcss} {"Journal of Computer and System Sciences"}
  5818. X
  5819. XMACRO {scp} {"Science of Computer Programming"}
  5820. X
  5821. XMACRO {sicomp} {"SIAM Journal on Computing"}
  5822. X
  5823. XMACRO {tocs} {"ACM Transactions on Computer Systems"}
  5824. X
  5825. XMACRO {tods} {"ACM Transactions on Database Systems"}
  5826. X
  5827. XMACRO {tog} {"ACM Transactions on Graphics"}
  5828. X
  5829. XMACRO {toms} {"ACM Transactions on Mathematical Software"}
  5830. X
  5831. XMACRO {toois} {"ACM Transactions on Office Information Systems"}
  5832. X
  5833. XMACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
  5834. X
  5835. XMACRO {tcs} {"Theoretical Computer Science"}
  5836. X
  5837. X
  5838. X
  5839. X
  5840. XREAD
  5841. X
  5842. X
  5843. X
  5844. X
  5845. XFUNCTION {sortify}
  5846. X{ purify$
  5847. X  "l" change.case$
  5848. X}
  5849. X
  5850. XINTEGERS { len }
  5851. X
  5852. XFUNCTION {chop.word}
  5853. X{ 's :=
  5854. X  'len :=
  5855. X  s #1 len substring$ =
  5856. X    { s len #1 + global.max$ substring$ }
  5857. X    's
  5858. X  if$
  5859. X}
  5860. X
  5861. X
  5862. X
  5863. X
  5864. X
  5865. X
  5866. XINTEGERS { et.al.char.used }
  5867. X
  5868. XFUNCTION {initialize.et.al.char.used}
  5869. X{ #0 'et.al.char.used :=
  5870. X}
  5871. X
  5872. XEXECUTE {initialize.et.al.char.used}
  5873. X
  5874. XFUNCTION {format.lab.names}
  5875. X{ 's :=
  5876. X  s num.names$ 'numnames :=
  5877. X  numnames #1 >
  5878. X    { numnames #4 >
  5879. X    { #3 'namesleft := }
  5880. X    { numnames 'namesleft := }
  5881. X      if$
  5882. X      #1 'nameptr :=
  5883. X      ""
  5884. X    { namesleft #0 > }
  5885. X    { nameptr numnames =
  5886. X        { s nameptr "{ff }{vv }{ll}{ jj}" format.name$ "others" =
  5887. X        { "{\etalchar{+}}" *
  5888. X          #1 'et.al.char.used :=
  5889. X        }
  5890. X        { s nameptr "{v{}}{l{}}" format.name$ * }
  5891. X          if$
  5892. X        }
  5893. X        { s nameptr "{v{}}{l{}}" format.name$ * }
  5894. X      if$
  5895. X      nameptr #1 + 'nameptr :=
  5896. X      namesleft #1 - 'namesleft :=
  5897. X    }
  5898. X      while$
  5899. X      numnames #4 >
  5900. X    { "{\etalchar{+}}" *
  5901. X      #1 'et.al.char.used :=
  5902. X    }
  5903. X    'skip$
  5904. X      if$
  5905. X    }
  5906. X    { s #1 "{v{}}{l{}}" format.name$
  5907. X      duplicate$ text.length$ #2 <
  5908. X    { pop$ s #1 "{ll}" format.name$ #3 text.prefix$ }
  5909. X    'skip$
  5910. X      if$
  5911. X    }
  5912. X  if$
  5913. X}
  5914. X
  5915. XFUNCTION {author.key.label}
  5916. X{ author empty$
  5917. X    { key empty$
  5918. X
  5919. X    { cite$ #1 #3 substring$ }
  5920. X
  5921. X    { key #3 text.prefix$ }
  5922. X      if$
  5923. X    }
  5924. X    { author format.lab.names }
  5925. X  if$
  5926. X}
  5927. X
  5928. XFUNCTION {author.editor.key.label}
  5929. X{ author empty$
  5930. X    { editor empty$
  5931. X    { key empty$
  5932. X
  5933. X        { cite$ #1 #3 substring$ }
  5934. X
  5935. X        { key #3 text.prefix$ }
  5936. X      if$
  5937. X    }
  5938. X    { editor format.lab.names }
  5939. X      if$
  5940. X    }
  5941. X    { author format.lab.names }
  5942. X  if$
  5943. X}
  5944. X
  5945. XFUNCTION {author.key.organization.label}
  5946. X{ author empty$
  5947. X    { key empty$
  5948. X    { organization empty$
  5949. X
  5950. X        { cite$ #1 #3 substring$ }
  5951. X
  5952. X        { "The " #4 organization chop.word #3 text.prefix$ }
  5953. X      if$
  5954. X    }
  5955. X    { key #3 text.prefix$ }
  5956. X      if$
  5957. X    }
  5958. X    { author format.lab.names }
  5959. X  if$
  5960. X}
  5961. X
  5962. XFUNCTION {editor.key.organization.label}
  5963. X{ editor empty$
  5964. X    { key empty$
  5965. X    { organization empty$
  5966. X
  5967. X        { cite$ #1 #3 substring$ }
  5968. X
  5969. X        { "The " #4 organization chop.word #3 text.prefix$ }
  5970. X      if$
  5971. X    }
  5972. X    { key #3 text.prefix$ }
  5973. X      if$
  5974. X    }
  5975. X    { editor format.lab.names }
  5976. X  if$
  5977. X}
  5978. X
  5979. XFUNCTION {calc.label}
  5980. X{
  5981. X
  5982. X  cite$ cite$
  5983. X
  5984. X  'label :=
  5985. X  year field.or.null purify$ #-1 #4 substring$
  5986. X  *
  5987. X  sortify 'sort.label :=
  5988. X}
  5989. X
  5990. X
  5991. X
  5992. X
  5993. X
  5994. X
  5995. X
  5996. X
  5997. X
  5998. XFUNCTION {sort.format.names}
  5999. X{ 's :=
  6000. X  #1 'nameptr :=
  6001. X  ""
  6002. X  s num.names$ 'numnames :=
  6003. X  numnames 'namesleft :=
  6004. X    { namesleft #0 > }
  6005. X    { nameptr #1 >
  6006. X    { "   " * }
  6007. X    'skip$
  6008. X      if$
  6009. X
  6010. X      s nameptr "{vv{ } }{ll{ }}{  ff{ }}{  jj{ }}" format.name$ 't :=
  6011. X
  6012. X      nameptr numnames = t "others" = and
  6013. X    { "et al" * }
  6014. X    { t sortify * }
  6015. X      if$
  6016. X      nameptr #1 + 'nameptr :=
  6017. X      namesleft #1 - 'namesleft :=
  6018. X    }
  6019. X  while$
  6020. X}
  6021. X
  6022. X
  6023. XFUNCTION {sort.format.title}
  6024. X{ 't :=
  6025. X  "A " #2
  6026. X    "An " #3
  6027. X      "The " #4 t chop.word
  6028. X    chop.word
  6029. X  chop.word
  6030. X  sortify
  6031. X  #1 global.max$ substring$
  6032. X}
  6033. X
  6034. X
  6035. XFUNCTION {author.sort}
  6036. X{ author empty$
  6037. X    { key empty$
  6038. X    { "to sort, need author or key in " cite$ * warning$
  6039. X      ""
  6040. X    }
  6041. X    { key sortify }
  6042. X      if$
  6043. X    }
  6044. X    { author sort.format.names }
  6045. X  if$
  6046. X}
  6047. X
  6048. XFUNCTION {author.editor.sort}
  6049. X{ author empty$
  6050. X    { editor empty$
  6051. X    { key empty$
  6052. X        { "to sort, need author, editor, or key in " cite$ * warning$
  6053. X          ""
  6054. X        }
  6055. X        { key sortify }
  6056. X      if$
  6057. X    }
  6058. X    { editor sort.format.names }
  6059. X      if$
  6060. X    }
  6061. X    { author sort.format.names }
  6062. X  if$
  6063. X}
  6064. X
  6065. XFUNCTION {author.organization.sort}
  6066. X{ author empty$
  6067. X    { organization empty$
  6068. X    { key empty$
  6069. X        { "to sort, need author, organization, or key in " cite$ * warning$
  6070. X          ""
  6071. X        }
  6072. X        { key sortify }
  6073. X      if$
  6074. X    }
  6075. X    { "The " #4 organization chop.word sortify }
  6076. X      if$
  6077. X    }
  6078. X    { author sort.format.names }
  6079. X  if$
  6080. X}
  6081. X
  6082. XFUNCTION {editor.organization.sort}
  6083. X{ editor empty$
  6084. X    { organization empty$
  6085. X    { key empty$
  6086. X        { "to sort, need editor, organization, or key in " cite$ * warning$
  6087. X          ""
  6088. X        }
  6089. X        { key sortify }
  6090. X      if$
  6091. X    }
  6092. X    { "The " #4 organization chop.word sortify }
  6093. X      if$
  6094. X    }
  6095. X    { editor sort.format.names }
  6096. X  if$
  6097. X}
  6098. X
  6099. X
  6100. XFUNCTION {presort}
  6101. X
  6102. X{ calc.label
  6103. X  sort.label
  6104. X  "    "
  6105. X  *
  6106. X  type$ "book" =
  6107. X
  6108. X  type$ "inbook" =
  6109. X  or
  6110. X    'author.editor.sort
  6111. X    { type$ "proceedings" =
  6112. X    'editor.organization.sort
  6113. X    { type$ "manual" =
  6114. X        'author.organization.sort
  6115. X        'author.sort
  6116. X      if$
  6117. X    }
  6118. X      if$
  6119. X    }
  6120. X  if$
  6121. X
  6122. X  *
  6123. X
  6124. X  "    "
  6125. X  *
  6126. X  year field.or.null sortify
  6127. X  *
  6128. X  "    "
  6129. X  *
  6130. X  title field.or.null
  6131. X  sort.format.title
  6132. X  *
  6133. X  #1 entry.max$ substring$
  6134. X  'sort.key$ :=
  6135. X}
  6136. X
  6137. XITERATE {presort}
  6138. X
  6139. X
  6140. XSORT
  6141. X
  6142. X
  6143. X
  6144. X
  6145. X
  6146. X
  6147. X
  6148. X
  6149. XSTRINGS { longest.label last.sort.label next.extra }
  6150. X
  6151. XINTEGERS { longest.label.width last.extra.num }
  6152. X
  6153. XFUNCTION {initialize.longest.label}
  6154. X{ "" 'longest.label :=
  6155. X  #0 int.to.chr$ 'last.sort.label :=
  6156. X  "" 'next.extra :=
  6157. X  #0 'longest.label.width :=
  6158. X  #0 'last.extra.num :=
  6159. X}
  6160. X
  6161. XFUNCTION {forward.pass}
  6162. X{ last.sort.label sort.label =
  6163. X    { last.extra.num #1 + 'last.extra.num :=
  6164. X      last.extra.num int.to.chr$ 'extra.label :=
  6165. X    }
  6166. X    { "a" chr.to.int$ 'last.extra.num :=
  6167. X      "" 'extra.label :=
  6168. X      sort.label 'last.sort.label :=
  6169. X    }
  6170. X  if$
  6171. X}
  6172. X
  6173. XFUNCTION {reverse.pass}
  6174. X{ next.extra "b" =
  6175. X    { "a" 'extra.label := }
  6176. X    'skip$
  6177. X  if$
  6178. X  label extra.label * 'label :=
  6179. X  label width$ longest.label.width >
  6180. X    { label 'longest.label :=
  6181. X      label width$ 'longest.label.width :=
  6182. X    }
  6183. X    'skip$
  6184. X  if$
  6185. X  extra.label 'next.extra :=
  6186. X}
  6187. X
  6188. XEXECUTE {initialize.longest.label}
  6189. X
  6190. XITERATE {forward.pass}
  6191. X
  6192. XREVERSE {reverse.pass}
  6193. X
  6194. X
  6195. X
  6196. X
  6197. X
  6198. X
  6199. XFUNCTION {begin.bib}
  6200. X
  6201. X{ et.al.char.used
  6202. X    { "\newcommand{\etalchar}[1]{$^{#1}$}" write$ newline$ }
  6203. X    'skip$
  6204. X  if$
  6205. X  preamble$ empty$
  6206. X
  6207. X    'skip$
  6208. X    { preamble$ write$ newline$ }
  6209. X  if$
  6210. X  "\begin{thebibliography}{"  longest.label  * "}" * write$ newline$
  6211. X}
  6212. X
  6213. XEXECUTE {begin.bib}
  6214. X
  6215. XEXECUTE {init.state.consts}
  6216. X
  6217. X
  6218. XITERATE {call.type$}
  6219. X
  6220. X
  6221. XFUNCTION {end.bib}
  6222. X{ newline$
  6223. X  "\end{thebibliography}" write$ newline$
  6224. X}
  6225. X
  6226. XEXECUTE {end.bib}
  6227. EOFile specl.bst
  6228. chmod u=rw+,g=r++,o=r++ specl.bst
  6229. echo '...done' 1>&2
  6230. if [ ! -d . ] ; then
  6231.     echo -n Directory . not found. Creating....
  6232.     mkdir .
  6233.     if [ ! -d . ] ; then
  6234.         echo ...failed
  6235.         echo unable to create directory ..  Please create the directory and try again
  6236.         exit
  6237.     fi
  6238.     echo ...done
  6239. fi
  6240. echo -n "strings.h..." 1>&2
  6241. if test -f strings.h
  6242. then
  6243.     case $# in 
  6244.     0)
  6245.         echo 'exists, `sh filename -o'\'' to overwrite'
  6246.         exit 0;;
  6247.     esac
  6248.     case $1 in 
  6249.     -o)    ;;
  6250.     *)
  6251.         echo 'exists, `sh filename -o'\'' to overwrite'
  6252.         exit 0;;
  6253.     esac
  6254. fi
  6255. sed 's/^X//' << 'EOFile strings.h' > strings.h
  6256. X/*
  6257. X * This program has been written by Kannan Varadhan.  You are welcome to
  6258. X * use, copy, modify, or circulate as you please, provided you do not
  6259. X * charge any fee for any of it, and you do not remove these header
  6260. X * comments from any of these files.
  6261. X *
  6262. X *        -- kva    Mon Dec  4 11:26:37 EST 1989
  6263. X */
  6264. X
  6265. X#include <strings.h>
  6266. X
  6267. X#define Index        (char *) index
  6268. X#define    Rindex        (char *) rindex
  6269. X#define Strcpy        (void *) strcpy
  6270. X#define Strncpy        (void *) strncpy
  6271. X#define Strcat        (void *) strcat
  6272. X#define Strncat        (void *) strncat
  6273. X#define Strcmp        (int) strcmp
  6274. X#define    Strlen        (int) strlen
  6275. X
  6276. X#define    Sprintf        (void) sprintf
  6277. X#define    Fprintf        (void) fprintf
  6278. EOFile strings.h
  6279. chmod u=rw+,g=r++,o=r++ strings.h
  6280. echo '...done' 1>&2
  6281. if [ ! -d . ] ; then
  6282.     echo -n Directory . not found. Creating....
  6283.     mkdir .
  6284.     if [ ! -d . ] ; then
  6285.         echo ...failed
  6286.         echo unable to create directory ..  Please create the directory and try again
  6287.         exit
  6288.     fi
  6289.     echo ...done
  6290. fi
  6291. echo -n "sun.regexp.a..." 1>&2
  6292. if test -f sun.regexp.a
  6293. then
  6294.     case $# in 
  6295.     0)
  6296.         echo 'exists, `sh filename -o'\'' to overwrite'
  6297.         exit 0;;
  6298.     esac
  6299.     case $1 in 
  6300.     -o)    ;;
  6301.     *)
  6302.         echo 'exists, `sh filename -o'\'' to overwrite'
  6303.         exit 0;;
  6304.     esac
  6305. fi
  6306. sed 's/^X//' << 'EOFile sun.regexp.a' > sun.regexp.a
  6307. X!<arch>
  6308. X__.SYMDEF       628639319   1112  198   100644  76        `
  6309. X     J>$_regexec_regcomp_regsub_regerrorregexp.o        628639016   1112  198   100644  6781      `
  6310. X0@$hpNVlHW8J.fHy0ajXOp`\#np~#GtB9#|x|HxN9    HXOHn|B'N9POJg 9mHy>a
  6311. XOp`| 9~\P/apXO*@JfHyMa\XOp`N#np~#GtAmZ#H|HxN9    HXOHn|B'N9POJfp`B-PB-QB-RB-VIm[HTN94XO @JfhV flP`
  6312. X fR-Q.gFK~`4 f"Hla~:XO0mGlHla~&XO.HTN94XO(@J fH+KR+GV Ln8lN^NuNVlHW8 n r J.g@ 9
  6313. XtmHyZa~PXOp`F.9tR9t rP/N9    XO*@`MHn|N9
  6314. XXO(@J g Jf"*L`*R9pHn|N9
  6315. XXO(@J fp`lHTHUN9    BPO.f n r~C n .r@ yp |g,J.g ~P`p/N9    XO&@HSHUN9    BPO(M`HSHTN9
  6316. XPOHTN94XO(@J fdJ.g$ ypR9p )gHyfa}LXOp`BJ.f: ypJg0 yp )fHysa}XOp`Hya} XOp` Ln8lN^NuNVpHW8 nBHxN9    XO*@L`^ yp |g\ yp )gPHn|N9.XO&@J fp`L n.r@J f n.r@` HSHTN9    BPO(K ypJfJ f Hx    N9    XO Ln8pN^NuNVpHW0Hn|N9PXO*@Jfp`z yp *g +g ?g  n .|`R.f ?gHy a{vXOp`2 n +gp`p  *f.gHUHx
  6317. XN9    t`B *fdHUHxN9    tPOHxN9    XO/HUN9
  6318. XPOHUHUN9
  6319. XPOHxN9    XO/HUN9    BPOHx    N9    XO/HUN9    B`X +f.gHUHx N9    t`: +fbHxN9    XO(@HTHUN9    BPOHUHxN9    XO/N9    BPOHxN9    XO/HTN9    BPOHx    N9    XO/HUN9    B`P ?fLHUHxN9    tPOHxN9    XO/HUN9    BPOHx    N9    XO(@HTHUN9    BPOHTHUN9
  6320. XPOR9p yp *g yp +g  yp ?fHy&azFXOp` Ln0pN^NuNVpHW @ nB ypI@R9p~|0b\Az~r 0TI|fL0;N{>*>RR<RVf>HxN9    XO*@`LHxN9    XO*@`:HxN9    XO*@ n~`  yp ^fHxN9    XO*@R9p`HxN9    XO*@ yp ]g yp -f*` Hx-` yp ]g yp -fhR9p yp ]gL ypJgB yp~(~R ypp,R>o Hy1axfXOp``/N9    HXOR>opR9p` ypR9pI@/N9    HXO ypJfZB'N9    HXO yp ]gHyBax~XOp`xR9p n~`dHn|Hxay\PO*@Jfp`L n.~@`8HyOax,XOp`&Hy\axXOp` ypJfHypawzXOp`tHxN9    XO*@ ypR9pI@/N9    HXOB'N9    HXO n~`4S9pHy{/9pN9|PO.nHyaw
  6321. XOp` yp0xr>o *g +g ?fS n|>f n|HxN9    XO*@` ypR9pI@/N9    HXOSJn`B'N9    HXO` |^\[?.+*)($ Ln @pN^NuNVxHW0*y|;|xfV9`(Mn BB#L| Ln0xN^NuNV 9x|g y|. R9|`R9N^NuNVtHW8 9x|fV9`(*y|V9|(y|`%;n bx&n n BBLn8tN^NuNVtHW0 .xg@*n`*LHUN94XO(@J fn f . ` . `@GLn0tN^NuNVJ.g" .xg n f/. V/a|PON^NuNVtHW8*n(n JgJ fHyauXO`Jp-Z gHy(aurXO`*J-Rg<&L`/-V/-RHSauROo JgR  mRI@/HSau6PO&@JfLJ gf#LJ-QgHTHUN9 LPO`N&LJ-Pg,-PI@/HSatxPO&@Jg,HSHUN9 LPOJfR `THSHUN9 LPOJgp`JfhpLn8tN^NuNVtHW0#n #n  .~(P#@*n(MYG~
  6322. XBBSJnv .~[P/N9 @XOJg n .  n!y(p`pLn0tN^NuNVhHW0`*n`HUN94XO-@|I@~'0bj0;
  6323. XN{,PdtR~26
  6324. 2~~`````````:::::::::`vvvvvvvvv 909g
  6325. X` yJgz` yJgR9``Im y0ffHTasnXO.|>o//9HTasTOo Jf:_9` yJg$ yI@/HmasPOJf.` yJgx yI@/HmarrPOJfZR9`8`4`0I@~.(y/.|a~~XOJg( y J0|f
  6326. X y ! |p`I@~.(y/.|a~BXOJgl yJ0|f
  6327. X y! |p`R n| g Am-H|`"(yHma}zXOJfP#LHUN94XO*@Jg gN`~ n| f( 
  6328. Xfp`p*(yHmN9~XO,<mLJg
  6329. X y>f/.|a}XOJf\SAth#H`PHy:`*n|Jf}nHyLaqXOpLn0`hN^NuNVtHW0~*y(nV  nI@rr0bl0;
  6330. XN{ (FddHUaqBXO.[G`X0fRRR`tJgHI@/HTaqPOJg4RR`bJg*I@/HTap~POJfRR`bHy_apfXO~#M Ln0tN^NuNVxHW *n;|xgp-ar-P.fp` f `Aux Ln xN^NuNVtHW0~*n`RRJg(n Jgp0fv Ln0tN^NuNULL argumentregexp too bigout of spacetoo many ()unmatched ()unmatched ()junk on end*+ operand could be emptynested *?+invalid [] rangeunmatched []internal urp?+* follows nothingtrailing \^$.[()|?+*\internal disasterNULL parametercorrupted programmemory corruptioncorrupted pointersinternal foulup@P&@.@4@:@>@H@V@h@p@vP@P@$P4@<@F@P@^@@FPZPf@"@*@0P>@D@R@d@z@@@B@`@n@~@@@"@.@4PF@P@\@bPn@tP@,@8@H@@
  6331. @@<@P@@
  6332. XP>@T@`@l@x@@@@(@F@Z@h@v@@ @@$@0@D@P@\@h@v@@
  6333. @@@(@4@:P`@j@,@>@P@f@v@@ @@$@>@L@X@^@j@t@@@P*@8@@@F@R@Z@h@p@|@P@N@TPb@hPv@@P@"@(@4@>@R@X@^@d@p@vP@@@L@R@^@n@    @    @    &@    8@    N@    R@    Z@    d@    l@    ~@    @    
  6334. @    @    @    @    L@    `@
  6335. X*@
  6336. Xh@
  6337. XnP
  6338. X@
  6339. XP
  6340. X.P
  6341. XJ    P
  6342. X\@
  6343. Xl@     P @ .@ X@ `@ n@ @ *@ T@ D@ J@ X@ h@ t@ @ P $@ ,P <@ F@ R@ b    P r@ ~@    P@8@N@Z@t@
  6344. @@<@P@X@@@,@L@T@f@lP
  6345. @>Pd    P    P@P$@B@ L      @(|1p;DI~T[    Bd    Hj
  6346. Xuxt
  6347. XN|    t%.7.APJT^fnv
  6348. X  4_regtry_regnode_regmatch_strncmp_regcode_regparse_regsize_reg_regrepeat_index_regtail_regc_regoptail_regdummy_regnpar_regexec_strcspn_reginsert_regcomp_regendp_regpiece_regatom_regerror_reginput_regbol_malloc_strlen_regbranch_regstartp_regnext
  6349. Xregsub.o        628639027   1112  198   100644  439       `
  6350. XdH$(NVlHW0`J.g J. gJ.f
  6351. XHyd` np(Z g
  6352. XHyx`*n (n` \f \g &fGfnB`` 0m\ 9nVI@|0,mJ`| nJ0lgRJ0l(gL*0l(0l//0lHTaZOo YEJg,J,f&Hya>XOLn0`lN^Nu &g* \g
  6353. `jNULL parm to regsubdamaged regexp fed to regsubdamaged match string@8@&P<@BP_strncpy_regsub_regerror
  6354. Xregerror.o      628639273   1112  198   100644  219       `
  6355. X80 NV_|HW/.Hy8Hy(a`Oo HxaRXON^Nuregexp(3): %s@P P.P
  6356. X#_exit_fprintf_regerror__iob
  6357. EOFile sun.regexp.a
  6358. chmod u=rw+,g=r++,o=r++ sun.regexp.a
  6359. echo '...done' 1>&2
  6360. if [ ! -d . ] ; then
  6361.     echo -n Directory . not found. Creating....
  6362.     mkdir .
  6363.     if [ ! -d . ] ; then
  6364.         echo ...failed
  6365.         echo unable to create directory ..  Please create the directory and try again
  6366.         exit
  6367.     fi
  6368.     echo ...done
  6369. fi
  6370. echo -n "templates.c..." 1>&2
  6371. if test -f templates.c
  6372. then
  6373.     case $# in 
  6374.     0)
  6375.         echo 'exists, `sh filename -o'\'' to overwrite'
  6376.         exit 0;;
  6377.     esac
  6378.     case $1 in 
  6379.     -o)    ;;
  6380.     *)
  6381.         echo 'exists, `sh filename -o'\'' to overwrite'
  6382.         exit 0;;
  6383.     esac
  6384. fi
  6385. sed 's/^X//' << 'EOFile templates.c' > templates.c
  6386. X/*
  6387. X * This program has been written by Kannan Varadhan.  You are welcome to
  6388. X * use, copy, modify, or circulate as you please, provided you do not
  6389. X * charge any fee for any of it, and you do not remove these header
  6390. X * comments from any of these files.
  6391. X *
  6392. X *        -- kva    Mon Dec  4 11:26:37 EST 1989
  6393. X */
  6394. X
  6395. X#include "bibc.h"
  6396. X
  6397. Xint    i;
  6398. X#define    GET_USR_DEFNS                        \
  6399. X    for (i = 0; i != usr_defns_ctr; i++)            \
  6400. X      GET (&bibitem, usr_defns[i], OPTIONAL)
  6401. X
  6402. Xget_article ()
  6403. X
  6404. X{
  6405. X    SET (&bibitem, rectype, "ARTICLE");
  6406. X    GET (&bibitem, citekey, REQUIRED);
  6407. X    GET (&bibitem, author, REQUIRED);
  6408. X    GET (&bibitem, title, REQUIRED);
  6409. X    GET (&bibitem, journal, REQUIRED);
  6410. X    GET (&bibitem, year, REQUIRED);
  6411. X    GET (&bibitem, volume, OPTIONAL);
  6412. X    GET (&bibitem, number, OPTIONAL);
  6413. X    GET (&bibitem, pages, OPTIONAL);
  6414. X    GET (&bibitem, month, OPTIONAL);
  6415. X    GET (&bibitem, note, OPTIONAL);
  6416. X    GET (&bibitem, key, OPTIONAL);
  6417. X    GET (&bibitem, comment, OPTIONAL);
  6418. X    GET (&bibitem, cross_ref, OPTIONAL);
  6419. X    GET_USR_DEFNS;
  6420. X    return 0;
  6421. X}
  6422. X
  6423. Xget_book () 
  6424. X
  6425. X{
  6426. X    SET (&bibitem, rectype, "BOOK");
  6427. X    GET (&bibitem, citekey, REQUIRED);
  6428. X    GET (&bibitem, author, REQUIRED);
  6429. X    GET (&bibitem, title, REQUIRED);
  6430. X    GET (&bibitem, publisher, REQUIRED);
  6431. X    GET (&bibitem, year, REQUIRED);
  6432. X    GET (&bibitem, volume, OPTIONAL);
  6433. X    GET (&bibitem, series, OPTIONAL);
  6434. X    GET (&bibitem, address, OPTIONAL);
  6435. X    GET (&bibitem, edition, OPTIONAL);
  6436. X    GET (&bibitem, month, OPTIONAL);
  6437. X    GET (&bibitem, note, OPTIONAL);
  6438. X    GET (&bibitem, key, OPTIONAL);
  6439. X    GET (&bibitem, comment, OPTIONAL);
  6440. X    GET (&bibitem, cross_ref, OPTIONAL);
  6441. X    GET_USR_DEFNS;
  6442. X    return 0;
  6443. X}
  6444. X
  6445. Xget_booklet () 
  6446. X
  6447. X{
  6448. X    SET (&bibitem, rectype, "BOOKLET");
  6449. X    GET (&bibitem, citekey, REQUIRED);
  6450. X    GET (&bibitem, title, REQUIRED);
  6451. X    GET (&bibitem, author, OPTIONAL);
  6452. X    GET (&bibitem, howpublished, OPTIONAL);
  6453. X    GET (&bibitem, address, OPTIONAL);
  6454. X    GET (&bibitem, month, OPTIONAL);
  6455. X    GET (&bibitem, year, OPTIONAL);
  6456. X    GET (&bibitem, note, OPTIONAL);
  6457. X    GET (&bibitem, key, OPTIONAL);
  6458. X    GET (&bibitem, comment, OPTIONAL);
  6459. X    GET (&bibitem, cross_ref, OPTIONAL);
  6460. X    GET_USR_DEFNS;
  6461. X    return 0;
  6462. X}
  6463. X
  6464. X
  6465. Xget_inproceedings ()
  6466. X
  6467. X{
  6468. X    SET (&bibitem, rectype, "INPROCEEDINGS");
  6469. X    GET (&bibitem, citekey, REQUIRED);
  6470. X    GET (&bibitem, author, REQUIRED);
  6471. X    GET (&bibitem, title, REQUIRED);
  6472. X    GET (&bibitem, booktitle, REQUIRED);
  6473. X    GET (&bibitem, year, REQUIRED);
  6474. X    GET (&bibitem, editor, OPTIONAL);
  6475. X    GET (&bibitem, pages, OPTIONAL);
  6476. X    GET (&bibitem, organisation, OPTIONAL);
  6477. X    GET (&bibitem, publisher, OPTIONAL);
  6478. X    GET (&bibitem, address, OPTIONAL);
  6479. X    GET (&bibitem, month, OPTIONAL);
  6480. X    GET (&bibitem, note, OPTIONAL);
  6481. X    GET (&bibitem, key, OPTIONAL);
  6482. X    GET (&bibitem, comment, OPTIONAL);
  6483. X    GET (&bibitem, cross_ref, OPTIONAL);
  6484. X    GET_USR_DEFNS;
  6485. X    return 0;
  6486. X}
  6487. X
  6488. X
  6489. Xget_inbook ()
  6490. X
  6491. X{
  6492. X    SET (&bibitem, rectype, "INBOOK");
  6493. X    GET (&bibitem, citekey, REQUIRED);
  6494. X    GET (&bibitem, author, REQUIRED);
  6495. X    GET (&bibitem, title, REQUIRED);
  6496. X    GET (&bibitem, chapter, REQUIRED);
  6497. X    GET (&bibitem, pages, OPTIONAL);
  6498. X    GET (&bibitem, publisher, REQUIRED);
  6499. X    GET (&bibitem, year, REQUIRED);
  6500. X    GET (&bibitem, volume, OPTIONAL);
  6501. X    GET (&bibitem, series, OPTIONAL);
  6502. X    GET (&bibitem, address, OPTIONAL);
  6503. X    GET (&bibitem, edition, OPTIONAL);
  6504. X    GET (&bibitem, month, OPTIONAL);
  6505. X    GET (&bibitem, note, OPTIONAL);
  6506. X    GET (&bibitem, key, OPTIONAL);
  6507. X    GET (&bibitem, comment, OPTIONAL);
  6508. X    GET (&bibitem, cross_ref, OPTIONAL);
  6509. X    GET_USR_DEFNS;
  6510. X    return 0;
  6511. X}
  6512. X
  6513. X
  6514. Xget_incollection ()
  6515. X
  6516. X{
  6517. X    SET (&bibitem, rectype, "INCOLLECTION");
  6518. X    GET (&bibitem, citekey, REQUIRED);
  6519. X    GET (&bibitem, author, REQUIRED);
  6520. X    GET (&bibitem, title, REQUIRED);
  6521. X    GET (&bibitem, booktitle, REQUIRED);
  6522. X    GET (&bibitem, publisher, REQUIRED);
  6523. X    GET (&bibitem, year, REQUIRED);
  6524. X    GET (&bibitem, editor, OPTIONAL);
  6525. X    GET (&bibitem, chapter, OPTIONAL);
  6526. X    GET (&bibitem, pages, OPTIONAL);
  6527. X    GET (&bibitem, address, OPTIONAL);
  6528. X    GET (&bibitem, month, OPTIONAL);
  6529. X    GET (&bibitem, note, OPTIONAL);
  6530. X    GET (&bibitem, key, OPTIONAL);
  6531. X    GET (&bibitem, comment, OPTIONAL);
  6532. X    GET (&bibitem, cross_ref, OPTIONAL);
  6533. X    GET_USR_DEFNS;
  6534. X    return 0;
  6535. X}
  6536. X
  6537. X
  6538. Xget_manual ()
  6539. X
  6540. X{
  6541. X    SET (&bibitem, rectype, "MANUAL");
  6542. X    GET (&bibitem, citekey, REQUIRED);
  6543. X    GET (&bibitem, title, REQUIRED);
  6544. X    GET (&bibitem, author, OPTIONAL);
  6545. X    GET (&bibitem, organisation, OPTIONAL);
  6546. X    GET (&bibitem, address, OPTIONAL);
  6547. X    GET (&bibitem, edition, OPTIONAL);
  6548. X    GET (&bibitem, month, OPTIONAL);
  6549. X    GET (&bibitem, note, OPTIONAL);
  6550. X    GET (&bibitem, key, OPTIONAL);
  6551. X    GET (&bibitem, comment, OPTIONAL);
  6552. X    GET (&bibitem, cross_ref, OPTIONAL);
  6553. X    GET_USR_DEFNS;
  6554. X    return 0;
  6555. X}
  6556. X
  6557. X
  6558. Xget_mastersthesis ()
  6559. X
  6560. X{
  6561. X    SET (&bibitem, rectype, "MASTERSTHESIS");
  6562. X    GET (&bibitem, citekey, REQUIRED);
  6563. X    GET (&bibitem, author, REQUIRED);
  6564. X    GET (&bibitem, title, REQUIRED);
  6565. X    GET (&bibitem, school, REQUIRED);
  6566. X    GET (&bibitem, year, REQUIRED);
  6567. X    GET (&bibitem, address, OPTIONAL);
  6568. X    GET (&bibitem, month, OPTIONAL);
  6569. X    GET (&bibitem, note, OPTIONAL);
  6570. X    GET (&bibitem, key, OPTIONAL);
  6571. X    GET (&bibitem, comment, OPTIONAL);
  6572. X    GET (&bibitem, cross_ref, OPTIONAL);
  6573. X    GET_USR_DEFNS;
  6574. X    return 0;
  6575. X}
  6576. X
  6577. X
  6578. Xget_misc ()
  6579. X
  6580. X{
  6581. X    SET (&bibitem, rectype, "MISC");
  6582. X    GET (&bibitem, citekey, REQUIRED);
  6583. X    GET (&bibitem, author, OPTIONAL);
  6584. X    GET (&bibitem, title, OPTIONAL);
  6585. X    GET (&bibitem, howpublished, OPTIONAL);
  6586. X    GET (&bibitem, month, OPTIONAL);
  6587. X    GET (&bibitem, year, OPTIONAL);
  6588. X    GET (&bibitem, note, OPTIONAL);
  6589. X    GET (&bibitem, key, OPTIONAL);
  6590. X    GET (&bibitem, comment, OPTIONAL);
  6591. X    GET (&bibitem, cross_ref, OPTIONAL);
  6592. X    GET_USR_DEFNS;
  6593. X    return 0;
  6594. X}
  6595. X
  6596. X
  6597. Xget_phdthesis ()
  6598. X
  6599. X{
  6600. X    SET (&bibitem, rectype, "PHDTHESIS");
  6601. X    GET (&bibitem, citekey, REQUIRED);
  6602. X    GET (&bibitem, author, REQUIRED);
  6603. X    GET (&bibitem, title, REQUIRED);
  6604. X    GET (&bibitem, school, REQUIRED);
  6605. X    GET (&bibitem, year, REQUIRED);
  6606. X    GET (&bibitem, address, OPTIONAL);
  6607. X    GET (&bibitem, month, OPTIONAL);
  6608. X    GET (&bibitem, note, OPTIONAL);
  6609. X    GET (&bibitem, key, OPTIONAL);
  6610. X    GET (&bibitem, comment, OPTIONAL);
  6611. X    GET (&bibitem, cross_ref, OPTIONAL);
  6612. X    GET_USR_DEFNS;
  6613. X    return 0;
  6614. X}
  6615. X
  6616. X
  6617. Xget_proceedings ()
  6618. X
  6619. X{
  6620. X    SET (&bibitem, rectype, "PROCEEDINGS");
  6621. X    GET (&bibitem, citekey, REQUIRED);
  6622. X    GET (&bibitem, title, REQUIRED);
  6623. X    GET (&bibitem, year, REQUIRED);
  6624. X    GET (&bibitem, editor, OPTIONAL);
  6625. X    GET (&bibitem, publisher, OPTIONAL);
  6626. X    GET (&bibitem, organisation, OPTIONAL);
  6627. X    GET (&bibitem, address, OPTIONAL);
  6628. X    GET (&bibitem, month, OPTIONAL);
  6629. X    GET (&bibitem, note, OPTIONAL);
  6630. X    GET (&bibitem, key, OPTIONAL);
  6631. X    GET (&bibitem, comment, OPTIONAL);
  6632. X    GET (&bibitem, cross_ref, OPTIONAL);
  6633. X    GET_USR_DEFNS;
  6634. X    return 0;
  6635. X}
  6636. X
  6637. X
  6638. Xget_techreport ()
  6639. X
  6640. X{
  6641. X    SET (&bibitem, rectype, "TECHREPORT");
  6642. X    GET (&bibitem, citekey, REQUIRED);
  6643. X    GET (&bibitem, author, REQUIRED);
  6644. X    GET (&bibitem, title, REQUIRED);
  6645. X    GET (&bibitem, institution, REQUIRED);
  6646. X    GET (&bibitem, year, REQUIRED);
  6647. X    GET (&bibitem, type, OPTIONAL);
  6648. X    GET (&bibitem, number, OPTIONAL);
  6649. X    GET (&bibitem, address, OPTIONAL);
  6650. X    GET (&bibitem, month, OPTIONAL);
  6651. X    GET (&bibitem, note, OPTIONAL);
  6652. X    GET (&bibitem, key, OPTIONAL);
  6653. X    GET (&bibitem, comment, OPTIONAL);
  6654. X    GET (&bibitem, cross_ref, OPTIONAL);
  6655. X    GET_USR_DEFNS;
  6656. X    return 0;
  6657. X}
  6658. X
  6659. X
  6660. Xget_unpublished ()
  6661. X
  6662. X{
  6663. X    SET (&bibitem, rectype, "UNPUBLISHED");
  6664. X    GET (&bibitem, citekey, REQUIRED);
  6665. X    GET (&bibitem, author, REQUIRED);
  6666. X    GET (&bibitem, title, REQUIRED);
  6667. X    GET (&bibitem, note, REQUIRED);
  6668. X    GET (&bibitem, month, OPTIONAL);
  6669. X    GET (&bibitem, year, OPTIONAL);
  6670. X    GET (&bibitem, key, OPTIONAL);
  6671. X    GET (&bibitem, comment, OPTIONAL);
  6672. X    GET (&bibitem, cross_ref, OPTIONAL);
  6673. X    GET_USR_DEFNS;
  6674. X    return 0;
  6675. X}
  6676. EOFile templates.c
  6677. chmod u=rw+,g=rw+,o=r++ templates.c
  6678. echo '...done' 1>&2
  6679. if [ ! -d . ] ; then
  6680.     echo -n Directory . not found. Creating....
  6681.     mkdir .
  6682.     if [ ! -d . ] ; then
  6683.         echo ...failed
  6684.         echo unable to create directory ..  Please create the directory and try again
  6685.         exit
  6686.     fi
  6687.     echo ...done
  6688. fi
  6689. echo -n "typescript..." 1>&2
  6690. if test -f typescript
  6691. then
  6692.     case $# in 
  6693.     0)
  6694.         echo 'exists, `sh filename -o'\'' to overwrite'
  6695.         exit 0;;
  6696.     esac
  6697.     case $1 in 
  6698.     -o)    ;;
  6699.     *)
  6700.         echo 'exists, `sh filename -o'\'' to overwrite'
  6701.         exit 0;;
  6702.     esac
  6703. fi
  6704. sed 's/^X//' << 'EOFile typescript' > typescript
  6705. XScript started on Sun Dec  3 00:47:28 1989
  6706. Xcheops Bibcreate. bibc -help
  6707. XUsage: bibc [-i|-verify] [+|-verbose] [+|-pester] [-file <filename>] [-help]
  6708. X    -i            Inquire whether to commit a record
  6709. X    -verify            Same as above, a duplicate form
  6710. X    -verbose        Turn off verbose flag
  6711. X    +verbose        Turn on verbose flag
  6712. X    -pester            Do not insist, even for required fields
  6713. X    +pester            Insist once for required fields
  6714. X    -file <filename>    Output bib entries to <filename>
  6715. X    -help            Print this help output
  6716. Xcheops Bibcreate. bibc -file foo.bib
  6717. XWhat kind of record would you like to enter (one of the following)?
  6718. X    article        book        booklet        conference
  6719. X    inbook        incollection    inproceedings    manual
  6720. X    mastersthesis    msthesis    misc        phdthesis
  6721. X    proceedings    techreport    unpublished
  6722. Xor    EDIT        quit
  6723. Xinb
  6724. XCITEKEY? NAR88
  6725. XAUTHOR? Narayan, R. K.
  6726. XTITLE? A Writer's Nightmare
  6727. XCHAPTER? 
  6728. XERROR: CHAPTER is a REQUIRED FIELD for INBOOK. Let's try that again...sigh...
  6729. XCHAPTER? 
  6730. XERROR: Frankly my dear, I don't give a damn...
  6731. XPAGES (optional)? 164--166
  6732. XPUBLISHER? Penguin Books
  6733. XYEAR? 1988
  6734. XVOLUME (optional)? 1
  6735. XSERIES (optional)? 
  6736. XADDRESS (optional)? 
  6737. XEDITION (optional)? 
  6738. XMONTH (optional)? 
  6739. XNOTE (optional)? 
  6740. XKEY (optional)? ?
  6741. XUsed for alphabetising and creating a label when the author and
  6742. X  editor fields are missing.
  6743. XKEY (optional)? 
  6744. XCOMMENT (optional)? 
  6745. XCROSS-REFERENCE (optional)? 
  6746. X @INBOOK { NAR88 ,
  6747. X    AUTHOR = "Narayan, R. K." ,
  6748. X    PAGES = "164--166" ,
  6749. X    PUBLISHER = "Penguin Books" ,
  6750. X    TITLE = "A Writer's Nightmare" ,
  6751. X    VOLUME = "1" ,
  6752. X    YEAR = "1988"
  6753. X    }
  6754. X
  6755. XWhat kind of record would you like to enter (one of the following)?
  6756. X    article        book        booklet        conference
  6757. X    inbook        incollection    inproceedings    manual
  6758. X    mastersthesis    msthesis    misc        phdthesis
  6759. X    proceedings    techreport    unpublished
  6760. Xor    EDIT        quit
  6761. Xin
  6762. XUh oh! no no no
  6763. XWhat kind of record would you like to enter (one of the following)?
  6764. X    article        book        booklet        conference
  6765. X    inbook        incollection    inproceedings    manual
  6766. X    mastersthesis    msthesis    misc        phdthesis
  6767. X    proceedings    techreport    unpublished
  6768. Xor    EDIT        quit
  6769. Xmi
  6770. XCITEKEY? xx
  6771. XAbort? [y|n] y
  6772. XWhat kind of record would you like to enter (one of the following)?
  6773. X    article        book        booklet        conference
  6774. X    inbook        incollection    inproceedings    manual
  6775. X    mastersthesis    msthesis    misc        phdthesis
  6776. X    proceedings    techreport    unpublished
  6777. Xor    EDIT        quit
  6778. X^D
  6779. Xcheops Bibcreate. BIBCINIT="USR_FIELD1:USR_FIELD2?Bah Humbug" export BIBCINIT
  6780. Xcheops Bibcreate. bibc -file foo.bib
  6781. XWhat kind of record would you like to enter (one of the following)?
  6782. X    article        book        booklet        conference
  6783. X    inbook        incollection    inproceedings    manual
  6784. X    mastersthesis    msthesis    misc        phdthesis
  6785. X    proceedings    techreport    unpublished
  6786. Xor    EDIT        quit
  6787. Xa
  6788. XCITEKEY? LAM78
  6789. XAUTHOR? Lamport, Leslie
  6790. XTITLE? Time, Clocks, and the Ordering of Events in a Distributed System
  6791. XJOURNAL? \jacm
  6792. XYEAR? 1978
  6793. XVOLUME (optional)? 21
  6794. XNUMBER (optional)? 7
  6795. XPAGES (optional)? 558--565
  6796. XMONTH (optional)? \jul
  6797. XNOTE (optional)? 
  6798. XKEY (optional)? 
  6799. XCOMMENT (optional)? 
  6800. XCROSS-REFERENCE (optional)? 
  6801. XUSR_FIELD1 (optional)? ?
  6802. XYou asked for it, buster, so you figure it out...
  6803. XUSR_FIELD1 (optional)? This wasn't in the jacm, sigh
  6804. XUSR_FIELD2 (optional)? ?
  6805. XBah Humbug
  6806. XUSR_FIELD2 (optional)? There we go, it was in the cacm, so we can EDIT and change the entry
  6807. X @ARTICLE { LAM78 ,
  6808. X    AUTHOR = "Lamport, Leslie" ,
  6809. X    JOURNAL =   jacm  ,
  6810. X    MONTH =   jul  ,
  6811. X    NUMBER = "7" ,
  6812. X    PAGES = "558--565" ,
  6813. X    TITLE = "Time, Clocks, and the Ordering of Events in a Distributed System" ,
  6814. X    VOLUME = "21" ,
  6815. X    YEAR = "1978" ,
  6816. X    USR_FIELD1 = "This wasn't in the jacm, sigh" ,
  6817. X    USR_FIELD2 = "There we go, it was in the cacm, so we can EDIT and change the entry"
  6818. X    }
  6819. X
  6820. XWhat kind of record would you like to enter (one of the following)?
  6821. X    article        book        booklet        conference
  6822. X    inbook        incollection    inproceedings    manual
  6823. X    mastersthesis    msthesis    misc        phdthesis
  6824. X    proceedings    techreport    unpublished
  6825. Xor    EDIT        quit
  6826. X^D
  6827. Xcheops Bibcreate. shbib lam78 foo.bib
  6828. X@ARTICLE { LAM78 ,
  6829. X    AUTHOR = "Lamport, Leslie" ,
  6830. X    JOURNAL =   jacm  ,
  6831. X    MONTH =   jul  ,
  6832. X    NUMBER = "7" ,
  6833. X    PAGES = "558--565" ,
  6834. X    TITLE = "Time, Clocks, and the Ordering of Events in a Distributed System" ,
  6835. X    VOLUME = "21" ,
  6836. X    YEAR = "1978" ,
  6837. X    USR_FIELD1 = "This wasn't in the jacm, sigh" ,
  6838. X    USR_FIELD2 = "There we go, it was in the cacm, so we can EDIT and change the entry"
  6839. X    }
  6840. Xcheops Bibcreate. 
  6841. X
  6842. Xscript done on Sun Dec  3 00:57:11 1989
  6843. EOFile typescript
  6844. chmod u=rw+,g=r++,o=r++ typescript
  6845. echo '...done' 1>&2
  6846. if [ ! -d misc ] ; then
  6847.     echo -n Directory misc not found. Creating....
  6848.     mkdir misc
  6849.     if [ ! -d misc ] ; then
  6850.         echo ...failed
  6851.         echo unable to create directory misc.  Please create the directory and try again
  6852.         exit
  6853.     fi
  6854.     echo ...done
  6855. fi
  6856. echo -n "misc/Changes..." 1>&2
  6857. if test -f misc/Changes
  6858. then
  6859.     case $# in 
  6860.     0)
  6861.         echo 'exists, `sh filename -o'\'' to overwrite'
  6862.         exit 0;;
  6863.     esac
  6864.     case $1 in 
  6865.     -o)    ;;
  6866.     *)
  6867.         echo 'exists, `sh filename -o'\'' to overwrite'
  6868.         exit 0;;
  6869.     esac
  6870. fi
  6871. sed 's/^X//' << 'EOFile misc/Changes' > misc/Changes
  6872. XWed Jul 19 11:32:35 EDT 1989
  6873. X
  6874. Xbibc now deals with prefixed blanks correct;y...sigh! What a stupid
  6875. Xmiskate...
  6876. X
  6877. Xbibc now understands that some fields should not be quoted, as these
  6878. Xare macros.  This it figures, when the field is preceeded by a
  6879. XBACKSLASH, as ferinstance....
  6880. X
  6881. XJournal? \jacm
  6882. X
  6883. Xgets written out as 
  6884. X
  6885. X    JOURNAL = jacm
  6886. X
  6887. Xinstead of
  6888. X
  6889. X    JOURNAL = "jacm"   or        JOURNAL = "\jacm"
  6890. X
  6891. Xearlier.
  6892. X
  6893. XThu Jul 20 08:26:44 EDT 1989
  6894. X
  6895. XIntroduced a -pester flag, to quieten bibc's insistence about required
  6896. Xfields, and toggle appropriately from the command line.
  6897. X
  6898. XFri Jul 21 11:28:47 EDT 1989
  6899. X
  6900. Xbibv changed considerably, because it also accepts fields like...
  6901. X
  6902. X    From: Armin Liebl <liebla%lan.informatik.tu-muenchen.dbp.de@RELAY.CS.NET>
  6903. X    Date: 20 Jul 89 14:09:00 B
  6904. X    
  6905. X    > 4.) Your bibv-tool creates entries like
  6906. X    >        \nocite{osr=ACMOperatingSystemsReview}
  6907. X    >     if I have an entry 
  6908. X    >        @STRING{osr="ACM Operating Systems Review"}
  6909. X    ack! You are right! :-) I didn't realise this earlier.  Maybe, I'll just
  6910. X    chuck the sed expression in bibv, and put in a "\nocite{*}" there.
  6911. X    hmmmmmmmm......yeah, why not? Thanks, I'll do this rightaway...
  6912. X    
  6913. XSat Jul 22 15:05:11 EDT 1989
  6914. X
  6915. Xbibc now allows users to define their own fileds in addition to standard
  6916. Xpredefined ones.  The format of this is similiar to the MAILPATH
  6917. Xvariable used by the korn shell...
  6918. X/*
  6919. X * Now that the standard fields are defined, see if the user would like
  6920. X * to define specific fields for themselves.  Such fields are specified
  6921. X * by the user in tthe BIBCINIT environment variables.  The format of
  6922. X * his variable shall be similiar to the MAILPATH variable used by the
  6923. X * korn shell, as....
  6924. X *    <fieldname>?<optional help string>
  6925. X * multiple fields shall be separated by <COLON>s, ':'
  6926. X * A maximum of USR_DEFNS_MAX is taken....
  6927. X */
  6928. X    From: Armin Liebl <liebla%lan.informatik.tu-muenchen.dbp.de@RELAY.CS.NET>
  6929. X    Date: 20 Jul 89 14:09:00 B
  6930. X    
  6931. X    > 3.) A good feature that I miss (or that I didn't discover)
  6932. X    >     would be to allow the user to specify additional
  6933. X    >     fields (I for example use the additional field "key"
  6934. X    >     in my records).
  6935. X    I put in one such abitrary field, and called it "COMMENT".  I have to
  6936. X    work out how to put in such fields.  It isn't too difficult, just that I
  6937. X    haven't bothered.  I'll look into it.
  6938. X
  6939. XSat Jul 22 16:51:49 EDT 1989
  6940. X
  6941. XThe lex file, bibc.l is now generated automatically by gen_lex_file
  6942. Xusing prologue.lex, lexstrings.lex and postscript.lex!  This just made
  6943. Xmy life a wee bit easier...;-).
  6944. X
  6945. XWith this, all valid prefixes are accepted by lex, ie,
  6946. Xa, ar, art, .. etc.. are valid keys for article.....
  6947. X
  6948. XAlso, msthesis is now a valid input for mastersthesis, which too is
  6949. Xaccepted...
  6950. X
  6951. XSat Sep 16 23:15:59 EDT 1989
  6952. X
  6953. XGuess what, a replacement for gets.3 calls.  All gets() calls are now
  6954. Xreplaced by my_gets() in gets.c, which uses fgets() to get whole lines,
  6955. Xpiecemeal, and return nil terminated strings chopped to size available.
  6956. EOFile misc/Changes
  6957. chmod u=rw+,g=r++,o=r++ misc/Changes
  6958. echo '...done' 1>&2
  6959. if [ ! -d misc ] ; then
  6960.     echo -n Directory misc not found. Creating....
  6961.     mkdir misc
  6962.     if [ ! -d misc ] ; then
  6963.         echo ...failed
  6964.         echo unable to create directory misc.  Please create the directory and try again
  6965.         exit
  6966.     fi
  6967.     echo ...done
  6968. fi
  6969. echo -n "misc/README..." 1>&2
  6970. if test -f misc/README
  6971. then
  6972.     case $# in 
  6973.     0)
  6974.         echo 'exists, `sh filename -o'\'' to overwrite'
  6975.         exit 0;;
  6976.     esac
  6977.     case $1 in 
  6978.     -o)    ;;
  6979.     *)
  6980.         echo 'exists, `sh filename -o'\'' to overwrite'
  6981.         exit 0;;
  6982.     esac
  6983. fi
  6984. sed 's/^X//' << 'EOFile misc/README' > misc/README
  6985. XThis directorycontains various earlier attempts.
  6986. X
  6987. Xbibv.sh was a shell script attempt to do bibv
  6988. XChanges shows some evolutions that these tools underwent.
  6989. Xgets.c is the source to doing a gets() simulation with fgets() only
  6990. EOFile misc/README
  6991. chmod u=rw+,g=r++,o=r++ misc/README
  6992. echo '...done' 1>&2
  6993. if [ ! -d misc ] ; then
  6994.     echo -n Directory misc not found. Creating....
  6995.     mkdir misc
  6996.     if [ ! -d misc ] ; then
  6997.         echo ...failed
  6998.         echo unable to create directory misc.  Please create the directory and try again
  6999.         exit
  7000.     fi
  7001.     echo ...done
  7002. fi
  7003. echo -n "misc/bibv.sh..." 1>&2
  7004. if test -f misc/bibv.sh
  7005. then
  7006.     case $# in 
  7007.     0)
  7008.         echo 'exists, `sh filename -o'\'' to overwrite'
  7009.         exit 0;;
  7010.     esac
  7011.     case $1 in 
  7012.     -o)    ;;
  7013.     *)
  7014.         echo 'exists, `sh filename -o'\'' to overwrite'
  7015.         exit 0;;
  7016.     esac
  7017. fi
  7018. sed 's/^X//' << 'EOFile misc/bibv.sh' > misc/bibv.sh
  7019. X#! /bin/sh
  7020. X
  7021. XFN=`basename $0`
  7022. X
  7023. Xcase $# in
  7024. X0)    echo "$FN: Usage: bibv [-style style-to-use] [ <filename> ... ]"
  7025. X    exit
  7026. X    ;;
  7027. Xesac
  7028. X
  7029. XSTYLE=specl
  7030. Xcase $1 in
  7031. X"-style")    STYLE=$2; shift ; shift ;;
  7032. Xesac
  7033. X
  7034. Xcase $# in
  7035. X0)    echo "$FN: Usage: bibv [-style style-to-use] [ <filename> ... ]"
  7036. X    exit
  7037. X    ;;
  7038. Xesac
  7039. X
  7040. X
  7041. XFILE=bibtex
  7042. XBIBFILE=${FILE}.bib
  7043. XTEXFILE=${FILE}.tex
  7044. XTMPFIL1=sysut1.$$
  7045. X
  7046. Xtrap 'rm -f ${FILE}.bbl ${FILE}.aux ${FILE}.log ${FILE}.blg $TMPFIL1 ; exit' \
  7047. X                        1 2 3 15
  7048. X
  7049. XKEYS="@ARTI|@BOOK|@CONF|@INBO|@INCO|@INPR|@MANU|@MAST|@MISC|@PHDT|@PROC|@TECH|@UNPU"
  7050. X
  7051. X> $TEXFILE
  7052. X> ${FILE}.bbl
  7053. X> ${FILE}.aux
  7054. X> ${FILE}.log
  7055. X> ${FILE}.blg
  7056. X> $TMPFIL1
  7057. X
  7058. Xecho "\documentstyle{article}"                >> $TEXFILE
  7059. Xecho "\begin{document}"                    >> $TEXFILE
  7060. Xecho "\bibliographystyle{$STYLE}"            >> $TEXFILE
  7061. Xecho "\title{Verifying Biblio files}"            >> $TEXFILE
  7062. Xecho "\author{$USER}"                    >> $TEXFILE
  7063. Xecho "\date{\today}"                    >> $TEXFILE
  7064. Xecho "\maketitle"                    >> $TEXFILE
  7065. Xecho ""                            >> $TEXFILE
  7066. Xecho ""                            >> $TEXFILE
  7067. X
  7068. XBIBRECD=""
  7069. Xfor i
  7070. Xdo
  7071. X    file="`echo $i | sed 's/\.bib//'`"
  7072. X    bibfile=${file}.bib
  7073. X    echo "\section{FILE $bibfile}"            >> $TEXFILE
  7074. X    BIBRECD="${BIBRECD},${file}"
  7075. X    RECS=`tr [a-z] [A-Z] < $bibfile | egrep $KEYS | wc -l`
  7076. X    echo FILE $bibfile has $RECS records
  7077. X    sed -n '/^@s/d ; /^@S/d ; /^@.*{[     ]*\(.*\)[,     ]*/\\cite {\1}/p' $bibfile >> $TMPFIL1
  7078. X#    echo "%"                    >> $TMPFIL1
  7079. X#    echo "%    $bibfile"                >> $TMPFIL1
  7080. X#    echo "%"                    >> $TMPFIL1
  7081. X# This is not the exact sed expression to be used, but works in
  7082. X# most cases...it is left as commented LaTeX output for convenience...
  7083. X#    sed -n 's/^@.*{[     ]*\(.*\)/%\\nocite {\1}/p' $bibfile  |
  7084. X#        sed 's/[,     ]//g' >> $TMPFIL1
  7085. X
  7086. Xdone
  7087. XBIBRECD="`echo $BIBRECD | sed 's/,//'`"
  7088. X
  7089. Xecho "\bibliography{$BIBRECD}"                >> $TEXFILE
  7090. Xcat $TMPFIL1                        >> $TEXFILE
  7091. Xecho ""                            >> $TEXFILE
  7092. Xecho "\nocite{*}"                    >> $TEXFILE
  7093. Xecho ""                            >> $TEXFILE
  7094. Xecho "\end{document}"                    >> $TEXFILE
  7095. Xexit
  7096. X
  7097. X# Do this run silently....
  7098. Xlatex  $FILE    2>&- 1>&- </dev/null || {
  7099. X    echo "$FN: cannot run latex, see yah"
  7100. X    rm -f ${FILE}.bbl ${FILE}.aux ${FILE}.log ${FILE}.blg $TMPFIL1
  7101. X    exit
  7102. X    }
  7103. X
  7104. Xbibtex $FILE
  7105. Xlatex  $FILE    < /dev/null
  7106. X
  7107. X# Cleanup...
  7108. Xrm -f ${FILE}.bbl ${FILE}.aux ${FILE}.log ${FILE}.blg $TMPFIL1
  7109. X
  7110. Xecho "Now print out ${FILE}.dvi to see a hardcopy..."
  7111. X
  7112. Xexit
  7113. EOFile misc/bibv.sh
  7114. chmod u=rwx,g=r+x,o=r+x misc/bibv.sh
  7115. echo '...done' 1>&2
  7116. if [ ! -d misc ] ; then
  7117.     echo -n Directory misc not found. Creating....
  7118.     mkdir misc
  7119.     if [ ! -d misc ] ; then
  7120.         echo ...failed
  7121.         echo unable to create directory misc.  Please create the directory and try again
  7122.         exit
  7123.     fi
  7124.     echo ...done
  7125. fi
  7126. echo -n "misc/gets.c..." 1>&2
  7127. if test -f misc/gets.c
  7128. then
  7129.     case $# in 
  7130.     0)
  7131.         echo 'exists, `sh filename -o'\'' to overwrite'
  7132.         exit 0;;
  7133.     esac
  7134.     case $1 in 
  7135.     -o)    ;;
  7136.     *)
  7137.         echo 'exists, `sh filename -o'\'' to overwrite'
  7138.         exit 0;;
  7139.     esac
  7140. fi
  7141. sed 's/^X//' << 'EOFile misc/gets.c' > misc/gets.c
  7142. X/* ugh...I know of no better way..*sigh*     */
  7143. X#ifndef FILE
  7144. X#include <stdio.h>
  7145. X#endif
  7146. X#include "strings.h"
  7147. X
  7148. Xchar    *
  7149. Xmy_gets (buffer, size)
  7150. Xchar    *buffer;
  7151. Xint    size;
  7152. X
  7153. X/*
  7154. X * This is an emulation of gets() using fgets.3
  7155. X * This routine reads everything upto a newline, using fgets.3
  7156. X * 
  7157. X * OUTPUT: Returns buffer on exit, (char *) NULL on error
  7158. X * The contents of buffer are the input string, a max of (size -1)
  7159. X * characters are filled on exit,
  7160. X * The buffer is zeroed and returned on EOF.
  7161. X *
  7162. X * This routine only deals with EOF as an error cleanly.  On any other 
  7163. X * error returned by fgets.3, this routine will return will return
  7164. X * (char *) NULL and a partially filled buffer....*sigh*
  7165. X *
  7166. X * if EMUL_GETS is turned on, (it probably should, neh? :-) then
  7167. X * it converts any trailing NEWLINE character ('\n') to a NIL ('\0')
  7168. X * character, else, it leaves them alone
  7169. X */
  7170. X
  7171. X#ifdef BUFSIZE
  7172. X#undef BUFSIZE
  7173. X#endif
  7174. X#define    BUFSIZE    512
  7175. X#define    EMUL_GETS
  7176. X
  7177. X{
  7178. Xint    sizeleft, cursize;
  7179. Xchar    lbuf[BUFSIZE];    /* These figures are unimportant...leave well alone */
  7180. Xchar    *foo, *answer;
  7181. Xint    done;
  7182. X
  7183. X    sizeleft = size - 1;
  7184. X    bzero (buffer, size);
  7185. X    answer = buffer;
  7186. X    done = 0;
  7187. X
  7188. X    while (done != 1)
  7189. X      {
  7190. X      if (fgets (lbuf, BUFSIZE, stdin) == (char *) NULL)
  7191. X        {
  7192. X        done = 1    /* EOF or ERROR    */    ;
  7193. X        answer = (char *) NULL;
  7194. X        }
  7195. X      else if ((foo = Index (lbuf, '\n')) != (char *) NULL)
  7196. X        {            /* DONE */
  7197. X        if (sizeleft > 0)
  7198. X          strncat (buffer, lbuf, sizeleft);
  7199. X        done = 1;
  7200. X        }
  7201. X      else if (sizeleft > 0)
  7202. X        {            /* COPY    */
  7203. X        cursize = strlen (lbuf);
  7204. X        if (cursize <= sizeleft)
  7205. X          {
  7206. X          strncat (buffer, lbuf, cursize);
  7207. X          sizeleft -= cursize;
  7208. X          }
  7209. X        else
  7210. X          {
  7211. X          strncat (buffer, lbuf, sizeleft);
  7212. X          sizeleft = 0;
  7213. X          }
  7214. X        }
  7215. X      }
  7216. X
  7217. X#ifdef EMUL_GETS
  7218. X    if ((foo = Index (buffer, '\n')) != (char *) NULL)
  7219. X      *foo = '\0';
  7220. X#endif
  7221. X    return answer;
  7222. X}
  7223. EOFile misc/gets.c
  7224. chmod u=rw+,g=r++,o=r++ misc/gets.c
  7225. echo '...done' 1>&2
  7226. echo Now gitouttaere
  7227. exit
  7228.  
  7229.  
  7230. -=-
  7231. Kannan Varadhan, Ohio Supercomputer Center, Columbus, OH 43212  [(614) 292-4137]
  7232. email:    kannan@osc.edu    |  osu-cis!oscsunb!kannan
  7233.