|
|
1.1 ! root 1: ### ! 2: ### acm reference formatting style ! 3: ### ! 4: ! 5: BEGIN { ! 6: PASS="%TWOPASS"; # only one pass thru document ! 7: sortflag = 1; # reference_placement bib is sortedone ! 8: STYLE = "acm"; ! 9: SKEY = "atd"; ! 10: } ! 11: ! 12: ! 13: ! 14: ####################################################### ! 15: # ! 16: # Functions required by general awk script ! 17: # ! 18: ####################################################### ! 19: ! 20: ! 21: ## ! 22: ## Set author and editor fields ! 23: ## for reference list ! 24: ## for citation ! 25: ## for possible sorting ! 26: ## ! 27: ! 28: func setauthor(b,a) { ! 29: ! 30: Afull[b,a] = LastFM(); ! 31: Asort[b] = Asort[b] Afull[b,a] " "; ! 32: } ! 33: ! 34: func seteditor(b,a) { ! 35: E[b,a] = FMLast(); ! 36: Efull[b,a] = LastFM(); ! 37: Esort[b] = Esort[b] Efull[b,a] " "; ! 38: } ! 39: ! 40: ! 41: ## ! 42: ## citations ! 43: ## print a citation list ! 44: ## (Last, year; Last, year...) ! 45: ## ! 46: func citations(lastpunc) { ! 47: seq = "no"; ! 48: punc = "\n"; ! 49: if(lastpunc == "\"" || lastpunc == "'") { ! 50: punc = lastpunc " "; ! 51: lastpunc = "\\ "; ! 52: } ! 53: if(lastpunc == "(") { ! 54: punc = lastpunc; ! 55: lastpunc = ""; ! 56: } ! 57: for(i=1; i<=cites; i++) { ! 58: cn = bibptr[i] ! 59: seq = sequence(i,cites); ! 60: if (seq == "in") continue; ! 61: if (seq == "end") { ! 62: punc = "-"; ! 63: seq = "no"; ! 64: } ! 65: printf "%s[", punc; ! 66: if (pre_text[cn]) printf "%s ", pre_text[cn]; ! 67: printf "%s", makemark(i); ! 68: if(post_text[cn]) { ! 69: if (is_punc(substr(post_text[cn],1,1)) == 0) print ""; ! 70: printf "%s", post_text[cn]; ! 71: } ! 72: printf "]"; ! 73: punc = ", "; ! 74: } ! 75: printf lastpunc; ! 76: } ! 77: ! 78: func is_punc(p) ! 79: { ! 80: if(p == ",") return 1; ! 81: if(p == ".") return 1; ! 82: if(p == ";") return 1; ! 83: return 0; ! 84: } ! 85: ! 86: ! 87: ## ! 88: ## makemark ! 89: ## return citation mark: identical citations have the same number ! 90: ## ! 91: func makemark(m) { ! 92: return(inverse[uniqno[bibptr[m]]]); ! 93: } ! 94: ! 95: ! 96: ! 97: ## ! 98: ## bibindex ! 99: ## print citation mark for the bibliography; ! 100: ## return an index for accessing rest of citation ! 101: ## ! 102: func bibindex(i) { ! 103: print ".in \\w'999.\\ 'u" ! 104: printf ".sp .5\n.ti -\\w'%s.\\ 'u\n",i; ! 105: printf "%s.\\ ", i ; ! 106: if(sortflag) return sortorder[i]; ! 107: else return i; ! 108: } ! 109: ! 110: ! 111: ! 112: ############################################# ! 113: # ! 114: # Reference types ! 115: # ! 116: ############################################ ! 117: ! 118: ! 119: func book(b) { ! 120: # authorlist ! 121: if(authors[b]) { ! 122: printfull(b); ! 123: printf "\n"; ! 124: } ! 125: # italic title. ! 126: if(title[b]) ! 127: printf "\\f2\\&%s\\f1\\&.\n", title[b]; ! 128: # Vol. #. ! 129: if (volstr[b]) ! 130: printf "%s.\n", volstr[b] ; ! 131: else if (volume[b]) ! 132: printf "Vol. %s.\n", volume[b] ; ! 133: # publisher, location ! 134: printf "%s", issuer[b] ; ! 135: punc = ",\n"; ! 136: if (city[b]) printf ", %s", city[b] ; ! 137: # date ! 138: printf punc date[b] ; ! 139: } ! 140: ! 141: func editedbook(b) { ! 142: ! 143: # authorlist ! 144: if(authors[b]) { ! 145: printfull(b); ! 146: if(authors[b] <2) ! 147: printf ", Ed.\n"; ! 148: else ! 149: printf ", Eds.\n"; ! 150: } ! 151: # italic title. ! 152: if(title[b]) ! 153: printf "\\f2\\&%s\\f1\\&.\n", title[b]; ! 154: # Vol. #. ! 155: if (volstr[b]) ! 156: printf "%s.\n", volstr[b] ; ! 157: else if (volume[b]) ! 158: printf "Vol. %s.\n", volume[b] ; ! 159: # publisher, location ! 160: printf "%s", issuer[b] ; ! 161: if (city[b]) printf ", %s", city[b] ; ! 162: # date ! 163: printf ",\n%s", date[b] ; ! 164: } ! 165: ! 166: ! 167: ! 168: func incollection(b) { ! 169: ! 170: # Authorlist ! 171: if(authors[b]) { ! 172: printfull(b); ! 173: printf "\n"; ! 174: } ! 175: # Title. ! 176: if(title[b]) ! 177: printf "%s.\n", title[b] ; ! 178: # in italics booktitle, ! 179: printf "In \\f2\\&%s\\f1\\&,\n", booktitle[b]; ! 180: # Vol. #, ! 181: if (volstr[b]) ! 182: printf "%s,\n", volstr[b] ; ! 183: else if (volume[b]) ! 184: printf "Vol. %s,\n", volume[b] ; ! 185: # editorlist Ed. ! 186: if (editors[b]) { ! 187: editorlist(b); ! 188: if (editors[b] == 1) printf ", Ed.\n" ! 189: else if (editors[b] > 1) printf ", Eds.\n" ! 190: } ! 191: # publisher, location ! 192: printf "%s", issuer[b] ; ! 193: if (city[b]) printf ", %s", city[b] ; ! 194: # date, ! 195: printf ",\n%s", date[b] ; ! 196: # pages, ! 197: if ( pages[b]) { ! 198: if ( pages[b] ~ /[,-]/ ) ! 199: printf ",\npp. %s", pages[b]; ! 200: else printf ",\np. %s", pages[b]; ! 201: } ! 202: } ! 203: ! 204: func thesis(b) { ! 205: ! 206: # authorlist ! 207: if(authors[b]) { ! 208: printfull(b); ! 209: printf "\n"; ! 210: } ! 211: # italic title. ! 212: if(title[b]) ! 213: printf "%s.\n", title[b]; ! 214: # thesis, publisher, ! 215: if(reftype[b] == "phdthesis") ! 216: printf "PhD Thesis, %s", issuer[b]; ! 217: else if(reftype[b] == "mastersthesis") ! 218: printf "Master's Thesis, %s", issuer[b]; ! 219: ! 220: # date ! 221: printf ",\n%s", date[b] ; ! 222: } ! 223: ! 224: ! 225: ! 226: func review(b) { ! 227: article(b); ! 228: } ! 229: ! 230: func article(b) { ! 231: ! 232: # authorlist ! 233: if(authors[b]) { ! 234: printfull(b); ! 235: printf "\n"; ! 236: } ! 237: # title. ! 238: if(title[b]) ! 239: printf "%s.\n", title[b] ; ! 240: # review ! 241: if(booktitle[b]) { ! 242: printf "Review of \\f2\\&%s\\f1\\&", booktitle[b]; ! 243: if(editors[b]) { ! 244: printf " by " ! 245: editorlist(b); ! 246: } ! 247: if (issuer[b]) { ! 248: printf " %s", issuer[b]; ! 249: } ! 250: printf ".\n"; ! 251: } ! 252: # italics journal ! 253: printf "\\f2\\&%s\\f1\\&", journal[b]; ! 254: # italics volume, ! 255: if (volstr[b]) ! 256: printf " \\f2\\&%s\\f1\\&", volstr[b] ; ! 257: else if (volume[b]) ! 258: printf " \\f2\\&%s\\f1\\&", volume[b] ; ! 259: # number ! 260: if(numstr[b]) ! 261: printf ", %s", numstr[b]; ! 262: else if (number[b]) ! 263: printf ", %s", number[b] ; ! 264: # part ! 265: if(partstr[b]) ! 266: printf ", %s", partstr[b]; ! 267: else if (part[b]) ! 268: printf ", Pt. %s", part[b] ; ! 269: # date ! 270: printf " (%s)", date[b] ; ! 271: # pages, ! 272: if ( pages[b]) printf ", %s", pages[b]; ! 273: } ! 274: ! 275: ! 276: ! 277: ! 278: func inproceedings(b) { ! 279: # authorlist ! 280: if(authors[b]) { ! 281: printfull(b); ! 282: printf "\n"; ! 283: } ! 284: # Title. ! 285: if(title[b]) ! 286: printf "%s.\n", title[b] ; ! 287: # italics Journal, ! 288: printf "In \\f2\\&%s\\f1\\&", journal[b]; ! 289: # volume, ! 290: if (volstr[b]) ! 291: printf ", %s", volstr[b] ; ! 292: else if (volume[b]) ! 293: printf ", Vol. %s", volume[b] ; ! 294: if(numstr[b]) ! 295: printf ", %s", numstr[b]; ! 296: else if (number[b]) ! 297: printf ", No. %s", number[b] ; ! 298: if(partstr[b]) ! 299: printf ", %s", partstr[b]; ! 300: else if (part[b]) ! 301: printf ", Pt. %s", part[b] ; ! 302: # editorlist Ed. ! 303: if(editors[b]) { ! 304: printf ",\n"; ! 305: editorlist(b); ! 306: if (editors[b] == 1) printf ", Ed." ! 307: else if (editors[b] > 1) printf ", Eds." ! 308: } ! 309: # organization, ! 310: if(issuer[b]) ! 311: printf ", %s", issuer[b]; ! 312: # location, ! 313: if(city[b]) ! 314: printf ", %s", city[b]; ! 315: # date, ! 316: printf ", %s", date[b]; ! 317: # pages, ! 318: if ( pages[b]) { ! 319: if ( pages[b] ~ /[,-]/ ) ! 320: printf ", pp. %s", pages[b]; ! 321: else printf ", p. %s", pages[b] ; ! 322: } ! 323: } ! 324: ! 325: func proceedings(b) { ! 326: punc = ""; ! 327: # authorlist ! 328: if(authors[b] >0) { ! 329: authorlist(b); ! 330: punc = "\n"; ! 331: } ! 332: ! 333: # editorlist Ed. ! 334: else if(editors[b] > 0) { ! 335: printf punc; ! 336: editorlist(b); ! 337: if (editors[b] == 1) printf ", Ed." ! 338: else if (editors[b] > 1) printf ", Eds." ! 339: punc = "\n"; ! 340: } ! 341: # publisher. ! 342: else if(issuer[b]) { ! 343: printf "%s%s", punc, issuer[b]; ! 344: punc = ".\n"; ! 345: } ! 346: # italics(title), ! 347: if(title[b]) { ! 348: printf "%s\\f2\\&%s\\f1\\&", punc,title[b]; ! 349: punc = ".\n"; ! 350: if(substr(title[b],length(title[b]),1) == ".") ! 351: punc = "\n"; ! 352: ! 353: # volume, number, part. ! 354: if (volstr[b]) ! 355: printf ", %s", volstr[b] ; ! 356: else if (volume[b]) ! 357: printf ", Vol. %s", volume[b] ; ! 358: if(numstr[b]) ! 359: printf ", %s", numstr[b]; ! 360: else if (number[b]) ! 361: printf ", No. %s", number[b] ; ! 362: if(partstr[b]) ! 363: printf ", %s", partstr[b]; ! 364: else if (part[b]) ! 365: printf ", Pt. %s", part[b] ; ! 366: } ! 367: # publisher, ! 368: if(issuer[b]) ! 369: if(authors[b] || editors[b]) { ! 370: printf "%s%s", punc, issuer[b]; ! 371: punc = ",\n"; ! 372: } ! 373: # location, ! 374: if (city[b]) { ! 375: printf "%s%s", punc, city[b] ; ! 376: punc = ",\n"; ! 377: } ! 378: # date ! 379: if (date[b]) ! 380: printf "%s%s", punc, date[b]; ! 381: } ! 382: ! 383: func techreport(b) { ! 384: ! 385: # authorlist ! 386: if(authors[b]) { ! 387: printfull(b); ! 388: printf "\n"; ! 389: } ! 390: # title. ! 391: if(title[b]) ! 392: printf "%s.\n", title[b]; ! 393: # report number, ! 394: printf report[b] ! 395: # publisher, ! 396: if (issuer[b]) printf ",\n%s", issuer[b] ; ! 397: # date ! 398: printf ",\n%s", date[b] ; ! 399: } ! 400: ! 401: func tm(b) { ! 402: ! 403: # authorlist ! 404: if(authors[b]) { ! 405: printfull(b); ! 406: printf "\n"; ! 407: } ! 408: # title. ! 409: if(title[b]) ! 410: printf "%s.\n", title[b]; ! 411: # report number, ! 412: if(rp) ! 413: printf "AT&T Bell Laboratories internal memorandum"; ! 414: else ! 415: printf tmno[b] ! 416: # date ! 417: printf ",\n%s", date[b] ; ! 418: } ! 419: ! 420: ! 421: func manual(b) { ! 422: punc = ""; ! 423: # authorlist ! 424: if(authors[b] >0) { ! 425: printfull(b); ! 426: punc = "\n"; ! 427: } ! 428: # editorlist Ed. ! 429: else if(editors[b]) { ! 430: printf punc; ! 431: printedfull(b); ! 432: if (editors[b] == 1) printf ", Ed." ! 433: else if (editors[b] > 1) printf ", Eds." ! 434: punc = "\n"; ! 435: } ! 436: # publisher ! 437: else if(issuer[b]) { ! 438: printf "%s%s", punc, issuer[b]; ! 439: punc = ".\n"; ! 440: } ! 441: # title, ! 442: if(title[b]) { ! 443: printf "%s\\f2\\&%s\\f1\\&" ,punc, title[b]; ! 444: punc = ".\n"; ! 445: # Vol. volume, ! 446: if (volstr[b]) ! 447: printf ", %s", volstr[b] ; ! 448: else if (volume[b]) ! 449: printf ", Vol. %s", volume[b] ; ! 450: } ! 451: # publisher ! 452: if(issuer[b]) { ! 453: if(authors[b] || editors[b]) { ! 454: printf "%s%s", punc, issuer[b]; ! 455: punc = ", "; ! 456: } ! 457: } ! 458: # location ! 459: if (city[b]) { ! 460: printf "%s%s", punc, city[b] ; ! 461: punc = ", "; ! 462: } ! 463: # date ! 464: printf "%s%s", punc, date[b]; ! 465: } ! 466: ! 467: func pamphlet(b) { ! 468: default(b); ! 469: } ! 470: ! 471: func default(b) { ! 472: punc = ""; ! 473: # authorlist ! 474: if(authors[b] >0) { ! 475: printfull(b); ! 476: punc = "\n"; ! 477: } ! 478: ! 479: # publisher. ! 480: else if(issuer[b]) { ! 481: printf "%s%s", punc, issuer[b]; ! 482: punc = ".\n"; ! 483: } ! 484: # title, ! 485: if (title[b]) { ! 486: printf "%s%s" ,punc, title[b]; ! 487: punc = ".\n"; ! 488: } ! 489: # volume, ! 490: if(volstr[b]) { ! 491: printf ", %s", volstr[b]; ! 492: } ! 493: else if (volume[b]) { ! 494: printf ", Vol. %s", punc, volume[b] ; ! 495: } ! 496: # publisher, ! 497: if(issuer[b]) { ! 498: printf "%s%s", punc, issuer[b]; ! 499: punc = ", "; ! 500: } ! 501: # location, ! 502: if (city[b]) { ! 503: printf "%s%s", punc, city[b] ; ! 504: punc = ", "; ! 505: } ! 506: # date, ! 507: if (date[b]) { ! 508: printf "%s%s", punc, date[b]; ! 509: punc = ", "; ! 510: } ! 511: # pages ! 512: if (pages[b]) { ! 513: if ( pages[b] ~ /[,-]/ ) ! 514: printf "%spp. %s", punc, pages[b]; ! 515: else ! 516: printf "%sp. %s", punc, pages[b]; ! 517: } ! 518: } ! 519: ! 520: ! 521: ! 522: ! 523: ! 524: ! 525: # Author, First ! 526: # Author, First and Second Author ! 527: # Author, First, Second Author, and Remaining Authors ! 528: ! 529: func printfull(b) { ! 530: if ( authors[b] == 0 ) ; ! 531: else if ( authors[b] == 1 ) { ! 532: printf Afull[b,1] ; ! 533: if(aetal[b]) printf ", et al."; ! 534: } ! 535: else if ( authors[b] == 2 ) printf Afull[b,1] " and " Afull[b,2]; ! 536: else { ! 537: for ( j = 1; j < authors[b]; j++ ) printf Afull[b,j] ", "; ! 538: printf "and " Afull[b,authors[b]]; ! 539: } ! 540: } ! 541: func printedfull(b) { ! 542: if ( editors[b] == 0 ) ; ! 543: else if ( editors[b] == 1 ) { ! 544: printf Efull[b,1] ; ! 545: if(eetal[b]) printf ", et al."; ! 546: } ! 547: else if ( editors[b] == 2 ) printf Efull[b,1] " and " Efull[b,2]; ! 548: else { ! 549: for ( j = 1; j < editors[b]; j++ ) printf Efull[b,j] ", "; ! 550: printf "and " Efull[b,editors[b]]; ! 551: } ! 552: } ! 553: ! 554: func editorlist(b) { ! 555: if ( editors[b] == 0 ) ; ! 556: else if ( editors[b] == 1 ) printf E[b,1] ; ! 557: else if ( editors[b] == 2 ) printf E[b,1] " and " E[b,2]; ! 558: else { ! 559: for ( j = 1; j < editors[b]; j++ ) printf E[b,j] ", "; ! 560: printf "and " E[b,editors[b]]; ! 561: } ! 562: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.