1 /*-
2 * %sccs.include.proprietary.c%
3 */
4
5 #ifndef lint
6 static char sccsid[] = "@(#)annobib.c 4.2 (Berkeley) 04/18/91";
7 #endif /* not lint */
8
9 /*
10 * This program has been replaced by "refer -B" (bibliography mode),
11 * but is included here for backward compatiblity.
12 */
13
14 #include <stdio.h>
15
16 int noanno = 0; /* option to suppress .AP from %X field */
17
main(argc,argv)18 main(argc, argv) /* format (annotated) bibliography for n/troff */
19 int argc;
20 char *argv[];
21 {
22 FILE *fp, *fopen();
23
24 if (argv[1][0] == '-' && argv[1][1] == 'x')
25 {
26 noanno = 1;
27 argv++; argc--;
28 }
29 if (argc == 1)
30 {
31 annobib(stdin);
32 exit(0);
33 }
34 while (--argc > 0)
35 {
36 if ((fp = fopen(*++argv, "r")) == NULL)
37 {
38 perror(*argv);
39 exit(1);
40 }
41 annobib(fp);
42 fclose(fp);
43 }
44 exit(0);
45 }
46
annobib(fp)47 annobib(fp) /* prepare bibliography for refer bare mode */
48 FILE *fp;
49 {
50 char line[BUFSIZ];
51 int begun, ended;
52
53 begun = 0;
54 ended = 1;
55 while (fgets(line, BUFSIZ, fp))
56 {
57 if (line[0] == '%' && line[1] == 'X' && !noanno)
58 {
59 zap_x(line);
60 printf(".]\n.AP\n%s", line);
61 ended = 1;
62 begun = 0;
63 }
64 else if (line[0] == '%')
65 {
66 if (!begun)
67 {
68 puts(".[");
69 begun = 1;
70 ended = 0;
71 }
72 fputs(line, stdout);
73 }
74 else if (line[0] == '\n')
75 {
76 if (!ended)
77 {
78 puts(".]");
79 ended = 1;
80 begun = 0;
81 }
82 }
83 else
84 fputs(line, stdout);
85 }
86 if (!ended)
87 puts(".]");
88 }
89
zap_x(line)90 zap_x(line) /* take %X annotation flag out of line */
91 char line[];
92 {
93 register int i, j;
94
95 for (i = 3, j = 0; line[i] != NULL; i++, j++)
96 line[j] = line[i];
97 line[j] = NULL;
98 return;
99 }
100