|
|
1.1 root 1: ###
2: ### lsa reference formatting style
3: ###
4:
5: BEGIN {
6: PASS=""; # only one pass thru document
7: sortflag = 1; # reference_placement bib is sortedone
8: STYLE = "lsa";
9: SKEY = "adt";
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: func setauthor(b,a) {
28: Afull[b,a] = FirstMiddleLast();
29: Arfull[b,a] = LastFirstMiddle();
30: Alast[b,a] = Last;
31: Asort[b] = Asort[b] Arfull[b,a] " ";
32: }
33:
34: func seteditor(b,a) {
35: Efull[b,a] = FirstMiddleLast();;
36: Erfull[b,a] = LastFirstMiddle();
37: Elast[b,a] = Last;
38: Esort[b] = Esort[b] Erfull[b,a] " ";
39: }
40:
41:
42:
43:
44: ##
45: ## citations
46: ## print a citation list
47: ## (Last year{, year}, Last year...)
48: ##
49: func citations(lastpunc) {
50: sep = "\n(";
51: if(lastpunc == "\"" || lastpunc == "'") {
52: sep = lastpunc " (";
53: lastpunc = "\\ ";
54: }
55: ptext = 0;
56: ctext = 0;
57: for(i=1; i<=cites; i++) {
58: cn = bibptr[i];
59: b = uniqno[cn];
60: if (pre_text[cn]) ctext = 1;
61: if ((ctext == 1) || (ptext == 1) || new_author(i)) {
62: printf sep;
63: if (pre_text[cn]) {
64: printf "%s", pre_text[cn];
65: if((no_author[cn] == 0) || (no_date[cn] == 0))
66: printf " ";
67: }
68: if (no_author[cn] == 0) {
69: if(authors[b])
70: printlast(b);
71: else if (editors[b])
72: printlasted(b);
73: else if (issuer[b])
74: printf issuer[b];
75: else
76: printf title[b];
77: punc = " ";
78: }
79: else punc = "";
80: }
81: else {
82: punc = ", ";
83: }
84: if(no_date[cn] == 0) {
85: if(year[b] ~ /^[0-9][0-9][0-9][0-9]$/)
86: printf "%s%s", punc, year[b];
87: else {
88: if (date[b] != 0) printf "%s%s", punc, date[b];
89: }
90: }
91: if (post_text[cn]) {
92: if (is_punc(substr(post_text[cn],1,1)) == 0) print "";
93: printf "%s", post_text[cn];
94: }
95: sep = ",\n";
96: ptext = ctext;
97: ctext = 0;
98: }
99: printf ")";
100: printf lastpunc;
101: }
102:
103: func is_punc(p)
104: {
105: if(p == ",") return 1;
106: if(p == ".") return 1;
107: if(p == ";") return 1;
108: return 0;
109: }
110:
111: ##
112: ## new_author
113: ## returns 1 if current author is difference from
114: ## previous author in the citation list
115: ##
116: func new_author(c) {
117: if (c == 1) return 1;
118: b1 = uniqno[bibptr[c-1]];
119: b = uniqno[bibptr[c]];
120: if(authors[b] == 0) return 1;
121: if(authors[b1] != authors[b]) return 1;
122: for(k = 1; k <= authors[b]; k++) {
123: if (Alast[b1,k] != Alast[b,k]) return 1;
124: }
125: return 0;
126: }
127:
128:
129: ##
130: ## print author last name for citation
131: ## First
132: ## First and Second
133: ## First, Second,..., & Last
134: func printlast(c) {
135: a = authors[c]
136: if ( a == 1 ) printf "%s", Alast[c,1];
137: else if ( a == 2 ) printf "%s & %s", Alast[c,1], Alast[c,2];
138: else if (a > 5) printf "%s et al.", Alast[c,1];
139: else {
140: for ( j = 1; j < a; j++ ) printf Alast[c,j] ", ";
141: printf "& %s", Alast[c,a];
142: }
143: }
144:
145: ##
146:
147: ## print editor last name for citation
148: ## First
149: ## First and Second
150: ## First, Second,..., & Last
151: func printlasted(c) {
152: a = editors[c]
153: if ( a == 1 ) printf "%s", Elast[c,1];
154: else if ( a == 2 ) printf "%s & %s", Elast[c,1], Elast[c,2];
155: else if (a > 5) printf "%s et al.", Elast[c,1] ;
156: else {
157: for ( j = 1; j < a; j++ ) printf "%s, ", Elast[c,j];
158: printf "& %s", Elast[c,a];
159: }
160: }
161:
162:
163: ##
164: ## bibindex
165: ## set up indentation for bibliography;
166: ## return an index for accessing rest of citation
167: ## do misc stuff specific to this style
168: ##
169: func bibindex(i) {
170: printf ".sp .3\n.ti -.3i\n";
171: if (sortflag)
172: return sortorder[i];
173: else return i;
174: }
175:
176:
177:
178: #############################################
179: #
180: # Reference types
181: #
182: ############################################
183:
184:
185: func book(b) {
186: # authorlist.
187: if(authors[b]) {
188: if(printfull(b) != ".")
189: printf ".";
190: printf "\n";
191: }
192: # date.
193: printf "%s", date[b] ;
194: punc = ".\n";
195: # title
196: if(title[b]) {
197: printf "%s%s", punc, title[b];
198: # Vol #.
199: if(volstr[b])
200: printf ", %s", volstr[b];
201: else if(volume[b])
202: printf ", Vol. %s", volume[b];
203: }
204: # location: publisher.
205: if (city[b]) {
206: printf "%s%s", punc, city[b] ;
207: punc = ": ";
208: }
209: printf "%s%s", punc, issuer[b] ;
210: }
211:
212:
213: func editedbook(b) {
214: # authorlist.
215: if(authors[b]) {
216: if(printfull(b) != ".")
217: printf ".";
218: printf "\n";
219: }
220: # date.
221: printf "%s", date[b] ;
222: if(authors[b] <2)
223: printf " (ed.)\n";
224: else
225: printf " (eds.)\n";
226: # italic(title)
227: if(title[b]) {
228: printf title[b];
229: punc = ".\n";
230: }
231: # (Vol #).
232: if(volstr[b])
233: printf ", %s", volstr[b];
234: else if(volume[b])
235: printf ", Vol. %s", volume[b];
236: # location: publisher.
237: if (city[b]) {
238: printf "%s%s", punc, city[b] ;
239: punc = ": ";
240: }
241: printf "%s%s", punc, issuer[b] ;
242: }
243:
244:
245: func thesis(b) {
246:
247: # authorlist.
248: if(authors[b]) {
249: if(printfull(b) != ".")
250: printf ".";
251: printf "\n";
252: }
253: # date.
254: printf "%s.\n", date[b] ;
255: # title.
256: if(title[b]) {
257: printf "%s.\n", title[b];
258: }
259: # city
260: if(address[b]) {
261: printf "%s: ", address[b];
262: }
263: # thesis, school.
264: if(reftype[b] == "phdthesis")
265: printf "%s dissertation", issuer[b];
266: else if(reftype[b] == "mastersthesis")
267: printf "%s master's thesis", issuer[b];
268: }
269:
270: func review(b) {
271: article(b);
272: }
273:
274:
275: func article(b) {
276:
277: # authorlist.
278: if(authors[b]) {
279: if(printfull(b) != ".")
280: printf ".";
281: printf "\n";
282: }
283: # date.
284: printf "%s.\n", date[b] ;
285: # title.
286: if(title[b]) {
287: printf title[b] ".\n";
288: }
289: # [reviewed title.]
290: if(booktitle[b]) {
291: printf "[Review of %s", booktitle[b];
292: if(editors[b]) {
293: printf " by ";
294: editorlist(b);
295: if (issuer[b]) {
296: printf " %s", issuer[b];
297: }
298: }
299: printf "].\n";
300: }
301:
302: # italics journal,
303: printf "%s", journal[b];
304: punc = ", ";
305: # volume:number.pages
306: if (volstr[b]) {
307: printf ", %s", volstr[b];
308: if (numstr[b]) {
309: printf ", %s", numstr[b];
310: }
311: else if (number[b]) {
312: printf ", %s", number[b];
313: }
314: punc = ".";
315: }
316: else if (volume[b]) {
317: printf " %s", volume[b];
318: if (numstr[b]) {
319: printf ", %s", numstr[b];
320: }
321: else if (number[b]) {
322: printf ":%s",number[b];
323: }
324: punc = ".";
325: }
326: if ( pages[b] ) printf "%s%s", punc, pages[b];
327: }
328:
329: func inproceedings(b) {
330:
331: # authorlist.
332: if(authors[b]) {
333: if(printfull(b) != ".")
334: printf ".";
335: printf "\n";
336: }
337: # date.
338: printf "%s.\n", date[b] ;
339: # title.
340: if(title[b]) {
341: printf title[b] ".\n";
342: }
343:
344: # italics journal,
345: printf "%s", journal[b];
346: punc = ",\n";
347:
348: # ed. by editorlist,
349: if(editors[b]) {
350: printf ", ed. by "
351: editorlist(b);
352: }
353: punc = ".\n";
354: # pages.
355: if(pages[b]) {
356: printf ", %s", pages[b];
357: }
358: # location: publisher,
359: if (city[b]) {
360: printf "%s%s", punc, city[b] ;
361: punc = ": ";
362: }
363: if (issuer[b])
364: printf "%s%s", punc, issuer[b] ;
365: }
366:
367: func proceedings(b) {
368: punc = "";
369: # authorlist.
370: if(authors[b] >0) {
371: if(printfull(b) != ".")
372: printf ".";
373: printf "\n";
374: }
375: # editor
376: else if(editors[b]) {
377: printedfull(b);
378: if (editors[b] == 1) printf " (Ed.)"
379: else if (editors[b] > 1) printf " (Eds.)"
380: punc = ".\n";
381: }
382:
383: # publisher
384: else if(issuer[b]) {
385: printf "%s%s", punc, issuer[b];
386: punc = ".\n";
387: }
388: # date.
389: printf "%s%s.\n", punc, date[b] ;
390: # title
391: if (title[b]) {
392: printf "%s", title[b];
393: punc = ".\n";
394: if(substr(title[b],length(title[b]),1) == ".")
395: punc = "\n";
396: }
397: # volume:number
398: if (volstr[b]) {
399: printf ", %s", volstr[b];
400: if (numstr[b]) {
401: printf ", %s", numstr[b];
402: }
403: else if (number[b]) {
404: printf ", %s", number[b];
405: }
406: punc = ".";
407: }
408: else if (volume[b]) {
409: printf " %s", volume[b];
410: if (numstr[b]) {
411: printf ", %s", numstr[b];
412: }
413: else if (number[b]) {
414: printf ":%s",number[b];
415: }
416: punc = ".";
417: }
418: # location: publisher,
419: if (city[b]) {
420: printf "%s%s", punc, city[b] ;
421: punc = ": ";
422: }
423: printf "%s%s", punc, issuer[b] ;
424: }
425:
426:
427: func incollection(b) {
428:
429: # authorlist.
430: if(authors[b]) {
431: if(printfull(b) != ".")
432: printf ".";
433: printf "\n";
434: }
435: # date.
436: printf "%s.\n", date[b] ;
437: # title
438: if(title[b]) {
439: printf "%s.\n", title[b];
440: }
441: # booktitle,
442: printf "%s", booktitle[b];
443: # Vol #.
444: if(volstr[b])
445: printf ", %s", volstr[b];
446: else if(volume[b])
447: printf ", Vol. %s", volume[b];
448: # ed. by editorlist,
449: if(editors[b]) {
450: printf ", ed. by "
451: editorlist(b);
452: }
453: punc = ".\n";
454: # pages.
455: if(pages[b]) {
456: printf ", %s", pages[b];
457: }
458: # location: publisher,
459: if (city[b]) {
460: printf "%s%s", punc, city[b] ;
461: punc = ": ";
462: }
463: printf "%s%s", punc, issuer[b];
464: }
465:
466:
467:
468: func techreport(b) {
469:
470: # authorlist.
471: if(authors[b]) {
472: if(printfull(b) != ".")
473: printf ".";
474: printf "\n";
475: }
476: # date.
477: printf "%s.\n", date[b] ;
478: # title.
479: if(title[b])
480: printf "%s.\n", title[b];
481: # (report number).
482: printf "(%s).\n", report[b];
483:
484: # location: publisher.
485: if (city[b]) printf "%s: ", city[b] ;
486: printf issuer[b];
487: }
488:
489: func tm(b) {
490:
491: # authorlist.
492: if(authors[b]) {
493: if(printfull(b) != ".")
494: printf ".";
495: printf "\n";
496: }
497: # date.
498: printf "%s.\n", date[b] ;
499: # title.
500: if(title[b])
501: printf "%s.\n", title[b];
502: # (tm number).
503: if(rp)
504: printf "(AT&T Bell Laboratories internal memorandum)";
505: else
506: printf "(%s)", tmno[b]
507: }
508:
509: func manual(b) {
510: punc = "";
511: # authorlist.
512: if(authors[b] >0) {
513: if(printfull(b) != ".")
514: printf ".";
515: printf "\n";
516: }
517: # editor.
518: else if(editors[b]) {
519: if(printedfull(b) != ".")
520: printf ".";
521: printf "\n";
522: }
523:
524: # publisher
525: else if(issuer[b]) {
526: printf "%s%s", punc, issuer[b];
527: punc = ".\n";
528: }
529: # date.
530: printf "%s%s", punc, date[b] ;
531: if (editors[b] == 1) printf " (ed.)\n";
532: else if (editors[b] > 1) printf " (eds.)\n";
533: else printf ".\n";
534: # title
535: if(title[b]) {
536: printf "%s", title[b];
537: punc = ".\n";
538: }
539: # location: publisher.
540: if (city[b]) {
541: printf "%s%s", punc, city[b] ;
542: punc = ": ";
543: }
544: if(issuer[b]) {
545: if(editors[b] || authors[b]);
546: printf "%s%s", punc, issuer[b];
547: }
548: }
549:
550: func pamphlet(b)
551: {
552:
553: punc = "";
554: # authorlist.
555: if(authors[b] >0) {
556: if(printfull(b) != ".")
557: printf ".";
558: printf "\n";
559: }
560: # publisher.
561: else if(issuer[b]) {
562: printf issuer[b];
563: punc = ".\n";
564: }
565: # title.
566: else if(title[b]) {
567: printf title[b];
568: punc = ".\n"
569: }
570: # date.
571: if(date[b]) {
572: printf "%s%s", punc, date[b] ;
573: punc = ".\n";
574: }
575: # title
576: if(editors[b] || authors[b] || issuer[b]) {
577: if(title[b]) {
578: printf "%s%s", punc, title[b];
579: punc = ".\n"
580: }
581: }
582:
583: # Vol #.
584: if(volstr[b])
585: printf ", %s", volstr[b];
586: else if(volume[b])
587: printf ", Vol. %s", volume[b];
588: # location: publisher.
589: if (city[b]) {
590: printf "%s%s", punc, city[b] ;
591: punc = ": ";
592: }
593: if(issuer[b]) {
594: if(editors[b] || authors[b]);
595: printf "%s%s", punc, issuer[b];
596: }
597:
598: }
599:
600: func default(b) {
601: punc = "";
602: # authorlist.
603: if(authors[b]) {
604: if(printfull(b) != ".")
605: printf ".";
606: printf "\n";
607: }
608: # publisher.
609: else if(issuer[b]) {
610: printf issuer[b];
611: punc = ".\n";
612: }
613: # title.
614: else if(title[b]) {
615: printf title[b];
616: punc = ".\n"
617: }
618: # date.
619: if(date[b]) {
620: printf "%s%s", punc, date[b] ;
621: punc = ".\n";
622: }
623: # title
624: if(editors[b] || authors[b] || issuer[b] ) {
625: if(title[b]) {
626: printf "%s%s", punc, title[b];
627: punc = ".\n"
628: }
629: }
630: # Vol #,
631: if(volstr[b]) {
632: printf ", %s", volstr[b];
633: punc = ".\n";
634: }
635: else if(volume[b]) {
636: printf ", Vol. %s", volume[b];
637: punc = ".\n";
638: }
639: # pages.
640: if (pages[b]) {
641: printf ", %s", pages[b];
642: punc = ".\n";
643: }
644:
645: # location: publisher.
646: if (city[b]) {
647: printf "%s%s", punc, city[b] ;
648: punc = ": ";
649: }
650: if(issuer[b]) {
651: if(editors[b] || authors[b]);
652: printf "%s%s", punc, issuer[b];
653: }
654: }
655:
656: #
657: # return index of previous item
658: #
659:
660: func previous(q)
661: {
662: if (sortflag)
663: return sortorder[inverse[q]-1];
664: else
665: return q-1;
666: }
667:
668:
669:
670: # Author, First
671: # Author, First, and Second Author
672: # Author, First, Second Author, and Remaining Authors
673:
674: func printfull(b) {
675: longdash = "\\(em\\(em\\(em";
676: dash = 0;
677: prev = previous(b);
678: if ( authors[b] == 1 ) {
679: if(Arfull[b,1] == Arfull[prev,1]) {
680: printf longdash;
681: return "";
682: }
683: else printf Arfull[b,1] ;
684: if(aetal[b]) {
685: printf ", et al.";
686: return ".";
687: }
688: return substr(Arfull[b,1],length(Arfull[b,1]));
689: }
690: else if ( authors[b] == 2 ) {
691: if(Arfull[b,1] == Arfull[prev,1]) {
692: printf longdash;
693: dash = 1;
694: }
695: else printf Arfull[b,1];
696: printf ", and "
697: if(dash && (Afull[b,2] == Afull[prev,2]))
698: printf longdash;
699: else printf Afull[b,2];
700: }
701: else {
702: if(Arfull[b,1] == Arfull[prev,1]) {
703: printf longdash;
704: dash = 1;
705: }
706: else printf Arfull[b,1];
707: printf "; ";
708: for ( j = 2 ; j < authors[b]; j++ ) {
709: if(dash && (Afull[b,j] == Afull[prev,j]))
710: printf longdash;
711: else {
712: dash = 0;
713: printf Afull[b,j];
714: }
715: printf "; ";
716: }
717: printf "and "
718: j = authors[b];
719: if(dash && (Afull[b,j] == Afull[prev,j]))
720: printf longdash;
721: else printf Afull[b,j];
722: }
723: return "";
724: }
725:
726: func printedfull(b) {
727: longdash = "\\(em\\(em\\(em\\(em";
728: dash = 0;
729: prev = previous(b);
730: if ( editors[b] == 0 ) ;
731: else if ( editors[b] == 1 ) {
732: if(Erfull[b,1] == Erfull[prev,1]) {
733: printf longdash;
734: return "";
735: }
736: else printf Erfull[b,1] ;
737: if(aetal[b]) {
738: printf ", et al.";
739: return ".";
740: }
741: return substr(Erfull[b,1],length(Erfull[b,1]));
742: }
743: else if ( editors[b] == 2 ) {
744: if(Erfull[b,1] == Erfull[prev,1]) {
745: printf longdash;
746: dash = 1;
747: }
748: else printf Erfull[b,1];
749: printf ", and "
750: if(dash && (Efull[b,2] == Efull[prev,2]))
751: printf longdash;
752: else printf Efull[b,2];
753: }
754: else {
755: if(Erfull[b,1] == Erfull[prev,1]) {
756: printf longdash;
757: dash = 1;
758: }
759: else printf Erfull[b,1];
760: printf "; ";
761: for ( j = 2 ; j < editors[b]; j++ ) {
762: if(dash && (Efull[b,j] == Efull[prev,j]))
763: printf longdash;
764: else {
765: dash = 0;
766: printf Efull[b,j];
767: }
768: printf "; ";
769: }
770: printf "and "
771: j = editors[b];
772: if(dash && (Efull[b,j] == Efull[prev,j]))
773: printf longdash;
774: else printf Efull[b,j];
775: }
776: return "";
777: }
778:
779:
780:
781: func editorlist(b) {
782: if ( editors[b] == 0 ) ;
783: else if ( editors[b] == 1 ) printf "%s", Efull[b,1] ;
784: else if ( editors[b] == 2 ) printf "%s & %s", Efull[b,1], Efull[b,2];
785: else {
786: printf "%s et al.", Efull[b,1];
787: }
788: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.