ex_cmds.c revision 68c92b9f236192fc4b1af4355a207acf7469bd59
4ff39ece92375d317f59ac6424ee301e1603bdc8Andi Egloff * CDDL HEADER START
d0840514601c4eea1672996b07b27ca61bd4197dLaszlo Hordos * The contents of this file are subject to the terms of the
4ff39ece92375d317f59ac6424ee301e1603bdc8Andi Egloff * Common Development and Distribution License (the "License").
4ff39ece92375d317f59ac6424ee301e1603bdc8Andi Egloff * You may not use this file except in compliance with the License.
4ff39ece92375d317f59ac6424ee301e1603bdc8Andi Egloff * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
4ff39ece92375d317f59ac6424ee301e1603bdc8Andi Egloff * See the License for the specific language governing permissions
4ff39ece92375d317f59ac6424ee301e1603bdc8Andi Egloff * and limitations under the License.
4ff39ece92375d317f59ac6424ee301e1603bdc8Andi Egloff * When distributing Covered Code, include this CDDL HEADER in each
4ff39ece92375d317f59ac6424ee301e1603bdc8Andi Egloff * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
4ff39ece92375d317f59ac6424ee301e1603bdc8Andi Egloff * If applicable, add the following below this CDDL HEADER, with the
4ff39ece92375d317f59ac6424ee301e1603bdc8Andi Egloff * fields enclosed by brackets "[]" replaced with your own identifying
4ff39ece92375d317f59ac6424ee301e1603bdc8Andi Egloff * information: Portions Copyright [yyyy] [name of copyright owner]
4ff39ece92375d317f59ac6424ee301e1603bdc8Andi Egloff * CDDL HEADER END
4ff39ece92375d317f59ac6424ee301e1603bdc8Andi Egloff * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
4ff39ece92375d317f59ac6424ee301e1603bdc8Andi Egloff * Use is subject to license terms.
4ff39ece92375d317f59ac6424ee301e1603bdc8Andi Egloff/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
4ff39ece92375d317f59ac6424ee301e1603bdc8Andi Egloff/* All Rights Reserved */
77b80fa07dbd56fab6c74619beffb82060990cddAndi Egloff/* Copyright (c) 1981 Regents of the University of California */
d0840514601c4eea1672996b07b27ca61bd4197dLaszlo Hordos#pragma ident "%Z%%M% %I% %E% SMI"
d0840514601c4eea1672996b07b27ca61bd4197dLaszlo Hordos * Main loop for command mode command decoding.
d0840514601c4eea1672996b07b27ca61bd4197dLaszlo Hordos * A few commands are executed here, but main function
d0840514601c4eea1672996b07b27ca61bd4197dLaszlo Hordos * is to strip command addresses, do a little address oriented
d0840514601c4eea1672996b07b27ca61bd4197dLaszlo Hordos * processing and call command routines to do the real work.
d0840514601c4eea1672996b07b27ca61bd4197dLaszlo Hordosextern unsigned char *Version;
4cfdd3a9ed0c109f4d3b7a1c6e5c6db3fb3ea951Chad Kienle#endif /* XPG4 */
d0840514601c4eea1672996b07b27ca61bd4197dLaszlo Hordos unsigned char *vgetpass();
shudclob = 0;
pflag = 0;
nochng();
poffset = 0;
setdot1();
goto print;
nochng();
if (inglobal == 0) {
flush();
TSYNC();
addr2 = 0;
c = getcd();
if (addr == 0) {
else if (addr1 != 0) {
given++;
c = getchar();
if (addr1 == 0)
c = getchar();
tailspec(c);
if (inopen) {
if (addr2)
if (c == EOF)
switch (peekchar()) {
setnoaddr();
setnoaddr();
eol();
pargs();
if (inopen)
goto notinvis;
setdot();
donewline();
vmacchng(0);
deletenone();
inappend = 0;
nochng();
switch (peekchar()) {
vmacchng(0);
vi_move();
setnoaddr();
if (permflag)
xflag = 0;
kflag = 0;
crflag = 0;
if (kflag == 0)
crflag = 0;
goto changdir;
ignchar();
(void) exclam();
(void) quickly();
if (skipend()) {
if (p == NULL)
eol();
if (chdir((char *)p) < 0)
filioerr(p);
edited = 0;
if (inopen)
if (inopen)
goto notinvis;
#ifdef XPG4ONLY
setcount2();
donewline();
setCNL();
vmacchng(0);
(void) delete(0);
#ifdef XPG4
inappend = 0;
nochng();
c = cmdreg();
#ifdef XPG4ONLY
setcount2();
donewline();
setCNL();
vmacchng(0);
(void) YANKreg(c);
(void) delete(0);
appendnone();
gotfile = 0;
filename(c);
if (!exclam()) {
ckaw();
xchng = 0;
Command);
if (gotfile == 0)
filename(c);
setnoaddr();
init();
laste++;
sync();
rop(c);
nochng();
setnoaddr();
filename(c);
noonl();
nochng();
if (inopen)
goto notinvis;
setdot();
nonzero();
donewline();
vmacchng(0);
deletenone();
inappend = 0;
nochng();
c = exclam();
setcount();
nonzero();
donewline();
vmacchng(0);
#ifdef XPG4ONLY
addr2++;
addr2++;
(void) join(c);
pastwh();
c = getchar();
if (endcmd(c))
donewline();
if (!islower(c))
setdot();
nonzero();
#ifdef XPG4ONLY
setcount2();
donewline();
setCNL();
pflag = 0;
goto print;
ignchar();
setnoaddr();
mapcmd(0, 0);
goto casek;
vmacchng(0);
vi_move();
goto numberit;
setnoaddr();
if (!exclam()) {
ckaw();
xchng = 0;
Command);
if (getargs())
makargs();
next();
filename(c);
goto doecmd;
oop();
pflag = 0;
nochng();
switch (peekchar()) {
#ifdef TAG_STACK
if (!inopen)
nochng();
setdot();
c = cmdreg();
eol();
vmacchng(0);
(void) putreg(c);
(void) put();
ignchar();
eol();
if (preserve() == 0)
#ifdef XPG4
setCNL();
pflag = 0;
nonzero();
flush1();
vclear();
if (poffset == 0)
setnoaddr();
c = quickly();
eol();
quit:
if (nomore())
if (inopen) {
if (!ateopr())
vnfl();
tostop();
flush();
ignchar();
switch (peekchar()) {
setnoaddr();
if (!exclam()) {
ckaw();
eol();
erewind();
next();
filename(c);
goto doecmd;
setnoaddr();
filename(c);
(void) quickly();
init();
laste++;
sync();
recover();
rop2();
revocer();
if (status == 0)
rop3(c);
change();
nochng();
pastwh();
vmacchng(0);
setdot();
ignchar();
(void) vi_filter(0);
filename(c);
rop(c);
nochng();
switch (peekchar()) {
setnoaddr();
set();
setNAEOL();
vnfl();
flush();
resetterm();
vcontin(0);
#ifdef notdef
if (inopen)
goto notinvis;
setnoaddr();
getone();
eol();
#ifdef SIGTSTP
goto suspend;
#ifdef XPG4
switch (d = peekchar()) {
c = exclam();
eol();
ckaw();
onsusp(0);
#ifdef XPG4
vmacchng(0);
if (!substitute(c))
pflag = 0;
tagflg = 0;
if (!inopen)
nochng();
vmacchng(0);
vi_move();
ignchar();
switch (peekchar()) {
setnoaddr();
setnoaddr();
setnoaddr();
markDOT();
c = exclam();
donewline();
undo(c);
switch (peekchar()) {
setNAEOL();
noonl();
if (inopen) {
goto editcmd;
vop();
pflag = 0;
nochng();
global(0);
nochng();
c = peekchar();
wq:
pofix();
ignchar();
setall();
setall();
write_quit = 0;
nochng();
goto quit;
goto ent_crypt;
goto ent_crypt;
if (!chng)
goto quit;
goto wq;
c = cmdreg();
#ifdef XPG4ONLY
setcount2();
setcount();
eol();
vmacchng(0);
(void) YANKreg(c);
(void) yank();
zop(0);
pflag = 0;
c = getchar();
ungetchar(c);
c = lastmac;
if (isupper(c))
c = tolower(c);
if (!islower(c))
donewline();
setdot();
cmdmac(c);
endline = 0;
goto caseline;
notempty();
if (addr2 == 0) {
!inglobal)
if (inglobal)
setdot();
nonzero();
if (seensemi)
flush1();
destline--;
if (hadpr)
comment();
setCNL();
pflag = 0;
goto print;
donewline();
setall();
pofix();
noonl();
if (addr2 != 0) {
vmacchng(0);
setdot();
pofix();
flush();
resetterm();
if (!tagflg) {
nochng();
ignchar();
setCNL();
vmacchng(0);
case EOF:
if (exitoneof) {
if (addr2 != 0)
if (!isatty(0)) {
if (intty)
onhup(0);
if (addr2 != 0) {
putnl();
if (addr2 == 0)
putnl();
notempty();
ungetchar(c);
ungetchar(c);
int length;
if (length < 0)
multic);