|
|
1.1 ! root 1: # include "refer..c" ! 2: putref (n, tvec) ! 3: char *tvec[]; ! 4: { ! 5: char *s, *tx; ! 6: char buf1[LLINE], buf2[50]; ! 7: int nauth = 0, i, lastype = 0, cch, macro = 0, la; ! 8: int lauth = 0, ltitle = 0, lother = 0; ! 9: ! 10: fprintf(fo, ".]-%c", sep); ! 11: # define dsde (macro? "de" : "ds") ! 12: # define ifnl (macro? sep : ' ') ! 13: for (i=0; i<n; i++) ! 14: { ! 15: s = tvec[i]; ! 16: if (*s==0) continue; ! 17: if (control(s[0]) ) ! 18: { ! 19: if (lastype && macro) ! 20: fprintf(fo, "..%c", sep); ! 21: if (control(s[1])) ! 22: { ! 23: cch = s[2]; ! 24: tx = s+3; ! 25: macro=1; ! 26: } ! 27: else ! 28: { ! 29: cch = s[1]; ! 30: tx = s+2; ! 31: macro=0; ! 32: } ! 33: } ! 34: else ! 35: { ! 36: cch = lastype; ! 37: tx=s; ! 38: } ! 39: # if D1 ! 40: fprintf(stderr, "smallcaps %s cch %c\n",smallcaps, cch); ! 41: # endif ! 42: if (mindex (smallcaps, cch)) ! 43: tx = caps(tx, buf1); ! 44: # if D1 ! 45: fprintf(stderr, " s %o tx %o %s\n",s,tx,tx); ! 46: # endif ! 47: if (!control(s[0])) /* append to previous item */ ! 48: { ! 49: if (lastype!=0) ! 50: { ! 51: if (macro) ! 52: fprintf(fo, "%s%c", tx, sep); ! 53: else ! 54: fprintf(fo, ".as [%c \" %s%c",lastype,tx,sep); ! 55: if (lastype == 'T') ! 56: ltitle = (mindex(".;,?", last(tx))!=0); ! 57: if (lastype == 'A') ! 58: lauth = last(tx) == '.'; ! 59: } ! 60: continue; ! 61: } ! 62: if (mindex("XYZ[]", cch)) /* skip these */ ! 63: { ! 64: lastype=0; ! 65: continue; ! 66: } ! 67: else ! 68: if (cch == 'A') ! 69: { ! 70: if (nauth < authrev) ! 71: tx = revauth(tx, buf2); ! 72: if (nauth++ ==0) ! 73: if (macro) ! 74: fprintf(fo, ".de [%c%c%s%c",cch,sep,tx,sep); ! 75: else ! 76: fprintf(fo, ".ds [%c%s%c", cch,tx,sep); ! 77: else ! 78: { ! 79: la = (tvec[i+1][1]!='A'); ! 80: fprintf(fo, ".as [A \""); ! 81: if (la == 0 || nauth != 2) ! 82: fprintf(fo, ","); ! 83: if (la) ! 84: fprintf(fo,"%s", ! 85: mindex(smallcaps, 'A')? " \\s-2AND\\s+2" : " and"); ! 86: fprintf(fo, "%s%c", tx, sep); ! 87: } ! 88: lauth = last(tx)=='.'; ! 89: } ! 90: else ! 91: if (macro) ! 92: fprintf(fo, ".de [%c%c%s%c",cch,sep, tx, sep); ! 93: else ! 94: fprintf(fo, ".ds [%c%s%c",cch,tx, sep); ! 95: if (cch=='P') ! 96: fprintf(fo, ".nr [P %d%c", mindex(s, '-')!=0, sep); ! 97: lastype = cch; ! 98: if (cch == 'T') ! 99: ltitle = (mindex(".;,?", last(tx)) != 0); ! 100: if (cch == 'O') ! 101: lother = (mindex(".;,?", last(tx)) != 0); ! 102: } ! 103: if (lastype && macro) ! 104: fprintf(fo, "..%c", sep); ! 105: fprintf(fo, ".nr [T %d%c", ltitle, sep); ! 106: fprintf(fo, ".nr [A %d%c", lauth, sep); ! 107: fprintf(fo, ".nr [O %d%c", lother, sep); ! 108: fprintf (fo, ".][ %s%c", class(n, tvec), '\n'); ! 109: } ! 110: tabs (sv, line) ! 111: char *sv[], *line; ! 112: { ! 113: char *p; ! 114: int n = 0; ! 115: sv[n++] = line; ! 116: for( p= line; *p; p++) ! 117: { ! 118: if (*p == '\n') ! 119: { ! 120: *p=0; ! 121: sv[n++] = p+1; ! 122: } ! 123: } ! 124: return(n-1); ! 125: } ! 126: char * ! 127: class (nt, tv) ! 128: char *tv[]; ! 129: { ! 130: if (hastype (nt, tv, 'J')) ! 131: return("1 journal-article"); ! 132: if (hastype (nt, tv, 'B')) ! 133: return("3 article-in-book"); ! 134: if (hastype (nt, tv, 'R')) ! 135: return ("4 tech-report"); ! 136: if (hastype (nt, tv, 'G')) ! 137: return ("4 tech-report"); ! 138: if (hastype (nt, tv, 'I')) ! 139: return("2 book"); ! 140: if (hastype (nt, tv,'M')) ! 141: return ("5 bell-tm"); ! 142: return("0 other"); ! 143: } ! 144: hastype (nt, tv, c) ! 145: char *tv[]; ! 146: { ! 147: int i; ! 148: for(i=0; i<nt; i++) ! 149: if ( control(tv[i][0]) && tv[i][1]==c ) ! 150: return(1); ! 151: return(0); ! 152: } ! 153: char * ! 154: caps(a, b) ! 155: char *a, *b; ! 156: { ! 157: char *p; ! 158: int c, alph, this; ! 159: p=b; ! 160: alph = 0; ! 161: while (c = *a++) ! 162: { ! 163: this = isalpha(c); ! 164: if (this && alph==1) ! 165: { ! 166: *b++ = '\\'; ! 167: *b++ = 's'; ! 168: *b++ = '-'; ! 169: *b++ = '2'; ! 170: } ! 171: if (!this && alph>1) ! 172: { ! 173: *b++ = '\\'; ! 174: *b++ = 's'; ! 175: *b++ = '+'; ! 176: *b++ = '2'; ! 177: } ! 178: if (this) ! 179: c &= (~040); ! 180: *b++ = c; ! 181: alph = this ? alph+1 : 0; ! 182: } ! 183: if (alph>1) ! 184: { ! 185: *b++ = '\\'; ! 186: *b++ = 's'; ! 187: *b++ = '+'; ! 188: *b++ = '2'; ! 189: } ! 190: *b=0; ! 191: return (p); ! 192: } ! 193: char * ! 194: revauth(s, b) ! 195: char *s, *b; ! 196: { ! 197: char *init, *name, *jr, *p, *bcop; ! 198: bcop = b; ! 199: init=name=s; ! 200: while (*name)name++; ! 201: jr=name; ! 202: while (name>init && *name!= ' ') ! 203: name--; ! 204: if (name[-1] == ',' || name[-1]== '(' ) ! 205: { ! 206: jr = --name; ! 207: while (name>init && *name != ' ') ! 208: name--; ! 209: } ! 210: p=name; ! 211: while (p<jr) ! 212: *b++ = *p++; ! 213: *b++ = ','; ! 214: while (init<name) ! 215: *b++ = *init++; ! 216: if (*jr)jr++; ! 217: while(*jr) ! 218: *b++ = *jr++; ! 219: *b++ = 0; ! 220: return(bcop); ! 221: } ! 222: last(s) ! 223: char *s; ! 224: { ! 225: while (*s) s++; ! 226: return(*--s); ! 227: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.