|
|
1.1 root 1: /*
2: * env.c
3: * Nroff/Troff.
4: * Environments.
5: */
6:
7: #include "roff.h"
8:
9: /*
10: * Initialize the current environment.
11: * The new environment inherits the values of all
12: * environmental variables which are not initialized here:
13: * this includes fcsz, fpsz, tfn, ufn, ufp.
14: */
15: envset()
16: {
17: register int inc, i, n;
18:
19: /* Set output line, default font and pointsize, vertical spacing. */
20: tln = lln = (lflag) ? unit(9*SMINCH, SDINCH) : unit(13*SMINCH, 2*SDINCH);
21: setline();
22: curfont = 0;
23: fon[0] = 'R';
24: fon[1] = '\0';
25: if (ntroff == TROFF) {
26: psz = unit(10*SMPOIN, SDPOIN); /* default point size = 10pt */
27: vls = unit(11*SMPOIN, SDPOIN); /* default leading 11 on 10 */
28: }
29:
30: /* Set default tab stops. */
31: tab[0].t_pos = 0;
32: tab[0].t_jus = LJUS;
33: inc = n = unit(8*SMINCH, 10*SDINCH);
34: for (i=1; i<TABSIZE-1; i++) {
35: env.e_tab[i].t_pos = n;
36: env.e_tab[i].t_jus = LJUS;
37: n += inc;
38: }
39: tab[TABSIZE-1].t_pos = 0;
40: tab[TABSIZE-1].t_jus = NJUS;
41:
42: /* Set other variables. */
43: adj = FJUS;
44: adm = 1;
45: ccc = '.';
46: cec = 0;
47: csz = 0;
48: enb = 0;
49: fill = 1;
50: hic = EHYP;
51: hyp = 1;
52: hypf = 0;
53: ind = 0;
54: inpltrc = 0;
55: inptrap[0] = '\0';
56: ldc = '.';
57: lgm = (ntroff == NROFF) ? 0 : 1;
58: lmn = 0;
59: lni = 0;
60: lnn = 0;
61: lns = 0;
62: lsp = 1;
63: mar = unit(SMEMSP, SDEMSP);
64: mrc = '\0';
65: mrch = '\0';
66: nbc = '\'';
67: nnc = 0;
68: spcnt = 0;
69: ssz = sszmul = (ntroff == NROFF) ? unit(SMEMSP, SDEMSP)
70: : unit(SMEMSP * 12, SDEMSP * 36);
71: sszdiv = psz;
72: tbc = '\0';
73: tbs = 0;
74: tif = 0;
75: tin = 0;
76: tpc = '%';
77: ulc = 0;
78: oldfon[0] = fon[0];
79: oldfon[1] = fon[1];
80: oldind = ind;
81: oldlln = lln;
82: oldlsp = lsp;
83: oldpsz = psz;
84: oldtln = tln;
85: oldvls = vls;
86: }
87:
88: /*
89: * Save environment n.
90: */
91: envsave(n) int n;
92: {
93: lseek(fileno(tmp), (long) n * sizeof (ENV), 0);
94: if (write(fileno(tmp), &env, sizeof (env)) != sizeof (env))
95: panic("cannot write environment");
96: }
97:
98: /*
99: * Restore environment n.
100: * Bug: in troff, restoring a saved environment does not set
101: * fpsz[n] for a font n loaded in the new environment.
102: */
103: envload(n) int n;
104: {
105: lseek(fileno(tmp), (long) n * sizeof (ENV), 0);
106: if (read(fileno(tmp), &env, sizeof (env)) != sizeof (env))
107: panic("cannot read environment");
108: dev_font(curfont);
109: }
110:
111: /* end of env.c */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.