/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright (c) 1997-1999 by Sun Microsystems, Inc.
* All rights reserved.
*/
/*LINTLIBRARY*/
#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.2 */
#include <stdio.h>
#include <ctype.h>
#include <wchar.h>
#include <libintl.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include "libadm.h"
int
{
return (width);
return (width);
return (width);
}
if (*wp == L'!') {
wp++;
force = 1;
for (i = 0; i < lmarg; i++)
} else {
++wp; /* eat leading white space */
force = 0;
}
wordcnt = 0;
n = 0;
do {
if (force) {
if (*wp == L'\n') {
for (i = 0; i < lmarg; i++)
wp++;
n = 0;
} else {
/*
* Using putc instead of fputwc here to avoid
* mixing up the byte stream and the wide stream
* for fp.
*/
if (mlen == -1) {
/*
* wctomb failed
* nothing will be outputted
*/
wp++;
} else {
for (i = 0; i < mlen; i++)
wp++;
/*
* if wlen is a negative value (*wp is not printable),
* add 1 to n. (non-printable char shares 1 column.
*/
if (wlen >= 0)
n += wlen;
else
n++;
}
}
continue;
}
wordcnt++;
*copy++ = L' ';
n++;
} else if (*wp == L'\\') {
wordcnt++;
n = width + 1;
wp += 2;
wordcnt++;
do {
*copy++ = L' ';
} while (++n % 8);
n++;
wp += 2;
*copy++ = L' ';
wp += 2;
n++;
} else {
/*
* Only if both *wp and *(wp +1) are printable,
* tries to check the binding weight between them.
*/
/*
* if (n + wlen) is larger than width, *wp will be
* put to the next line.
*/
n = width + 1;
goto fold;
} else {
n += wlen;
if (bdg < 5) {
/*
* binding weight between *wp and *(wp + 1) is
* enough small to fold the line there.
*/
wordcnt++;
}
}
} else {
if (wlen > 0) {
/*
* *wp is printable
*/
/*
* if (n + wlen) is larger than width, *wp will
* be put to the next line.
*/
n = width + 1;
goto fold;
} else {
n += wlen;
}
} else {
/*
* *wp is not printable, and shares 1 column.
*/
n++;
}
}
}
} else {
/*
* Only if both *wp and *(wp + 1) are printable,
* tries to check the binding weight between them.
*/
/*
* if (n + wlen) is larger than width, *wp will be
* put to the next line.
*/
n = width + 1;
goto fold;
}
n += wlen;
if (bdg < 5) {
/*
* binding weight between *wp and *(wp + 1) is
* enough small to fold the line there.
*/
wordcnt++;
}
} else {
if (wlen > 0) {
/*
* *wp is printable
*/
/*
* if (n + wlen) is larger than width, *wp will
* be put to the next line.
*/
n = width + 1;
goto fold;
} else {
n += wlen;
}
} else {
/*
* *wp is not printable, and shares 1 column.
*/
n++;
}
}
}
fold:
if (n >= width) {
if (lastend)
*lastend = L'\0';
else
*copy = L'\0';
for (i = 0; i < lmarg; i++)
for (i = 0; i < mlen; i++)
if (wordcnt)
wordcnt = 0;
n = 0;
if (!force) {
wp++;
}
}
} while (*wp != L'\0');
if (!force) {
*copy = L'\0';
for (i = 0; i < lmarg; i++)
for (i = 0; i < mlen; i++)
}
}