home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / compsrcs / misc / volume09 / bibtools < prev    next >
Encoding:
Internet Message Format  |  1991-08-27  |  171.3 KB

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