/*
* 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 2000 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* UNIX shell
*/
#include "defs.h"
#include "sym.h"
#include <errno.h>
#include <fcntl.h>
/* ======== character handling for command lines ======== */
int
word(void)
{
unsigned int c, d, cc;
unsigned char *oldargp;
unsigned char *pc;
wdnum = 0;
wdset = 0;
while (1)
{
;
if (c == COMCHAR)
{
peekc = c;
}
else
{
break; /* out of comment - white space loop */
}
}
if (!eofmeta(c))
{
do
{
if (c == LITERAL)
{
/*
* quote each character within
* single quotes
*/
*argp++='\\';
/* Pick up rest of multibyte character */
if (c == NL)
chkpr();
while (c = *pc++) {
*argp++ = (unsigned char)c;
}
}
/*
* Word will be represented by quoted null
* in macro.c if necessary
*/
*argp++ = '"';
*argp++ = '"';
}
}
else
{
if (c == 0) {
*argp++ = 0;
} else {
while (*pc) {
}
}
if (c == '\\') {
*argp++ = 0;
} else {
while (*pc) {
}
}
}
if (c == '=')
if (!alphanum(c))
alpha = 0;
if (qotchar(c))
{
d = c;
for (;;)
{
if ((c = nextwc()) == 0) {
*argp++ = 0;
} else {
while (*pc) {
}
}
if (c == 0 || c == d)
break;
if (c == NL)
chkpr();
/*
* don't interpret quoted
* characters
*/
if (c == '\\') {
*argp++ = 0;
} else {
while (*pc) {
}
}
}
}
}
}
wdset = 0;
(c == '>' || c == '<'))
{
word();
wdnum = d - '0';
}else{ /* check for reserved words */
reserved, no_reserved)) == 0) {
wdval = 0;
}
/* set arg for reserved words too */
}
}else if (dipchar(c)){
if ((d = nextwc()) == c)
{
if (c == '<')
{
if ((d = nextwc()) == '-')
else
}
}
else
{
wdval = c;
}
}
else
{
{
tmp_iopend = iopend;
iopend = 0;
}
}
return (wdval);
}
unsigned int skipwc()
{
unsigned int c;
;
return (c);
}
unsigned int nextwc()
{
unsigned int c, d;
chkpr();
goto retry;
}
}
return (d);
}
unsigned char *readw(d)
wchar_t d;
{
static unsigned char c[MULTI_BYTE_MAX + 1];
int length;
wchar_t l;
if (isascii(d)) {
c[0] = d;
c[1] = '\0';
return (c);
}
if (length <= 0) {
c[0] = (unsigned char)d;
length = 1;
}
c[length] = '\0';
return (c);
}
unsigned int
readwc()
{
wchar_t c;
int len;
struct fileblk *f;
int i, mlen;
if (peekn) {
c = peekn & 0x7fffffff;
peekn = 0;
return (c);
}
if (peekc) {
c = peekc & 0x7fffffff;
peekc = 0;
return (c);
}
f = standin;
/*
* something in buffer
*/
if (*f->fnxt == 0) {
f->fnxt++;
f->nxtoff++;
if (f->feval == 0)
goto retry; /* = c = readc(); */
c = EOF;
else
c = SPACE;
prc(c);
if (c == NL)
f->flin++;
return (c);
}
f->fnxt++;
f->nxtoff++;
prc(c);
if (c == NL)
f->flin++;
return (c);
}
for (i = 1; i <= mbmax; i++) {
int rest;
/*
* not enough bytes available
* f->fsiz could be BUFFERSIZE or 1
* since mbmax is enough smaller than BUFFERSIZE,
* this loop won't overrun the f->fbuf buffer.
*/
rest);
if (len == 0)
break;
}
if (mlen > 0)
break;
}
if (i > mbmax) {
/*
* enough bytes available but cannot be converted to
* a valid wchar.
*/
c = (unsigned char)*f->fnxt;
mlen = 1;
}
prwc(c);
if (c == NL)
f->flin++;
return (c);
}
c = EOF;
f->feof++;
return (c);
}
f->fdes = -1;
}
f->feof++;
c = EOF;
return (c);
}
goto retry;
}
static int
{
int len;
int fflags;
if (rest) {
/*
* copies the remaining 'rest' bytes from f->fnxt
* to f->fbuf
*/
f->nxtoff = 0;
/*
* if '\n' found, it should be
* a bondary of multibyte char.
*/
return (rest);
}
}
do {
newline();
sigchk();
newline();
chktrap();
clearup();
}
/*
* if child sets O_NDELAY or O_NONBLOCK on stdin
* and exited then turn the modes off and retry
*/
if (len == 0) {
goto retry;
}
} else if (len < 0) {
fflags &= ~O_NONBLOCK;
goto retry;
}
len = 0;
}
f->nxtoff = 0;
}