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
39 #pragma ident "%Z%%M% %I% %E% SMI"
57 int (*wdbdg
)(wchar_t, wchar_t, int);
58 wchar_t *(*wddlm
)(wchar_t, wchar_t, int);
79 if (!ismot(i
= getch()))
90 int w
, cnt
, delim
, rem
, temp
;
93 if (ismot(c
= getch()))
98 length
= quant(atoi(), HOR
);
105 if ((cbits(c
= getch())) == delim
) {
108 } else if (cbits(c
) == FILLER
)
113 *i
++ = makem(length
);
116 if (!(cnt
= length
/ w
)) {
117 *i
++ = makem(-(temp
= ((w
- length
) / 2)));
119 *i
++ = makem(-(w
- length
- temp
));
122 if (rem
= length
% w
) {
123 if (cbits(c
) == RULE
|| cbits(c
) == UNDERLINE
||
148 while ((i
= cbits(getch())) != c
&& (i
!= '\n'))
161 if (ismot(i
= getch()))
164 for (k
= 0; (k
< NOV
) && ((j
= cbits(i
= getch())) != delim
) &&
176 for (k
= 1; o
[k
]; k
++) {
190 *pbp
++ = makem(w
[0] / 2);
191 for (k
= 0; o
[k
]; k
++)
195 *pbp
++ = makem(-((w
[k
] + w
[k
+1]) / 2));
211 if (ismot(i
= getch()))
217 dwn
= (2 * t
.Halfline
) | MOT
| VMOT
;
220 dwn
= EM
| MOT
| VMOT
;
222 while (((k
= cbits(i
= getch())) != delim
) && (k
!= '\n') &&
223 (j
<= (brabuf
+ NC
- 4))) {
236 *--j
= *brabuf
= (cnt
* t
.Halfline
) | MOT
| NMOT
| VMOT
;
239 *--j
= *brabuf
= (cnt
* EM
) / 2 | MOT
| NMOT
| VMOT
;
252 tchar c
, rem
, ver
, neg
;
257 if (ismot(c
= getch()))
262 i
= quant(atoi(), VERT
);
269 if ((cbits(c
= getch())) == delim
) {
270 c
= BOXRULE
| chbits
; /* default box rule */
286 rem
= makem(i
% v
) | neg
;
287 ver
= makem(v
) | neg
;
291 if (absmot(rem
) != 0) {
295 while ((vlp
< (vlbuf
+ NC
- 3)) && cnt
--) {
309 #define NPAIR (NC/2-6) /* max pairs in spline, etc. */
312 setdraw() /* generate internal cookies for a drawing function */
314 int i
, j
, k
, dx
[NPAIR
], dy
[NPAIR
], delim
, type
;
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
)
416 int length
, ws
, npad
, temp
, type
;
417 tchar
**pp
, *padptr
[NPP
];
419 int savfc
, savtc
, savlc
;
424 rchar
= tabc
| chbits
;
426 rchar
= dotc
| chbits
;
427 temp
= npad
= ws
= 0;
431 tabch
= ldrch
= fc
= IMP
;
432 savepos
= numtab
[HP
].val
;
433 gchtab
[tabch
] &= ~TABBIT
;
434 gchtab
[ldrch
] &= ~LDRBIT
;
435 gchtab
[fc
] &= ~FCBIT
;
436 gchtab
[IMP
] |= TABBIT
|LDRBIT
|FCBIT
;
438 if ((tabtab
[j
] & TABMASK
) == 0) {
440 errprint(gettext("zero field width."));
444 if ((length
= ((tabtab
[j
] & TABMASK
) - numtab
[HP
].val
)) > 0)
447 type
= tabtab
[j
] & (~TABMASK
);
452 j
= cbits(ii
= getch());
455 numtab
[HP
].val
+= jj
;
459 if (pp
> (padptr
+ NPP
- 1))
462 } else if (j
== savfc
)
464 else if (j
== '\n') {
472 if (fp
> (fbuf
+ FBUFSZ
- 3))
482 temp
= i
= (j
= length
- ws
) / npad
;
484 if ((j
-= i
* npad
) < 0)
489 for (; npad
> 0; npad
--) {
498 } else if (type
== 0) {
499 /* plain tab or leader */
500 if ((j
= width(rchar
)) > 0) {
501 int nchar
= length
/ j
;
502 while (nchar
-->0 && pbp
< &pbbuf
[NC
-3]) {
516 while (((j
= cbits(ii
= getch())) != savtc
) &&
517 (j
!= '\n') && (j
!= savlc
)) {
520 numtab
[HP
].val
+= jj
;
523 if (fp
> (fbuf
+ FBUFSZ
- 3))
531 length
-= ws
/ 2; /* CTAB */
533 if ((j
= width(rchar
)) != 0 && length
> 0) {
534 int nchar
= length
/ j
;
535 while (nchar
-- > 0 && pbp
< &pbbuf
[NC
-3])
539 length
= (length
/ HOR
) * HOR
;
544 gchtab
[fc
] &= ~FCBIT
;
545 gchtab
[tabch
] &= ~TABBIT
;
546 gchtab
[ldrch
] &= ~LDRBIT
;
551 gchtab
[tabch
] = TABBIT
;
552 gchtab
[ldrch
] |= LDRBIT
;
553 numtab
[HP
].val
= savepos
;
560 /* locale specific initialization */
564 extern int wdbindf();
565 extern wchar_t *wddelim();
568 codeset
= nl_langinfo(CODESET
);
573 if (*codeset
== '\0' ||
574 (strcmp(codeset
, ISO646
) == 0)) {
576 * if codeset is an empty string
577 * assumes this is C locale (7-bit) locale.
578 * This happens in 2.5, 2.5.1, and 2.6 system
579 * Or, if codeset is "646"
580 * this is 7-bit locale.