4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
27 /* All Rights Reserved */
30 * University Copyright- Copyright (c) 1982, 1986, 1988
31 * The Regents of the University of California
34 * University Acknowledgment- Portions of this document are derived from
35 * software developed by the University of California, Berkeley, and its
55 int (*wdbdg
)(wchar_t, wchar_t, int);
56 wchar_t *(*wddlm
)(wchar_t, wchar_t, int);
77 if (!ismot(i
= getch()))
88 int w
, cnt
, delim
, rem
, temp
;
91 if (ismot(c
= getch()))
96 length
= quant(atoi(), HOR
);
103 if ((cbits(c
= getch())) == delim
) {
106 } else if (cbits(c
) == FILLER
)
111 *i
++ = makem(length
);
114 if (!(cnt
= length
/ w
)) {
115 *i
++ = makem(-(temp
= ((w
- length
) / 2)));
117 *i
++ = makem(-(w
- length
- temp
));
120 if (rem
= length
% w
) {
121 if (cbits(c
) == RULE
|| cbits(c
) == UNDERLINE
||
145 while ((i
= cbits(getch())) != c
&& (i
!= '\n'))
158 if (ismot(i
= getch()))
161 for (k
= 0; (k
< NOV
) && ((j
= cbits(i
= getch())) != delim
) &&
173 for (k
= 1; o
[k
]; k
++) {
187 *pbp
++ = makem(w
[0] / 2);
188 for (k
= 0; o
[k
]; k
++)
192 *pbp
++ = makem(-((w
[k
] + w
[k
+1]) / 2));
208 if (ismot(i
= getch()))
214 dwn
= (2 * t
.Halfline
) | MOT
| VMOT
;
217 dwn
= EM
| MOT
| VMOT
;
219 while (((k
= cbits(i
= getch())) != delim
) && (k
!= '\n') &&
220 (j
<= (brabuf
+ NC
- 4))) {
233 *--j
= *brabuf
= (cnt
* t
.Halfline
) | MOT
| NMOT
| VMOT
;
236 *--j
= *brabuf
= (cnt
* EM
) / 2 | MOT
| NMOT
| VMOT
;
249 tchar c
, rem
, ver
, neg
;
254 if (ismot(c
= getch()))
259 i
= quant(atoi(), VERT
);
266 if ((cbits(c
= getch())) == delim
) {
267 c
= BOXRULE
| chbits
; /* default box rule */
283 rem
= makem(i
% v
) | neg
;
284 ver
= makem(v
) | neg
;
288 if (absmot(rem
) != 0) {
292 while ((vlp
< (vlbuf
+ NC
- 3)) && cnt
--) {
306 #define NPAIR (NC/2-6) /* max pairs in spline, etc. */
309 * Generate internal cookies for a drawing function.
314 int i
, j
, k
, dx
[NPAIR
], dy
[NPAIR
], delim
, type __unused
;
315 tchar c
, drawbuf
[NC
];
317 /* input is \D'f dx dy dx dy ... c' (or at least it had better be) */
318 /* this does drawing function f with character c and the */
319 /* specified dx,dy pairs interpreted as appropriate */
320 /* pairs are deltas from last point, except for radii */
322 /* l dx dy: line from here by dx,dy */
323 /* c x: circle of diameter x, left side here */
324 /* e x y: ellipse of diameters x,y, left side here */
326 * a dx1 dy1 dx2 dy2: ccw arc: ctr at dx1,dy1,
327 * then end at dx2,dy2 from there
330 * ~ dx1 dy1 dx2 dy2...:
331 * spline to dx1,dy1 to dx2,dy2 ...
333 /* f dx dy ...: f is any other char: like spline */
335 if (ismot(c
= getch()))
338 type
= cbits(getch());
339 for (i
= 0; i
< NPAIR
; i
++) {
341 if (cbits(c
) == delim
)
343 /* ought to pick up optional drawing character */
348 dx
[i
] = quant(atoi(), HOR
);
351 else if (dx
[i
] < -MAXMOT
)
353 if (cbits((c
= getch())) == delim
) { /* spacer */
359 dy
[i
] = quant(atoi(), VERT
);
362 else if (dy
[i
] < -MAXMOT
)
368 drawbuf
[0] = DRAWFCN
| chbits
| ZBIT
;
369 drawbuf
[1] = type
| chbits
| ZBIT
;
370 drawbuf
[2] = '.' | chbits
| ZBIT
; /* use default drawing character */
371 for (k
= 0, j
= 3; k
< i
; k
++) {
372 drawbuf
[j
++] = MOT
| ((dx
[k
] >= 0) ? dx
[k
] : (NMOT
| -dx
[k
]));
373 drawbuf
[j
++] = MOT
| VMOT
| ((dy
[k
] >= 0) ?
374 dy
[k
] : (NMOT
| -dy
[k
]));
376 if (type
== DRAWELLIPSE
) {
377 /* so the net vertical is zero */
378 drawbuf
[5] = drawbuf
[4] | NMOT
;
381 drawbuf
[j
++] = DRAWFCN
| chbits
| ZBIT
; /* marks end for ptout */
395 gchtab
[fc
] &= ~FCBIT
;
398 if (skip() || ismot(j
= getch()) || (i
= cbits(j
)) == '\n')
402 if (skip() || ismot(ch
) || (ch
= cbits(ch
)) == fc
)
415 int length
, ws
, npad
, temp
, type
;
416 tchar
**pp
, *padptr
[NPP
];
418 int savfc
, savtc
, savlc
;
423 rchar
= tabc
| chbits
;
425 rchar
= dotc
| chbits
;
426 temp
= npad
= ws
= 0;
430 tabch
= ldrch
= fc
= IMP
;
431 savepos
= numtab
[HP
].val
;
432 gchtab
[tabch
] &= ~TABBIT
;
433 gchtab
[ldrch
] &= ~LDRBIT
;
434 gchtab
[fc
] &= ~FCBIT
;
435 gchtab
[IMP
] |= TABBIT
|LDRBIT
|FCBIT
;
437 if ((tabtab
[j
] & TABMASK
) == 0) {
439 errprint(gettext("zero field width."));
443 if ((length
= ((tabtab
[j
] & TABMASK
) - numtab
[HP
].val
)) > 0)
446 type
= tabtab
[j
] & (~TABMASK
);
451 j
= cbits(ii
= getch());
454 numtab
[HP
].val
+= jj
;
458 if (pp
> (padptr
+ NPP
- 1))
461 } else if (j
== savfc
)
463 else if (j
== '\n') {
471 if (fp
> (fbuf
+ FBUFSZ
- 3))
481 temp
= i
= (j
= length
- ws
) / npad
;
483 if ((j
-= i
* npad
) < 0)
488 for (; npad
> 0; npad
--) {
497 } else if (type
== 0) {
498 /* plain tab or leader */
499 if ((j
= width(rchar
)) > 0) {
500 int nchar
= length
/ j
;
501 while (nchar
-->0 && pbp
< &pbbuf
[NC
-3]) {
515 while (((j
= cbits(ii
= getch())) != savtc
) &&
516 (j
!= '\n') && (j
!= savlc
)) {
519 numtab
[HP
].val
+= jj
;
522 if (fp
> (fbuf
+ FBUFSZ
- 3))
530 length
-= ws
/ 2; /* CTAB */
532 if ((j
= width(rchar
)) != 0 && length
> 0) {
533 int nchar
= length
/ j
;
534 while (nchar
-- > 0 && pbp
< &pbbuf
[NC
-3])
538 length
= (length
/ HOR
) * HOR
;
543 gchtab
[fc
] &= ~FCBIT
;
544 gchtab
[tabch
] &= ~TABBIT
;
545 gchtab
[ldrch
] &= ~LDRBIT
;
550 gchtab
[tabch
] = TABBIT
;
551 gchtab
[ldrch
] |= LDRBIT
;
552 numtab
[HP
].val
= savepos
;
559 /* locale specific initialization */
563 extern int wdbindf();
564 extern wchar_t *wddelim();
567 codeset
= nl_langinfo(CODESET
);
572 if (*codeset
== '\0' ||
573 (strcmp(codeset
, ISO646
) == 0)) {
575 * if codeset is an empty string
576 * assumes this is C locale (7-bit) locale.
577 * This happens in 2.5, 2.5.1, and 2.6 system
578 * Or, if codeset is "646"
579 * this is 7-bit locale.