rokicki@rocky.STANFORD.EDU (Tomas Rokicki) (12/30/87)
Enough people have asked for this who don't have Internet access, that I thought I'd post it. It's about 180K total, in six parts. The whole thing is one big source file, created automatically from the Pascal source by a translator I put together. Here goes! ---cut here--- /* * BibTeX in C by Radical Eye Software. This program may be * freely distributed and used as anyone sees fit, but Tomas * Rokicki maintains (C) 1987 on this C code. It may not be * distributed without this comment on the top. Bug reports, * complaints, and kudo's to rokicki@sushi.stanford.edu or * ...!decvax!decwrl!navajo.stanford.edu!rokicki. */ #include <stdio.h> #define TEXBIB ".,/usr/stanford/lib/tex82/macros" #define TEXINPUTS ".,/usr/stanford/lib/tex82/macros" #define incr(a) a++ #define decr(a) a-- #define cnull NULL #define ceof EOF #define cnewline (10) #define odd(a) ((a & 1) != 0) #define true (1) #define false (0) #define chr(a) (a) typedef int integer ; typedef unsigned short halfword ; typedef unsigned char quarterword ; typedef float real ; typedef char boolean ; #define aopenin(a,w) zaopenin(&(a),w) #define aopenout(a) zaopenout(&(a)) #define jumpout(a) zjumpout((integer)(a)) #define printpoolstr(a) zprintpoolstr((strnumber)(a)) #define traceprpoolstr(a) ztraceprpoolstr((strnumber)(a)) #define printfnclass(a) zprintfnclass((hashloc)(a)) #define traceprfnclass(a) ztraceprfnclass((hashloc)(a)) #define alreadyseenfunctionp(a) zalreadyseenfunctionp((hashloc)(a)) #define biboneoftwoprint(a,b) zbiboneoftwoprint((ASCIIcode)(a),(ASCIIcode)(b)) #define printstklit(a,b) zprintstklit((integer)(a),(stktype)(b)) #define printlit(a,b) zprintlit((integer)(a),(stktype)(b)) #define startname(a) zstartname((strnumber)(a)) #define addextension(a) zaddextension((strnumber)(a)) #define streqbuf(a,b,c,d) zstreqbuf((strnumber)(a),(b),(bufpointer)(c),(bufpointer)(d)) #define streqstr(a,b) zstreqstr((strnumber)(a),(strnumber)(b)) #define lowercase(a,b,c) zlowercase((a),(bufpointer)(b),(bufpointer)(c)) #define uppercase(a,b,c) zuppercase((a),(bufpointer)(b),(bufpointer)(c)) #define strlookup(a,b,c,d,e) zstrlookup((a),(bufpointer)(b),(bufpointer)(c),(strilk)(d),(boolean)(e)) #define predefine(a,b) zpredefine((a),(strilk)(b)) #define inttoASCII(a,b,c) zinttoASCII((integer)(a),(b),(bufpointer)(c)) #define swap(a,b) zswap((citenumber)(a),(citenumber)(b)) #define cycle(a,b,c) zcycle((citenumber)(a),(citenumber)(b),(citenumber)(c)) #define lessthan(a,b) zlessthan((citenumber)(a),(citenumber)(b)) #define quicksort(a,b) zquicksort((citenumber)(a),(citenumber)(b)) #define buildin(a,b) zbuildin((a),(bltinrange)(b)) #define scan1(a) zscan1((ASCIIcode)(a)) #define scan1white(a) zscan1white((ASCIIcode)(a)) #define scan2(a,b) zscan2((ASCIIcode)(a),(ASCIIcode)(b)) #define scan2white(a,b) zscan2white((ASCIIcode)(a),(ASCIIcode)(b)) #define scan3(a,b,c) zscan3((ASCIIcode)(a),(ASCIIcode)(b),(ASCIIcode)(c)) #define scanidentifier(a,b) zscanidentifier((ASCIIcode)(a),(ASCIIcode)(b)) #define scanfndef(a) zscanfndef((hashloc)(a)) #define decrbracelevel(a) zdecrbracelevel((strnumber)(a)) #define checkbracelevel(a) zcheckbracelevel((strnumber)(a)) #define namescanforand(a) znamescanforand((strnumber)(a)) #define pushlitstk(a,b) zpushlitstk((integer)(a),(stktype)(b)) #define poplitstk(a) zpoplitstk(&(a)) #define printwrongstklit(a,b,c) zprintwrongstklit((integer)(a),(stktype)(b),(stktype)(c)) #define addbufpool(a) zaddbufpool((strnumber)(a)) #define addoutpool(a) zaddoutpool((strnumber)(a)) #define executefn(a) zexecutefn((hashloc)(a)) #define tputi(f,a) ztputi(f,(integer)(a)) #define mymalloc(p,n) zmymalloc(&(p),(integer)(n)) #define bufsize 1000 #define minprintline 3 #define maxprintline 79 #define auxstacksize 20 #define maxbibfiles 20 #define poolsize 60000 #define maxstrings 4000 #define maxcites 750 #define wizfnspace 3000 #define singlefnspace 100 #define maxentints 3000 #define maxentstrs 3000 #define maxglobstrs 20 #define maxfields 15000 #define litstksize 100 #define numbltinfns 32 typedef quarterword ASCIIcode ; typedef quarterword lextype ; typedef quarterword idtype ; typedef FILE *alphafile ; typedef halfword bufpointer ; typedef ASCIIcode buftype[bufsize+1] ; typedef halfword poolpointer ; typedef halfword strnumber ; typedef halfword hashloc ; typedef halfword hashpointer ; typedef quarterword strilk ; typedef quarterword pdsloc ; typedef quarterword pdslen ; typedef char *pdstype ; typedef quarterword auxnumber ; typedef quarterword bibnumber ; typedef halfword citenumber ; typedef quarterword fnclass ; typedef halfword wizfnloc ; typedef halfword intentloc ; typedef halfword strentloc ; typedef quarterword strglobloc ; typedef halfword fieldloc ; typedef halfword hashptr2 ; typedef quarterword litstkloc ; typedef quarterword stktype ; typedef quarterword bltinrange ; integer bad ; ASCIIcode xord[128] ; char xchr[128] = { ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , 9 , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , '!' , '"' , '#' , '$' , '%' , '&' , '\'' , '(' , ')' , '*' , '+' , ',' , '-' , '.' , '/' , '0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , ':' , ';' , '<' , '=' , '>' , '?' , '@' , 'A' , 'B' , 'C' , 'D' , 'E' , 'F' , 'G' , 'H' , 'I' , 'J' , 'K' , 'L' , 'M' , 'N' , 'O' , 'P' , 'Q' , 'R' , 'S' , 'T' , 'U' , 'V' , 'W' , 'X' , 'Y' , 'Z' , '[' , '\\' , ']' , '^' , '_' , '`' , 'a' , 'b' , 'c' , 'd' , 'e' , 'f' , 'g' , 'h' , 'i' , 'j' , 'k' , 'l' , 'm' , 'n' , 'o' , 'p' , 'q' , 'r' , 's' , 't' , 'u' , 'v' , 'w' , 'x' , 'y' , 'z' , '{' , '|' , '}' , '~' , ' ' } ; lextype lexclass[128] ; idtype idclass[128] ; integer charwidth[128] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 278, 278, 500, 833, 500, 833, 778, 278, 389, 389, 500, 778, 278, 333, 278, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 278, 278, 278, 778, 472, 472, 778, 750, 708, 722, 764, 681, 653, 785, 750, 361, 514, 778, 625, 917, 750, 778, 681, 778, 736, 556, 722, 750, 750, 1028, 750, 750, 611, 278, 500, 278, 500, 278, 278, 500, 556, 444, 556, 444, 306, 500, 556, 278, 306, 528, 278, 833, 556, 500, 556, 528, 395, 394, 389, 556, 528, 722, 528, 528, 444, 500, 1000, 500, 500, 0 } ; integer stringwidth ; char nameoffile[101] ; quarterword namelength ; quarterword nameptr ; buftype buffer ; bufpointer last ; buftype svbuffer ; bufpointer svptr1 ; bufpointer svptr2 ; bufpointer tmpptr ; ASCIIcode strpool[poolsize+1] ; poolpointer strstart[maxstrings+1] ; poolpointer poolptr ; strnumber strptr ; strnumber strnum ; poolpointer pptr1, pptr2 ; hashpointer hashnext[5001] ; strnumber hashtext[5001] ; strilk hashilk[5001] ; integer ilkinfo[5001] ; halfword hashused ; boolean hashfound ; hashloc dummyloc ; strnumber sauxextension ; strnumber slogextension ; strnumber sbblextension ; strnumber sbstextension ; strnumber sbibextension ; hashloc predefloc ; integer commandnum ; bufpointer bufptr1 ; bufpointer bufptr2 ; quarterword scanresult ; integer tokenvalue ; alphafile auxfile[auxstacksize+1] ; strnumber auxlist[auxstacksize+1] ; auxnumber auxptr ; integer auxlnstack[auxstacksize+1] ; strnumber toplevstr ; alphafile logfile ; alphafile bblfile ; strnumber biblist[maxbibfiles+1] ; bibnumber bibptr ; bibnumber numbibfiles ; boolean bibseen ; alphafile bibfile[maxbibfiles+1] ; boolean bstseen ; strnumber bststr ; alphafile bstfile ; strnumber citelist[maxcites+1] ; citenumber citeptr ; citenumber numcites ; boolean citationseen ; hashloc citeloc ; hashloc lcciteloc ; boolean citefound ; integer bbllinenum ; integer bstlinenum ; hashloc fnloc ; hashloc wizloc ; hashloc literalloc ; hashloc macronameloc ; hashloc macrodefloc ; fnclass fntype[5001] ; wizfnloc wizdefptr ; wizfnloc wizfnptr ; hashptr2 wizfunctions[3001] ; intentloc intentptr ; integer entryints[maxentints+1] ; integer numentints ; strentloc strentptr ; ASCIIcode *entrystrs[maxentstrs+1] ; integer numentstrs ; strglobloc strglbptr ; ASCIIcode *globalstrs[maxglobstrs+1] ; strglobloc numglbstrs ; fieldloc fieldptr ; hashpointer fieldinfo[maxfields+1] ; integer numfields ; boolean entryseen ; boolean readseen ; boolean readperformed ; integer implfnnum ; integer biblinenum ; hashloc entrytypeloc ; hashptr2 typelist[maxcites+1] ; boolean typeexists ; boolean storeentry ; hashloc fieldnameloc ; hashloc fieldvalloc ; boolean storefield ; ASCIIcode rightouterdelim ; ASCIIcode rightstrdelim ; integer bibbracelevel ; bufpointer fieldend ; integer litstack[101] ; stktype litstktype[101] ; litstkloc litstkptr ; strnumber cmdstrptr ; quarterword entchrptr ; halfword globchrptr ; buftype exbuf ; bufpointer exbufptr ; bufpointer exbuflength ; buftype outbuf ; bufpointer outbufptr ; bufpointer outbuflength ; boolean messwithentries ; citenumber sortedcites[maxcites+1] ; citenumber sortciteptr ; strentloc sortkeynum ; integer bracelevel ; hashloc bequals ; hashloc bgreaterthan ; hashloc blessthan ; hashloc bplus ; hashloc bminus ; hashloc bconcatenate ; hashloc bgets ; hashloc baddperiod ; hashloc bcalltype ; hashloc bchangecase ; hashloc bchrtoint ; hashloc bcite ; hashloc bduplicate ; hashloc bformatname ; hashloc bif ; hashloc binttochr ; hashloc binttostr ; hashloc bmissing ; hashloc bnewline ; hashloc bnumnames ; hashloc bpop ; hashloc bpurify ; hashloc bquote ; hashloc bskip ; hashloc bstack ; hashloc bsubstring ; hashloc bswap ; hashloc btopstack ; hashloc btype ; hashloc bwhile ; hashloc bwidth ; hashloc bwrite ; hashloc bdefault ; char *gargv ; int gchrc ; #ifdef STAT hashloc bltinloc[numbltinfns+1] ; integer executioncount[numbltinfns+1] ; bltinrange bltinptr ; #endif strnumber snull ; strnumber sdefault ; strnumber sul ; strnumber sll ; strnumber suu ; strnumber slu ; strnumber speriod ; integer poplit1, poplit2, poplit3 ; stktype poptyp1, poptyp2, poptyp3 ; poolpointer spptr ; poolpointer spxptr1, spxptr2 ; poolpointer spend ; integer spbracelevel ; bufpointer exbufxptr ; boolean precedingwhite ; boolean andfound ; integer numnames ; bufpointer namebfptr ; bufpointer namebfxptr ; integer nmbracelevel ; bufpointer nametok[1001] ; bufpointer numtokens ; boolean tokenstarting ; boolean alphafound ; boolean doubleletter, endofgroup, tobewritten ; bufpointer firststart ; bufpointer firstend ; bufpointer lastend ; bufpointer vonstart ; bufpointer vonend ; bufpointer jrend ; bufpointer curtoken, lasttoken ; boolean usedefault ; bufpointer numcommas ; bufpointer comma1, comma2 ; quarterword conversiontype ; char texbib[200], texinputs[200] ; setupenv() { char *p ; char *getenv() ; if ((p = getenv("TEXBIB")) == NULL) strcpy(texbib, TEXBIB) ; else strcpy(texbib, p) ; if ((p = getenv("TEXINPUTS")) == NULL) strcpy(texinputs, TEXINPUTS) ; else strcpy(texinputs, p) ; } ztputi ( f , i ) alphafile f ; integer i ; { if ( f == NULL ) { fprintf ( stdout , "%ld" , i ) ; fprintf ( logfile , "%ld" , i ) ; } else fprintf ( f , "%ld" , i ) ; } tputs ( f , s ) alphafile f ; char *s ; { if ( f == NULL ) { fputs ( s , stdout ) ; fputs ( s , logfile ) ; } else fputs ( s , f ) ; } tputc ( f , s ) alphafile f ; char s ; { if ( f == NULL ) { fputc ( s , stdout ) ; fputc ( s , logfile ) ; } else fputc ( s , f ) ; } zjumpout ( i ) integer i ; { if ( i == 1 ) traceandstatprinting () ; exit ( 0 ) ; } zmymalloc ( p , n ) quarterword **p ; integer n ; { char *malloc() ; if ( *p ) free ( *p ) ; *p = ( quarterword * ) malloc ( n ) ; if ( ! *p ) { tputs ( cnull , "Out of memory during string allocation.\n" ) ; jumpout ( 1 ) ; } } boolean inputln ( f ) alphafile f ; { /* 15 */ integer c ; last = 0 ; if ( ( feof ( f ) ) ) return ( false ) ; else { c = getc ( f ) ; while ( ( c != 10 && ! feof ( f ) ) ) { if ( ( last >= bufsize ) ) { tputs ( cnull , "Sorry, you've exceeded BibTeX's buffer size " ) ; tputi ( cnull , bufsize ) ; tputc ( cnull , 10 ) ; jumpout ( 1 ) ; } buffer [ last ] = xord [ c ] ; c = getc ( f ) ; incr ( last ) ; } while ( ( last > 0 ) ) if ( ( lexclass [ buffer [ last - 1 ] ] == 1 ) ) decr ( last ) ; else goto lab15 ; lab15 : return ( true ) ; } } zprintpoolstr ( s ) strnumber s ; { poolpointer i ; if ( ( ( s < 0 ) || ( s >= strptr + 3 ) || ( s >= maxstrings ) ) ) { tputs ( cnull , "this can't happen---illegal string number:" ) ; tputi ( cnull , s ) ; tputc ( cnull , 10 ) ; } for ( i = strstart [ s ] ; i <= strstart [ s + 1 ] - 1 ; i ++ ) { fputc ( xchr [ strpool [ i ] ] , stdout ) ; fputc ( xchr [ strpool [ i ] ] , logfile ) ; } } ztraceprpoolstr ( s ) strnumber s ; { poolpointer i ; if ( ( ( s < 0 ) || ( s >= strptr + 3 ) || ( s >= maxstrings ) ) ) { tputs ( logfile , "this can't happen---illegal string number:" ) ; tputi ( logfile , s ) ; tputc ( logfile , 10 ) ; } for ( i = strstart [ s ] ; i <= strstart [ s + 1 ] - 1 ; i ++ ) { fputc ( xchr [ strpool [ i ] ] , logfile ) ; } } printtoken () { bufpointer i ; i = bufptr1 ; while ( ( i < bufptr2 ) ) { fputc ( xchr [ buffer [ i ] ] , stdout ) ; fputc ( xchr [ buffer [ i ] ] , logfile ) ; incr ( i ) ; } } traceprtoken () { bufpointer i ; i = bufptr1 ; while ( ( i < bufptr2 ) ) { fputc ( xchr [ buffer [ i ] ] , logfile ) ; incr ( i ) ; } } printbadinputline () { bufpointer bfptr ; tputs ( cnull , " : " ) ; bfptr = 0 ; while ( ( bfptr < bufptr2 ) ) { if ( ( lexclass [ buffer [ bfptr ] ] == 1 ) ) tputc ( cnull , xchr [ 32 ] ) ; else tputc ( cnull , xchr [ buffer [ bfptr ] ] ) ; incr ( bfptr ) ; } tputc ( cnull , 10 ) ; tputs ( cnull , " : " ) ; bfptr = 0 ; while ( ( bfptr < bufptr2 ) ) { tputs ( cnull , " " ) ; incr ( bfptr ) ; } bfptr = bufptr2 ; while ( ( bfptr < last ) ) { if ( ( lexclass [ buffer [ bfptr ] ] == 1 ) ) tputs ( cnull , " " ) ; else { fputc ( xchr [ buffer [ bfptr ] ] , stdout ) ; fputc ( xchr [ buffer [ bfptr ] ] , logfile ) ; } incr ( bfptr ) ; } tputc ( cnull , 10 ) ; } printauxname () { printpoolstr ( auxlist [ auxptr ] ) ; tputc ( cnull , 10 ) ; } auxerrprint () { tputs ( cnull , "---line " ) ; tputi ( cnull , auxlnstack [ auxptr ] ) ; tputs ( cnull , " of file " ) ; printauxname () ; } printbibname () { printpoolstr ( biblist [ bibptr ] ) ; printpoolstr ( sbibextension ) ; tputc ( cnull , 10 ) ; } printbstname () { printpoolstr ( bststr ) ; printpoolstr ( sbstextension ) ; tputc ( cnull , 10 ) ; } auxenderrprint () { tputs ( cnull , "---while reading file " ) ; printauxname () ; } bsterrprintandlookfo () { tputs ( cnull , "---line " ) ; tputi ( cnull , bstlinenum ) ; tputs ( cnull , " of file " ) ; printbstname () ; printbadinputline () ; while ( ( last != 0 ) ) if ( ( ! inputln ( bstfile ) ) ) { aclose ( bstfile ) ; aclose ( bblfile ) ; jumpout ( 1 ) ; } else incr ( bstlinenum ) ; bufptr2 = last ; } bstwarnprint () { tputs ( cnull , "---line " ) ; tputi ( cnull , bstlinenum ) ; tputs ( cnull , " of file " ) ; printbstname () ; } eatbstprint () { tputs ( cnull , "illegal end of style file in command: " ) ; } zprintfnclass ( fnloc ) hashloc fnloc ; { switch ( fntype [ fnloc ] ) { case 0 : tputs ( cnull , "built-in" ) ; break ; case 1 : tputs ( cnull , "macro" ) ; break ; case 2 : tputs ( cnull , "wizard-defined" ) ; break ; case 3 : tputs ( cnull , "integer-literal" ) ; break ; case 4 : tputs ( cnull , "string-literal" ) ; break ; case 5 : tputs ( cnull , "field" ) ; break ; case 6 : tputs ( cnull , "integer-entry-variable" ) ; break ; case 7 : tputs ( cnull , "string-entry-variable" ) ; break ; case 8 : tputs ( cnull , "integer-global-variable" ) ; break ; case 9 : tputs ( cnull , "string-global-variable" ) ; break ; default : tputs ( cnull , "this can't happen---unknown function class" ) ; break ; } } #ifdef TRACE ztraceprfnclass ( fnloc ) hashloc fnloc ; { switch ( fntype [ fnloc ] ) { case 0 : tputs ( logfile , "built-in" ) ; break ; case 1 : tputs ( logfile , "macro" ) ; break ; case 2 : tputs ( logfile , "wizard-defined" ) ; break ; case 3 : tputs ( logfile , "integer-literal" ) ; break ; case 4 : tputs ( logfile , "string-literal" ) ; break ; case 5 : tputs ( logfile , "field" ) ; break ; case 6 : tputs ( logfile , "integer-entry-variable" ) ; break ; case 7 : tputs ( logfile , "string-entry-variable" ) ; break ; case 8 : tputs ( logfile , "integer-global-variable" ) ; break ; case 9 : tputs ( logfile , "string-global-variable" ) ; break ; default : tputs ( cnull , "this can't happen---unknown function class" ) ; break ; } } #endif bstidprint () { if ( ( scanresult == 0 ) ) { tputs ( cnull , "\"" ) ; tputc ( cnull , xchr [ buffer [ bufptr2 ] ] ) ; tputs ( cnull , "\" begins identifier, command: " ) ; } else if ( ( scanresult == 2 ) ) { tputs ( cnull , "\"" ) ; tputc ( cnull , xchr [ buffer [ bufptr2 ] ] ) ; tputs ( cnull , "\" immediately follows identifier, command: " ) ; } else tputs ( cnull , "this can't happen---identifier scanning error, command: " ) ; } bstleftbraceprint () { tputs ( cnull , "\"{\" is missing in command: " ) ; } bstrightbraceprint () { tputs ( cnull , "\"}\" is missing in command: " ) ; } zalreadyseenfunctionp ( seenfnloc ) hashloc seenfnloc ; { /* 10 */ printpoolstr ( hashtext [ seenfnloc ] ) ; tputs ( cnull , " is already a type " ) ; printfnclass ( seenfnloc ) ; tputs ( cnull , " function name\n" ) ; { tputs ( cnull , " " ) ; bsterrprintandlookfo () ; goto lab10 ; } lab10 : ; } printfunctiontypebst () { printtoken () ; tputs ( cnull , " has a bad function type---" ) ; printfnclass ( fnloc ) ; { tputs ( cnull , " " ) ; bstwarnprint () ; } } biberrprint () { tputs ( cnull , "---line " ) ; tputi ( cnull , biblinenum ) ; tputs ( cnull , " of file " ) ; printbibname () ; printbadinputline () ; } bibwarnprint () { tputs ( cnull , "--warning--line " ) ; tputi ( cnull , biblinenum ) ; tputs ( cnull , " of file " ) ; printbibname () ; } eatbibprint () { /* 10 */ { tputs ( cnull , "illegal end of database file" ) ; biberrprint () ; goto lab10 ; } lab10 : ; } zbiboneoftwoprint ( char1 , char2 ) ASCIIcode char1 , char2 ; { /* 10 */ { tputs ( cnull , "I was expecting a `" ) ; tputc ( cnull , xchr [ char1 ] ) ; tputs ( cnull , "' or a `" ) ; tputc ( cnull , xchr [ char2 ] ) ; tputs ( cnull , "'" ) ; biberrprint () ; goto lab10 ; } lab10 : ; } bibequalssignprint () { /* 10 */ { tputs ( cnull , "I was expecting an \"=\"" ) ; biberrprint () ; goto lab10 ; } lab10 : ; } bibunbalancedbracesp () { /* 10 */ { tputs ( cnull , "unbalanced braces" ) ; biberrprint () ; goto lab10 ; } lab10 : ; } bibfieldtoolongprint () { /* 10 */ { tputs ( cnull , "your field is more than " ) ; tputi ( cnull , bufsize ) ; tputs ( cnull , " characters" ) ; biberrprint () ; goto lab10 ; } lab10 : ; } bibidprint () { if ( ( scanresult == 0 ) ) { tputs ( cnull , "\"" ) ; tputc ( cnull , xchr [ buffer [ bufptr2 ] ] ) ; tputs ( cnull , "\" begins " ) ; } else if ( ( scanresult == 2 ) ) { tputs ( cnull , "\"" ) ; tputc ( cnull , xchr [ buffer [ bufptr2 ] ] ) ; tputs ( cnull , "\" immediately follows " ) ; } else tputs ( cnull , "this can't happen---identifier scanning error, for " ) ; } bstexwarnprint () { if ( ( messwithentries ) ) { tputs ( cnull , " for entry " ) ; printpoolstr ( citelist [ citeptr ] ) ; } tputs ( cnull , "--warning\n" ) ; { tputs ( cnull , " while executing" ) ; bstwarnprint () ; } } zprintstklit ( stklt , stktp ) integer stklt ; stktype stktp ; { tputs ( cnull , " : " ) ; switch ( stktp ) { case 0 : { tputi ( cnull , stklt ) ; tputs ( cnull , " is an integer literal" ) ; } break ; case 1 : { tputs ( cnull , "\"" ) ; printpoolstr ( stklt ) ; tputs ( cnull , "\" is a string literal" ) ; } break ; case 2 : { tputs ( cnull , "`" ) ; printpoolstr ( hashtext [ stklt ] ) ; tputs ( cnull , "' is a function literal" ) ; } break ; case 3 : { tputs ( cnull , "`" ) ; printpoolstr ( stklt ) ; tputs ( cnull , "' is a missing field" ) ; } break ; case 4 : tputs ( cnull , "empty stack when popping this--bad literal" ) ; break ; default : tputs ( cnull , "this can't happen---unknown literal type\n" ) ; break ; } } zprintlit ( stklt , stktp ) integer stklt ; stktype stktp ; { tputs ( cnull , " : " ) ; switch ( stktp ) { case 0 : { tputi ( cnull , stklt ) ; tputc ( cnull , 10 ) ; } break ; case 1 : { printpoolstr ( stklt ) ; tputc ( cnull , 10 ) ; } break ; case 2 : { printpoolstr ( hashtext [ stklt ] ) ; tputc ( cnull , 10 ) ; } break ; case 3 : { printpoolstr ( stklt ) ; tputc ( cnull , 10 ) ; } break ; case 4 : tputs ( cnull , "the stack was empty when this was popped\n" ) ; break ; default : tputs ( cnull , "this can't happen---unknown literal type\n" ) ; break ; } } outputbblline () { /* 15 10 */ if ( ( outbuflength != 0 ) ) { while ( ( outbuflength > 0 ) ) if ( ( lexclass [ outbuf [ outbuflength - 1 ] ] == 1 ) ) decr ( outbuflength ) ; else goto lab15 ; lab15 : if ( ( outbuflength == 0 ) ) goto lab10 ; outbufptr = 0 ; while ( ( outbufptr < outbuflength ) ) { fputc ( xchr [ outbuf [ outbufptr ] ] , bblfile ) ; incr ( outbufptr ) ; } } tputc ( bblfile , 10 ) ; incr ( bbllinenum ) ; outbuflength = 0 ; lab10 : ; } traceandstatprinting () { #ifdef TRACE { tputs ( logfile , "the " ) ; tputi ( logfile , numbibfiles ) ; tputs ( logfile , " database files are\n" ) ; if ( ( numbibfiles == 0 ) ) tputs ( logfile , " undefined\n" ) ; else { bibptr = 0 ; while ( ( bibptr < numbibfiles ) ) { tputs ( logfile , " " ) ; traceprpoolstr ( biblist [ bibptr ] ) ; traceprpoolstr ( sbibextension ) ; tputc ( logfile , 10 ) ; incr ( bibptr ) ; } } tputs ( logfile , "the style file is " ) ; if ( ( bststr == 0 ) ) tputs ( logfile , "undefined\n" ) ; else { traceprpoolstr ( bststr ) ; traceprpoolstr ( sbstextension ) ; tputc ( logfile , 10 ) ; } } { tputs ( logfile , "the " ) ; tputi ( logfile , numcites ) ; tputs ( logfile , " \\cite keys:\n" ) ; if ( ( numcites == 0 ) ) tputs ( logfile , " undefined\n" ) ; else { sortciteptr = 0 ; while ( ( sortciteptr < numcites ) ) { if ( ( ! readperformed ) ) citeptr = sortciteptr ; else citeptr = sortedcites [ sortciteptr ] ; traceprpoolstr ( citelist [ citeptr ] ) ; if ( ( readperformed ) ) { tputs ( logfile , " of entry-type " ) ; if ( ( typelist [ citeptr ] == 5001 ) ) lab5001 : tputs ( logfile , "unknown," ) ; else if ( ( typelist [ citeptr ] == 0 ) ) tputs ( logfile , "--- no type found," ) ; else traceprpoolstr ( hashtext [ typelist [ citeptr ] ] ) ; tputs ( logfile , " has entry strings\n" ) ; { if ( ( numentstrs == 0 ) ) tputs ( logfile , " undefined\n" ) ; else { strentptr = citeptr * numentstrs ; while ( ( strentptr < ( citeptr + 1 ) * numentstrs ) ) { entchrptr = 0 ; tputs ( logfile , " \"" ) ; while ( ( entrystrs [ strentptr ] [ entchrptr ] != 127 ) ) { fputc ( xchr [ entrystrs [ strentptr ] [ entchrptr ] ] , logfile ) ; incr ( entchrptr ) ; } tputs ( logfile , "\"\n" ) ; incr ( strentptr ) ; } } } tputs ( logfile , "and has entry integers" ) ; { if ( ( numentints == 0 ) ) tputs ( logfile , " undefined" ) ; else { intentptr = citeptr * numentints ; while ( ( intentptr < ( citeptr + 1 ) * numentints ) ) { tputs ( logfile , " " ) ; tputi ( logfile , entryints [ intentptr ] ) ; incr ( intentptr ) ; } } tputc ( logfile , 10 ) ; } } else tputc ( logfile , 10 ) ; incr ( sortciteptr ) ; } } } { tputs ( logfile , "the wiz-defined functions are\n" ) ; if ( ( wizdefptr == 0 ) ) tputs ( logfile , " nonexistent\n" ) ; else { wizfnptr = 0 ; while ( ( wizfnptr < wizdefptr ) ) { if ( ( wizfunctions [ wizfnptr ] == 5001 ) ) { tputi ( logfile , wizfnptr ) ; tputs ( logfile , "--end-of-def--\n" ) ; } else if ( ( wizfunctions [ wizfnptr ] == 0 ) ) { tputi ( logfile , wizfnptr ) ; tputs ( logfile , " quote_next_function " ) ; } else { tputi ( logfile , wizfnptr ) ; tputs ( logfile , " `" ) ; traceprpoolstr ( hashtext [ wizfunctions [ wizfnptr ] ] ) ; tputs ( logfile , "'\n" ) ; } incr ( wizfnptr ) ; } } } { tputs ( logfile , "the string pool is\n" ) ; strnum = 1 ; while ( ( strnum < strptr ) ) { fprintf ( logfile , "%4d%6d \"" , strnum , strstart [ strnum ] ) ; traceprpoolstr ( strnum ) ; tputs ( logfile , "\"\n" ) ; incr ( strnum ) ; } } #endif #ifdef STAT { tputs ( logfile , "you've used " ) ; tputi ( logfile , numcites ) ; tputs ( logfile , " \\cite keys,\n" ) ; { tputs ( logfile , " " ) ; tputi ( logfile , wizdefptr ) ; tputs ( logfile , " wiz_defined-function locations,\n" ) ; } { tputs ( logfile , " " ) ; tputi ( logfile , strptr ) ; tputs ( logfile , " strings with " ) ; tputi ( logfile , strstart [ strptr ] ) ; tputs ( logfile , " characters,\n" ) ; } tputs ( logfile , "and the built_in function-call counts are:\n" ) ; bltinptr = 0 ; while ( ( bltinptr < numbltinfns ) ) { traceprpoolstr ( hashtext [ bltinloc [ bltinptr ] ] ) ; { tputs ( logfile , "---" ) ; tputi ( logfile , executioncount [ bltinptr ] ) ; tputc ( logfile , 10 ) ; } incr ( bltinptr ) ; } } #endif } boolean zaopenin ( f , where ) alphafile *f ; char *where ; { char realnameoffile[132], *p, *w ; while (*where != 0) { w = realnameoffile ; if (*where == '.') where++ ; else { while (*where != ',' && *where != 0) *w++ = *where++ ; *w++ = '/' ; } if (*where == ',') where++ ; p = nameoffile + 1 ; while (*p != 0 && *p != ' ') *w++ = *p++ ; *w++ = 0 ; if ( *f = fopen ( realnameoffile , "r" ) ) return ( 1 ) ; } return ( 0 ) ; } boolean zaopenout ( f ) alphafile *f ; { *f = fopen ( nameoffile + 1 , "w" ) ; return ( *f != cnull ) ; } aclose ( f ) alphafile f ; { fclose ( f ) ; } zstartname ( filename ) strnumber filename ; { poolpointer pptr ; if ( ( ( strstart [ filename + 1 ] - strstart [ filename ] ) > 100 ) ) { tputs ( cnull , "file " ) ; printpoolstr ( filename ) ; tputs ( cnull , "," ) ; { tputs ( cnull , "Sorry, you've exceeded BibTeX's file name size " ) ; tputi ( cnull , 100 ) ; tputc ( cnull , 10 ) ; jumpout ( 1 ) ; } } nameptr = 1 ; pptr = strstart [ filename ] ; while ( ( pptr < strstart [ filename + 1 ] ) ) { nameoffile [ nameptr ] = chr ( strpool [ pptr ] ) ; incr ( nameptr ) ; incr ( pptr ) ; } namelength = ( strstart [ filename + 1 ] - strstart [ filename ] ) ; } zaddextension ( ext ) strnumber ext ; { poolpointer pptr ; if ( ( namelength + ( strstart [ ext + 1 ] - strstart [ ext ] ) > 99 ) ) { { tputs ( cnull , "Sorry, you've exceeded BibTeX's file name size " ) ; tputi ( cnull , 100 ) ; ---cut here---