1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate *
4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate * with the License.
8*7c478bd9Sstevel@tonic-gate *
9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate *
14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate *
20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate */
22*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1988 AT&T */
23*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */
24*7c478bd9Sstevel@tonic-gate
25*7c478bd9Sstevel@tonic-gate
26*7c478bd9Sstevel@tonic-gate /*
27*7c478bd9Sstevel@tonic-gate * Copyright (c) 1997, by Sun Microsystems, Inc.
28*7c478bd9Sstevel@tonic-gate * All rights reserved.
29*7c478bd9Sstevel@tonic-gate */
30*7c478bd9Sstevel@tonic-gate
31*7c478bd9Sstevel@tonic-gate /*LINTLIBRARY*/
32*7c478bd9Sstevel@tonic-gate
33*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
34*7c478bd9Sstevel@tonic-gate #include <stdlib.h>
35*7c478bd9Sstevel@tonic-gate #include "utility.h"
36*7c478bd9Sstevel@tonic-gate
37*7c478bd9Sstevel@tonic-gate #define MAX_BUF 81
38*7c478bd9Sstevel@tonic-gate
39*7c478bd9Sstevel@tonic-gate /* default form */
40*7c478bd9Sstevel@tonic-gate
41*7c478bd9Sstevel@tonic-gate static FORM default_form =
42*7c478bd9Sstevel@tonic-gate {
43*7c478bd9Sstevel@tonic-gate 0, /* status */
44*7c478bd9Sstevel@tonic-gate 0, /* rows */
45*7c478bd9Sstevel@tonic-gate 0, /* cols */
46*7c478bd9Sstevel@tonic-gate 0, /* currow */
47*7c478bd9Sstevel@tonic-gate 0, /* curcol */
48*7c478bd9Sstevel@tonic-gate 0, /* toprow */
49*7c478bd9Sstevel@tonic-gate 0, /* begincol */
50*7c478bd9Sstevel@tonic-gate -1, /* maxfield */
51*7c478bd9Sstevel@tonic-gate -1, /* maxpage */
52*7c478bd9Sstevel@tonic-gate -1, /* curpage */
53*7c478bd9Sstevel@tonic-gate O_NL_OVERLOAD |
54*7c478bd9Sstevel@tonic-gate O_BS_OVERLOAD, /* opts */
55*7c478bd9Sstevel@tonic-gate (WINDOW *) 0, /* win */
56*7c478bd9Sstevel@tonic-gate (WINDOW *) 0, /* sub */
57*7c478bd9Sstevel@tonic-gate (WINDOW *) 0, /* w */
58*7c478bd9Sstevel@tonic-gate (FIELD **) 0, /* field */
59*7c478bd9Sstevel@tonic-gate (FIELD *) 0, /* current */
60*7c478bd9Sstevel@tonic-gate (_PAGE *) 0, /* page */
61*7c478bd9Sstevel@tonic-gate (char *) 0, /* usrptr */
62*7c478bd9Sstevel@tonic-gate (PTF_void) 0, /* forminit */
63*7c478bd9Sstevel@tonic-gate (PTF_void) 0, /* formterm */
64*7c478bd9Sstevel@tonic-gate (PTF_void) 0, /* fieldinit */
65*7c478bd9Sstevel@tonic-gate (PTF_void) 0, /* fieldterm */
66*7c478bd9Sstevel@tonic-gate };
67*7c478bd9Sstevel@tonic-gate
68*7c478bd9Sstevel@tonic-gate FORM * _DEFAULT_FORM = &default_form;
69*7c478bd9Sstevel@tonic-gate
70*7c478bd9Sstevel@tonic-gate /*
71*7c478bd9Sstevel@tonic-gate * insert - insert field f into sorted list pointed
72*7c478bd9Sstevel@tonic-gate * to by head. return (possibly new) head of list.
73*7c478bd9Sstevel@tonic-gate */
74*7c478bd9Sstevel@tonic-gate static FIELD *
insert(FIELD * f,FIELD * head)75*7c478bd9Sstevel@tonic-gate insert(FIELD *f, FIELD *head)
76*7c478bd9Sstevel@tonic-gate {
77*7c478bd9Sstevel@tonic-gate FIELD *p;
78*7c478bd9Sstevel@tonic-gate FIELD *newhead;
79*7c478bd9Sstevel@tonic-gate int frow, fcol;
80*7c478bd9Sstevel@tonic-gate
81*7c478bd9Sstevel@tonic-gate if (head) {
82*7c478bd9Sstevel@tonic-gate p = newhead = head;
83*7c478bd9Sstevel@tonic-gate
84*7c478bd9Sstevel@tonic-gate frow = f->frow;
85*7c478bd9Sstevel@tonic-gate fcol = f->fcol;
86*7c478bd9Sstevel@tonic-gate
87*7c478bd9Sstevel@tonic-gate while ((p->frow < frow) ||
88*7c478bd9Sstevel@tonic-gate (p->frow == frow && p->fcol < fcol)) {
89*7c478bd9Sstevel@tonic-gate p = p->snext;
90*7c478bd9Sstevel@tonic-gate
91*7c478bd9Sstevel@tonic-gate if (p == head) {
92*7c478bd9Sstevel@tonic-gate head = (FIELD *) 0;
93*7c478bd9Sstevel@tonic-gate break;
94*7c478bd9Sstevel@tonic-gate }
95*7c478bd9Sstevel@tonic-gate }
96*7c478bd9Sstevel@tonic-gate f->snext = p;
97*7c478bd9Sstevel@tonic-gate f->sprev = p->sprev;
98*7c478bd9Sstevel@tonic-gate f->snext->sprev = f;
99*7c478bd9Sstevel@tonic-gate f->sprev->snext = f;
100*7c478bd9Sstevel@tonic-gate
101*7c478bd9Sstevel@tonic-gate if (p == head)
102*7c478bd9Sstevel@tonic-gate newhead = f; /* insert at head of list */
103*7c478bd9Sstevel@tonic-gate } else
104*7c478bd9Sstevel@tonic-gate newhead = f->sprev = f->snext = f; /* initialize new list */
105*7c478bd9Sstevel@tonic-gate
106*7c478bd9Sstevel@tonic-gate return (newhead);
107*7c478bd9Sstevel@tonic-gate }
108*7c478bd9Sstevel@tonic-gate
109*7c478bd9Sstevel@tonic-gate /* sort_form - sort fields on form(per page) */
110*7c478bd9Sstevel@tonic-gate static void
sort_form(FORM * f)111*7c478bd9Sstevel@tonic-gate sort_form(FORM *f)
112*7c478bd9Sstevel@tonic-gate {
113*7c478bd9Sstevel@tonic-gate FIELD **field;
114*7c478bd9Sstevel@tonic-gate FIELD *p;
115*7c478bd9Sstevel@tonic-gate int i, page, pmin, pmax;
116*7c478bd9Sstevel@tonic-gate
117*7c478bd9Sstevel@tonic-gate field = f->field;
118*7c478bd9Sstevel@tonic-gate
119*7c478bd9Sstevel@tonic-gate for (page = 0; page < f->maxpage; ++page) { /* for each page */
120*7c478bd9Sstevel@tonic-gate p = (FIELD *) 0;
121*7c478bd9Sstevel@tonic-gate
122*7c478bd9Sstevel@tonic-gate pmin = Pmin(f, page);
123*7c478bd9Sstevel@tonic-gate pmax = Pmax(f, page);
124*7c478bd9Sstevel@tonic-gate
125*7c478bd9Sstevel@tonic-gate for (i = pmin; i <= pmax; ++i) { /* for each field */
126*7c478bd9Sstevel@tonic-gate field[i]->index = i;
127*7c478bd9Sstevel@tonic-gate field[i]->page = page;
128*7c478bd9Sstevel@tonic-gate
129*7c478bd9Sstevel@tonic-gate p = insert(field[i], p);
130*7c478bd9Sstevel@tonic-gate }
131*7c478bd9Sstevel@tonic-gate Smin(f, page) = p->index; /* set sorted min */
132*7c478bd9Sstevel@tonic-gate Smax(f, page) = p->sprev->index; /* set sorted max */
133*7c478bd9Sstevel@tonic-gate }
134*7c478bd9Sstevel@tonic-gate }
135*7c478bd9Sstevel@tonic-gate
136*7c478bd9Sstevel@tonic-gate /* merge - xmax/ymax is the minimum window size to hold field f */
137*7c478bd9Sstevel@tonic-gate static void
merge(FIELD * f,FORM * form)138*7c478bd9Sstevel@tonic-gate merge(FIELD *f, FORM *form) /* adjust form dimensions to include field f */
139*7c478bd9Sstevel@tonic-gate {
140*7c478bd9Sstevel@tonic-gate int xmax = f->fcol + f->cols;
141*7c478bd9Sstevel@tonic-gate int ymax = f->frow + f->rows;
142*7c478bd9Sstevel@tonic-gate
143*7c478bd9Sstevel@tonic-gate if (form->rows < ymax)
144*7c478bd9Sstevel@tonic-gate form->rows = ymax;
145*7c478bd9Sstevel@tonic-gate if (form->cols < xmax)
146*7c478bd9Sstevel@tonic-gate form->cols = xmax;
147*7c478bd9Sstevel@tonic-gate }
148*7c478bd9Sstevel@tonic-gate
149*7c478bd9Sstevel@tonic-gate /* disconnect_fields - disconnect fields from form */
150*7c478bd9Sstevel@tonic-gate static void
disconnect_fields(FORM * form)151*7c478bd9Sstevel@tonic-gate disconnect_fields(FORM *form)
152*7c478bd9Sstevel@tonic-gate {
153*7c478bd9Sstevel@tonic-gate FIELD **f = form->field;
154*7c478bd9Sstevel@tonic-gate
155*7c478bd9Sstevel@tonic-gate if (f)
156*7c478bd9Sstevel@tonic-gate while (*f) {
157*7c478bd9Sstevel@tonic-gate if ((*f)->form == form)
158*7c478bd9Sstevel@tonic-gate (*f)->form = (FORM *) 0;
159*7c478bd9Sstevel@tonic-gate ++f;
160*7c478bd9Sstevel@tonic-gate }
161*7c478bd9Sstevel@tonic-gate
162*7c478bd9Sstevel@tonic-gate form->rows = 0;
163*7c478bd9Sstevel@tonic-gate form->cols = 0;
164*7c478bd9Sstevel@tonic-gate form->maxfield = -1;
165*7c478bd9Sstevel@tonic-gate form->maxpage = -1;
166*7c478bd9Sstevel@tonic-gate form->field = (FIELD **) 0;
167*7c478bd9Sstevel@tonic-gate }
168*7c478bd9Sstevel@tonic-gate
169*7c478bd9Sstevel@tonic-gate /* connect_fields - connect fields to form */
170*7c478bd9Sstevel@tonic-gate static int
connect_fields(FORM * f,FIELD ** x)171*7c478bd9Sstevel@tonic-gate connect_fields(FORM *f, FIELD **x)
172*7c478bd9Sstevel@tonic-gate {
173*7c478bd9Sstevel@tonic-gate _PAGE * page;
174*7c478bd9Sstevel@tonic-gate
175*7c478bd9Sstevel@tonic-gate int nf, /* number of fields */
176*7c478bd9Sstevel@tonic-gate np; /* number of pages */
177*7c478bd9Sstevel@tonic-gate int i;
178*7c478bd9Sstevel@tonic-gate
179*7c478bd9Sstevel@tonic-gate f->field = x;
180*7c478bd9Sstevel@tonic-gate f->maxfield = 0;
181*7c478bd9Sstevel@tonic-gate f->maxpage = 0;
182*7c478bd9Sstevel@tonic-gate
183*7c478bd9Sstevel@tonic-gate if (!x)
184*7c478bd9Sstevel@tonic-gate return (E_OK); /* null field array */
185*7c478bd9Sstevel@tonic-gate
186*7c478bd9Sstevel@tonic-gate for (nf = 0, np = 0; x[nf]; ++nf) {
187*7c478bd9Sstevel@tonic-gate if (nf == 0 || Status(x[nf], NEW_PAGE))
188*7c478bd9Sstevel@tonic-gate ++np; /* count pages */
189*7c478bd9Sstevel@tonic-gate
190*7c478bd9Sstevel@tonic-gate if (x[nf]->form)
191*7c478bd9Sstevel@tonic-gate return (E_CONNECTED);
192*7c478bd9Sstevel@tonic-gate else
193*7c478bd9Sstevel@tonic-gate x[nf]->form = f; /* connect field to form */
194*7c478bd9Sstevel@tonic-gate }
195*7c478bd9Sstevel@tonic-gate if (nf == 0)
196*7c478bd9Sstevel@tonic-gate return (E_BAD_ARGUMENT); /* no fields */
197*7c478bd9Sstevel@tonic-gate
198*7c478bd9Sstevel@tonic-gate if (arrayAlloc(f->page, np, _PAGE)) {
199*7c478bd9Sstevel@tonic-gate page = f->page;
200*7c478bd9Sstevel@tonic-gate
201*7c478bd9Sstevel@tonic-gate for (i = 0; i < nf; ++i) {
202*7c478bd9Sstevel@tonic-gate if (i == 0)
203*7c478bd9Sstevel@tonic-gate page->pmin = i;
204*7c478bd9Sstevel@tonic-gate
205*7c478bd9Sstevel@tonic-gate else if (Status(x[i], NEW_PAGE)) {
206*7c478bd9Sstevel@tonic-gate page->pmax = i - 1;
207*7c478bd9Sstevel@tonic-gate ++page;
208*7c478bd9Sstevel@tonic-gate page->pmin = i;
209*7c478bd9Sstevel@tonic-gate }
210*7c478bd9Sstevel@tonic-gate merge(x[i], f);
211*7c478bd9Sstevel@tonic-gate }
212*7c478bd9Sstevel@tonic-gate page->pmax = nf - 1;
213*7c478bd9Sstevel@tonic-gate f->maxfield = nf;
214*7c478bd9Sstevel@tonic-gate f->maxpage = np;
215*7c478bd9Sstevel@tonic-gate sort_form(f);
216*7c478bd9Sstevel@tonic-gate return (E_OK);
217*7c478bd9Sstevel@tonic-gate }
218*7c478bd9Sstevel@tonic-gate return (E_SYSTEM_ERROR);
219*7c478bd9Sstevel@tonic-gate }
220*7c478bd9Sstevel@tonic-gate
221*7c478bd9Sstevel@tonic-gate FORM *
new_form(FIELD ** field)222*7c478bd9Sstevel@tonic-gate new_form(FIELD **field)
223*7c478bd9Sstevel@tonic-gate {
224*7c478bd9Sstevel@tonic-gate FORM *f;
225*7c478bd9Sstevel@tonic-gate
226*7c478bd9Sstevel@tonic-gate if (Alloc(f, FORM)) {
227*7c478bd9Sstevel@tonic-gate *f = *_DEFAULT_FORM;
228*7c478bd9Sstevel@tonic-gate
229*7c478bd9Sstevel@tonic-gate if (connect_fields(f, field) == E_OK) {
230*7c478bd9Sstevel@tonic-gate if (f->maxpage) {
231*7c478bd9Sstevel@tonic-gate P(f) = 0;
232*7c478bd9Sstevel@tonic-gate C(f) = _first_active(f);
233*7c478bd9Sstevel@tonic-gate } else {
234*7c478bd9Sstevel@tonic-gate P(f) = -1;
235*7c478bd9Sstevel@tonic-gate C(f) = (FIELD *) 0;
236*7c478bd9Sstevel@tonic-gate }
237*7c478bd9Sstevel@tonic-gate return (f);
238*7c478bd9Sstevel@tonic-gate }
239*7c478bd9Sstevel@tonic-gate }
240*7c478bd9Sstevel@tonic-gate (void) free_form(f);
241*7c478bd9Sstevel@tonic-gate return ((FORM *) 0);
242*7c478bd9Sstevel@tonic-gate }
243*7c478bd9Sstevel@tonic-gate
244*7c478bd9Sstevel@tonic-gate int
free_form(FORM * f)245*7c478bd9Sstevel@tonic-gate free_form(FORM *f)
246*7c478bd9Sstevel@tonic-gate {
247*7c478bd9Sstevel@tonic-gate if (!f)
248*7c478bd9Sstevel@tonic-gate return (E_BAD_ARGUMENT);
249*7c478bd9Sstevel@tonic-gate
250*7c478bd9Sstevel@tonic-gate if (Status(f, POSTED))
251*7c478bd9Sstevel@tonic-gate return (E_POSTED);
252*7c478bd9Sstevel@tonic-gate
253*7c478bd9Sstevel@tonic-gate disconnect_fields(f);
254*7c478bd9Sstevel@tonic-gate Free(f->page);
255*7c478bd9Sstevel@tonic-gate Free(f);
256*7c478bd9Sstevel@tonic-gate return (E_OK);
257*7c478bd9Sstevel@tonic-gate }
258*7c478bd9Sstevel@tonic-gate
259*7c478bd9Sstevel@tonic-gate int
set_form_fields(FORM * f,FIELD ** fields)260*7c478bd9Sstevel@tonic-gate set_form_fields(FORM *f, FIELD **fields)
261*7c478bd9Sstevel@tonic-gate {
262*7c478bd9Sstevel@tonic-gate FIELD **p;
263*7c478bd9Sstevel@tonic-gate int v;
264*7c478bd9Sstevel@tonic-gate
265*7c478bd9Sstevel@tonic-gate if (!f)
266*7c478bd9Sstevel@tonic-gate return (E_BAD_ARGUMENT);
267*7c478bd9Sstevel@tonic-gate
268*7c478bd9Sstevel@tonic-gate if (Status(f, POSTED))
269*7c478bd9Sstevel@tonic-gate return (E_POSTED);
270*7c478bd9Sstevel@tonic-gate
271*7c478bd9Sstevel@tonic-gate p = f->field;
272*7c478bd9Sstevel@tonic-gate disconnect_fields(f);
273*7c478bd9Sstevel@tonic-gate
274*7c478bd9Sstevel@tonic-gate if ((v = connect_fields(f, fields)) == E_OK) {
275*7c478bd9Sstevel@tonic-gate if (f->maxpage) {
276*7c478bd9Sstevel@tonic-gate P(f) = 0;
277*7c478bd9Sstevel@tonic-gate C(f) = _first_active(f);
278*7c478bd9Sstevel@tonic-gate } else {
279*7c478bd9Sstevel@tonic-gate P(f) = -1;
280*7c478bd9Sstevel@tonic-gate C(f) = (FIELD *) 0;
281*7c478bd9Sstevel@tonic-gate }
282*7c478bd9Sstevel@tonic-gate } else
283*7c478bd9Sstevel@tonic-gate (void) connect_fields(f, p); /* reconnect original fields */
284*7c478bd9Sstevel@tonic-gate return (v);
285*7c478bd9Sstevel@tonic-gate }
286*7c478bd9Sstevel@tonic-gate
287*7c478bd9Sstevel@tonic-gate FIELD **
form_fields(FORM * f)288*7c478bd9Sstevel@tonic-gate form_fields(FORM *f)
289*7c478bd9Sstevel@tonic-gate {
290*7c478bd9Sstevel@tonic-gate return (Form(f)->field);
291*7c478bd9Sstevel@tonic-gate }
292*7c478bd9Sstevel@tonic-gate
293*7c478bd9Sstevel@tonic-gate int
field_count(FORM * f)294*7c478bd9Sstevel@tonic-gate field_count(FORM *f)
295*7c478bd9Sstevel@tonic-gate {
296*7c478bd9Sstevel@tonic-gate return (Form(f)->maxfield);
297*7c478bd9Sstevel@tonic-gate }
298*7c478bd9Sstevel@tonic-gate
299*7c478bd9Sstevel@tonic-gate int
scale_form(FORM * f,int * rows,int * cols)300*7c478bd9Sstevel@tonic-gate scale_form(FORM *f, int *rows, int *cols)
301*7c478bd9Sstevel@tonic-gate {
302*7c478bd9Sstevel@tonic-gate if (!f)
303*7c478bd9Sstevel@tonic-gate return (E_BAD_ARGUMENT);
304*7c478bd9Sstevel@tonic-gate
305*7c478bd9Sstevel@tonic-gate if (!f->field)
306*7c478bd9Sstevel@tonic-gate return (E_NOT_CONNECTED);
307*7c478bd9Sstevel@tonic-gate
308*7c478bd9Sstevel@tonic-gate *rows = f->rows;
309*7c478bd9Sstevel@tonic-gate *cols = f->cols;
310*7c478bd9Sstevel@tonic-gate return (E_OK);
311*7c478bd9Sstevel@tonic-gate }
312*7c478bd9Sstevel@tonic-gate
313*7c478bd9Sstevel@tonic-gate BOOLEAN
data_behind(FORM * f)314*7c478bd9Sstevel@tonic-gate data_behind(FORM *f)
315*7c478bd9Sstevel@tonic-gate {
316*7c478bd9Sstevel@tonic-gate return (OneRow(C(f)) ? B(f) != 0 : T(f) != 0);
317*7c478bd9Sstevel@tonic-gate }
318*7c478bd9Sstevel@tonic-gate
319*7c478bd9Sstevel@tonic-gate /* _data_ahead - return ptr to last non-pad char in v[n] (v on failure) */
320*7c478bd9Sstevel@tonic-gate static char *
_data_ahead(char * v,int pad,int n)321*7c478bd9Sstevel@tonic-gate _data_ahead(char *v, int pad, int n)
322*7c478bd9Sstevel@tonic-gate {
323*7c478bd9Sstevel@tonic-gate char *vend = v + n;
324*7c478bd9Sstevel@tonic-gate while (vend > v && *(vend - 1) == pad) --vend;
325*7c478bd9Sstevel@tonic-gate return (vend);
326*7c478bd9Sstevel@tonic-gate }
327*7c478bd9Sstevel@tonic-gate
328*7c478bd9Sstevel@tonic-gate BOOLEAN
data_ahead(FORM * f)329*7c478bd9Sstevel@tonic-gate data_ahead(FORM *f)
330*7c478bd9Sstevel@tonic-gate {
331*7c478bd9Sstevel@tonic-gate static char buf[ MAX_BUF ];
332*7c478bd9Sstevel@tonic-gate char *bptr = buf;
333*7c478bd9Sstevel@tonic-gate WINDOW *w = W(f);
334*7c478bd9Sstevel@tonic-gate FIELD *c = C(f);
335*7c478bd9Sstevel@tonic-gate int ret = FALSE;
336*7c478bd9Sstevel@tonic-gate int pad = Pad(c);
337*7c478bd9Sstevel@tonic-gate int cols = c->cols;
338*7c478bd9Sstevel@tonic-gate int dcols;
339*7c478bd9Sstevel@tonic-gate int drows;
340*7c478bd9Sstevel@tonic-gate int flag = cols > MAX_BUF - 1;
341*7c478bd9Sstevel@tonic-gate int start;
342*7c478bd9Sstevel@tonic-gate int chunk;
343*7c478bd9Sstevel@tonic-gate
344*7c478bd9Sstevel@tonic-gate if (flag)
345*7c478bd9Sstevel@tonic-gate bptr = malloc(cols + 1);
346*7c478bd9Sstevel@tonic-gate
347*7c478bd9Sstevel@tonic-gate if (OneRow(c)) {
348*7c478bd9Sstevel@tonic-gate dcols = c->dcols;
349*7c478bd9Sstevel@tonic-gate start = B(f) + cols;
350*7c478bd9Sstevel@tonic-gate
351*7c478bd9Sstevel@tonic-gate while (start < dcols) {
352*7c478bd9Sstevel@tonic-gate chunk = MIN(cols, dcols - start);
353*7c478bd9Sstevel@tonic-gate (void) wmove(w, 0, start);
354*7c478bd9Sstevel@tonic-gate (void) winnstr(w, bptr, chunk);
355*7c478bd9Sstevel@tonic-gate
356*7c478bd9Sstevel@tonic-gate if (bptr != _data_ahead(bptr, pad, chunk)) {
357*7c478bd9Sstevel@tonic-gate ret = (TRUE);
358*7c478bd9Sstevel@tonic-gate break;
359*7c478bd9Sstevel@tonic-gate }
360*7c478bd9Sstevel@tonic-gate
361*7c478bd9Sstevel@tonic-gate start += cols;
362*7c478bd9Sstevel@tonic-gate }
363*7c478bd9Sstevel@tonic-gate } else { /* else multi-line field */
364*7c478bd9Sstevel@tonic-gate drows = c->drows;
365*7c478bd9Sstevel@tonic-gate start = T(f) + c->rows;
366*7c478bd9Sstevel@tonic-gate
367*7c478bd9Sstevel@tonic-gate while (start < drows) {
368*7c478bd9Sstevel@tonic-gate (void) wmove(w, start++, 0);
369*7c478bd9Sstevel@tonic-gate (void) winnstr(w, bptr, cols);
370*7c478bd9Sstevel@tonic-gate
371*7c478bd9Sstevel@tonic-gate if (bptr != _data_ahead(bptr, pad, cols)) {
372*7c478bd9Sstevel@tonic-gate ret = TRUE;
373*7c478bd9Sstevel@tonic-gate break;
374*7c478bd9Sstevel@tonic-gate }
375*7c478bd9Sstevel@tonic-gate }
376*7c478bd9Sstevel@tonic-gate }
377*7c478bd9Sstevel@tonic-gate
378*7c478bd9Sstevel@tonic-gate if (flag)
379*7c478bd9Sstevel@tonic-gate (void) free(bptr);
380*7c478bd9Sstevel@tonic-gate
381*7c478bd9Sstevel@tonic-gate (void) wmove(w, Y(f), X(f));
382*7c478bd9Sstevel@tonic-gate return (ret);
383*7c478bd9Sstevel@tonic-gate }
384