/*
* 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 1989 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* University Copyright- Copyright (c) 1982, 1986, 1988
* The Regents of the University of California
* All Rights Reserved
*
* University Acknowledgment- Portions of this document are derived from
* software developed by the University of California, Berkeley, and its
* contributors.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* unexpand - put tabs into a file replacing blanks
*/
#include <stdio.h>
#include <limits.h>
#include <stdlib.h>
#include <locale.h>
#include <libintl.h>
#include <wchar.h>
static void getstops(const char *);
static void usage(void);
int
int argc;
char *argv[];
{
int status = 0;
#if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */
#endif
(void) textdomain(TEXT_DOMAIN);
switch (flag) {
case 'a':
all++;
break;
case 't': /* POSIX.2 */
all++; /* -t turns on -a */
break;
default:
usage();
break;
}
}
do {
if (argc > 0) {
status++;
}
}
}
} while (argc > 0);
return (status);
/* NOTREACHED */
}
void
{
int p_col;
for (;;) {
switch (*cp) {
case ' ':
cp++;
spaces++;
ocol++;
if (nstops == 0) { /* default tab = 8 */
if ((ocol & 7) != 0)
break;
break;
} else { /* explicit tabstops */
cstop++;
(void) putchar(' ');
spaces = 0;
break;
}
break;
cstop++;
}
/*
* if we get to this point, we must be at a
* tab stop. if spaces, then write out a tab.
*/
if (spaces > 0) {
spaces = 0;
}
break;
case '\b': /* POSIX.2 */
while (spaces-- > 0)
(void) putchar(' ');
spaces = 0;
cp++;
(void) putchar('\b');
if (--ocol < 0)
ocol = 0;
/* just in case */
cstop = 0;
break;
case '\t':
cp++;
(void) putchar('\t');
/* adjust ocol to current tabstop */
if (nstops == 0) {
} else if (nstops == 1) {
} else {
else
ocol++;
}
spaces = 0;
break;
default:
while (spaces-- > 0)
(void) putchar(' ');
spaces = 0;
/*
* either end of input line or -a not set
*/
while (*cp != 0)
return;
}
p_col = 0;
break;
}
}
}
static void
{
register int i;
for (;;) {
i = 0;
if (i <= 0 || i > INT_MAX) {
"unexpand: invalid tablist item\n"));
usage();
}
"unexpand: tablist must be increasing\n"));
usage();
}
"unexpand: number of tabstops limited to %d\n"),
MAX_TABS);
usage();
}
if (*cp == 0)
break;
"unexpand: invalid tablist separator\n"));
usage();
}
cp++;
}
}
static void
usage(void)
{
"usage: unexpand [-a ] [-t tablist] [file ...]\n"));
exit(2);
/* NOTREACHED */
}