-rest:
- if (language == NOLANG)
- language = C; /* C is the default */
-
- /* initialize for the appropriate language */
- /* This is done because subscripting is too */
- /* damned slow to be done every reference */
-
- keywds = ld[language].kwd;
- isprbeg = ld[language].isproc;
- isprend = ld[language].ispend;
-
- cstart = ld[language].combeg;
- cstop = ld[language].comend;
- cout = ld[language].comout;
- lcstart = strlen (cstart);
- lcstop = strlen (cstop);
-
- acstart = ld[language].acmbeg;
- acstop = ld[language].acmend;
- acout = ld[language].acmout;
- lacstart = strlen (acstart);
- lacstop = strlen (acstop);
-
- sdelim = ld[language].strdel;
- cdelim = ld[language].chrdel;
- com1line = ld[language].onelncom;
- str1line = ld[language].onelnstr;
- upeqlow = ld[language].onecase;
- pname[0] = 0;
-
- /* initialize the program */
-
- incomm = 0;
- inacomm = 0;
- instr = 0;
- ps("'-F\n");
- printf(".ds =F %s\n", fname);
- fstat(fileno(stdin), &stbuf);
- cp = ctime(&stbuf.st_mtime);
- cp[16] = '\0';
- cp[24] = '\0';
- printf(".ds =M %s %s\n", cp+4, cp+20);
- if (needbp) {
- needbp = 0;
- printf(".()\n");
- printf(".bp\n");
- }
- while (fgets(buf, sizeof buf, stdin) != NULL) {
- if (buf[0] == '\f' && buf[1] == '\n') {
- printf(".bp\n");
- continue;
- }
- if (com1line && (incomm || inacomm)) {
- incomm = 0;
- inacomm = 0;
- ps("\\c\n'-C\n");
- }
- if (str1line)
- instr = 0;
- comcol = NULL;
- putScp(buf);
- if (buf[strlen(buf) - 2] != '\\')
- instr = 0;
- margin = 0;
- }
- needbp = 1;
- } while (argc > 0);
- exit(0);
+ printf("'ds =H %s\n", argv[1]);
+ argc--, argv++;
+ argc--, argv++;
+ if (argc > 0)
+ continue;
+ goto rest;
+ }
+
+ /* act as a filter like eqn */
+ if (!strcmp(argv[0], "-f")) {
+ filter++;
+ argv[0] = argv[argc-1];
+ argv[argc-1] = "-";
+ continue;
+ }
+
+ /* take input from the standard place */
+ if (!strcmp(argv[0], "-")) {
+ argc = 0;
+ goto rest;
+ }
+
+ /* build an index */
+ if (!strcmp(argv[0], "-x")) {
+ index++;
+ argv[0] = "-n";
+ }
+
+ /* indicate no keywords */
+ if (!strcmp(argv[0], "-n")) {
+ nokeyw++;
+ argc--, argv++;
+ continue;
+ }
+
+ /* specify the font size */
+ if (!strncmp(argv[0], "-s", 2)) {
+ i = 0;
+ cp = argv[0] + 2;
+ while (*cp)
+ i = i * 10 + (*cp++ - '0');
+ printf("'ps %d\n'vs %d\n", i, i+1);
+ argc--, argv++;
+ continue;
+ }
+
+ /* specify the language */
+ if (!strncmp(argv[0], "-l", 2)) {
+ language = argv[0]+2;
+ argc--, argv++;
+ continue;
+ }
+
+ /* specify the language description file */
+ if (!strncmp(argv[0], "-d", 2)) {
+ defsfile = argv[1];
+ argc--, argv++;
+ argc--, argv++;
+ continue;
+ }
+
+ /* open the file for input */
+ if (freopen(argv[0], "r", stdin) == NULL) {
+ perror(argv[0]);
+ exit(1);
+ }
+ if (index)
+ printf("'ta 4i 4.25i 5.5iR\n'in .5i\n");
+ fname = argv[0];
+ argc--, argv++;
+ }
+ rest:
+
+ /*
+ * get the language definition from the defs file
+ */
+ i = tgetent (defs, language, defsfile);
+ if (i == 0) {
+ fprintf (stderr, "no entry for language %s\n", language);
+ exit (0);
+ } else if (i < 0) {
+ fprintf (stderr, "cannot find vgrindefs file %s\n", defsfile);
+ exit (0);
+ }
+ cp = strings;
+ if (tgetstr ("kw", &cp) == NIL)
+ nokeyw = TRUE;
+ else {
+ char **cpp;
+
+ cpp = l_keywds;
+ cp = strings;
+ while (*cp) {
+ while (*cp == ' ' || *cp =='\t')
+ *cp++ = NULL;
+ if (*cp)
+ *cpp++ = cp;
+ while (*cp != ' ' && *cp != '\t' && *cp)
+ cp++;
+ }
+ *cpp = NIL;
+ }
+ cp = buf;
+ l_prcbeg = convexp (tgetstr ("pb", &cp));
+ cp = buf;
+ l_combeg = convexp (tgetstr ("cb", &cp));
+ cp = buf;
+ l_comend = convexp (tgetstr ("ce", &cp));
+ cp = buf;
+ l_acmbeg = convexp (tgetstr ("ab", &cp));
+ cp = buf;
+ l_acmend = convexp (tgetstr ("ae", &cp));
+ cp = buf;
+ l_strbeg = convexp (tgetstr ("sb", &cp));
+ cp = buf;
+ l_strend = convexp (tgetstr ("se", &cp));
+ cp = buf;
+ l_blkbeg = convexp (tgetstr ("bb", &cp));
+ cp = buf;
+ l_blkend = convexp (tgetstr ("be", &cp));
+ cp = buf;
+ l_chrbeg = convexp (tgetstr ("lb", &cp));
+ cp = buf;
+ l_chrend = convexp (tgetstr ("le", &cp));
+ l_escape = '\\';
+ l_onecase = tgetflag ("oc");
+ l_toplex = tgetflag ("tl");
+
+ /* initialize the program */
+
+ incomm = FALSE;
+ instr = FALSE;
+ inchr = FALSE;
+ _escaped = FALSE;
+ blklevel = 0;
+ for (psptr=0; psptr<PSMAX; psptr++) {
+ pstack[psptr][0] = NULL;
+ plstack[psptr] = 0;
+ }
+ psptr = -1;
+ ps("'-F\n");
+ if (!filter) {
+ printf(".ds =F %s\n", fname);
+ fstat(fileno(stdin), &stbuf);
+ cp = ctime(&stbuf.st_mtime);
+ cp[16] = '\0';
+ cp[24] = '\0';
+ printf(".ds =M %s %s\n", cp+4, cp+20);
+ ps("'wh 0 vH\n");
+ ps("'wh -1i vF\n");
+ }
+ if (needbp) {
+ needbp = 0;
+ printf(".()\n");
+ printf(".bp\n");
+ }
+
+ /*
+ * MAIN LOOP!!!
+ */
+ while (fgets(buf, sizeof buf, stdin) != NULL) {
+ if (buf[0] == '\f') {
+ printf(".bp\n");
+ }
+ if (buf[0] == '.') {
+ printf("%s", buf);
+ if (!strncmp (buf+1, "vS", 2))
+ pass = TRUE;
+ if (!strncmp (buf+1, "vE", 2))
+ pass = FALSE;
+ continue;
+ }
+ prccont = FALSE;
+ if (!filter || pass)
+ putScp(buf);
+ else
+ printf("%s", buf);
+ if (prccont && (psptr >= 0)) {
+ ps("'FC ");
+ ps(pstack[psptr]);
+ ps("\n");
+ }
+#ifdef DEBUG
+ printf ("com %o str %o chr %o ptr %d\n", incomm, instr, inchr, psptr);
+#endif
+ margin = 0;
+ }
+ needbp = 1;
+ } while (argc > 0);
+ exit(0);