8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / tbl / t1.c
blobb2f2b585cbc834a374de17d1d6823fa228a6d2ab
1 /*
2 * Copyright 1998 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
4 */
6 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
7 /* All Rights Reserved */
9 /*
10 * Copyright (c) 1980 Regents of the University of California.
11 * All rights reserved. The Berkeley software License Agreement
12 * specifies the terms and conditions for redistribution.
15 #pragma ident "%Z%%M% %I% %E% SMI"
17 /* t1.c: main control and input switching */
19 #include <locale.h>
20 # include "t..c"
21 #include <signal.h>
22 #include <stdlib.h>
24 # ifdef gcos
25 /* required by GCOS because file is passed to "tbl" by troff preprocessor */
26 # define _f1 _f
27 extern FILE *_f[];
28 # endif
30 # ifdef unix
31 # define MACROS "/usr/doctools/tmac/tmac.s"
32 # define MACROSS "/usr/share/lib/tmac/s"
33 # define PYMACS "/usr/doctools/tmac/tmac.m"
34 # define PYMACSS "/usr/share/lib/tmac/m"
35 # define MEMACSS "/usr/share/lib/tmac/e"
36 # endif
38 # ifdef gcos
39 # define MACROS "cc/troff/smac"
40 # define PYMACS "cc/troff/mmac"
41 # endif
43 # define ever (;;)
45 void setinp(int, char **);
47 int
48 main(int argc, char **argv)
50 # ifdef unix
51 void badsig();
52 # endif
53 (void) setlocale(LC_ALL, "");
54 #if !defined(TEXT_DOMAIN)
55 #define TEXT_DOMAIN "SYS_TEST"
56 #endif
57 (void) textdomain(TEXT_DOMAIN);
58 # ifdef unix
59 signal(SIGPIPE, badsig);
60 # endif
61 # ifdef gcos
62 if(!intss()) tabout = fopen("qq", "w"); /* default media code is type 5 */
63 # endif
64 exit(tbl(argc,argv));
67 int
68 tbl(int argc, char **argv)
70 char line[BIGBUF];
71 /* required by GCOS because "stdout" is set by troff preprocessor */
72 tabin=stdin; tabout=stdout;
73 setinp(argc,argv);
74 while (gets1(line, sizeof line))
76 fprintf(tabout, "%s\n",line);
77 if (prefix(".TS", line))
78 tableput();
80 fclose(tabin);
81 return(0);
84 int sargc;
85 char **sargv;
87 void
88 setinp(int argc, char **argv)
90 sargc = argc;
91 sargv = argv;
92 sargc--; sargv++;
93 if (sargc>0)
94 swapin();
97 int
98 swapin(void)
100 while (sargc>0 && **sargv=='-') /* Mem fault if no test on sargc */
102 if (sargc<=0) return(0);
103 if (match("-me", *sargv))
105 *sargv = MEMACSS;
106 break;
108 if (match("-ms", *sargv))
110 *sargv = MACROSS;
111 break;
113 if (match("-mm", *sargv))
115 *sargv = PYMACSS;
116 break;
118 if (match("-TX", *sargv))
119 pr1403=1;
120 else {
121 (void) fprintf(stderr, gettext("tbl: Invalid option "
122 "(%s).\n"), *sargv);
123 (void) fprintf(stderr, gettext("Usage: tbl [ -me ] "
124 "[ -mm ] [ -ms ] [ filename ] ...\n"));
125 exit(1);
127 sargc--; sargv++;
129 if (sargc<=0) return(0);
130 # ifdef unix
131 /* file closing is done by GCOS troff preprocessor */
132 if (tabin!=stdin) fclose(tabin);
133 # endif
134 tabin = fopen(ifile= *sargv, "r");
135 iline=1;
136 # ifdef unix
137 /* file names are all put into f. by the GCOS troff preprocessor */
138 fprintf(tabout, ".ds f. %s\n",ifile);
139 # endif
140 if (tabin==NULL)
141 error(gettext("Can't open file"));
142 sargc--;
143 sargv++;
144 return(1);
147 # ifdef unix
148 void
149 badsig(void)
151 signal(SIGPIPE, SIG_IGN);
152 exit(0);
154 # endif