/* Copyright (c) 1981 Regents of the University of California */
static char *sccsid
= "@(#)ex_cmds2.c 7.1 %G%";
extern bool pflag
, nflag
; /* mjm: extern; also in ex_cmds.c */
extern int poffset
; /* mjm: extern; also in ex_cmds.c */
* Subroutines for major command loop.
* Is there a single letter indicating a named buffer next?
register int wh
= skipwh();
if (wh
&& isalpha(peekchar()))
* Tell whether the character ends a command
* Insist on the end of the command.
error("Extra chars|Extra characters at end of command");
* Print out the message in the error message file at str,
* with i an integer argument to printf.
serror(" [Warning - %s is incomplete]", file
);
* Rewind the argument list.
printf(mesg("%d files@to edit"), argc
);
* Guts of the pre-printing error processing.
* If in visual and catching errors, then we dont mung up the internals,
* just fixing up the echo area for the print.
* Otherwise we reset a number of externals, and discard unused input.
input
= strend(input
) - 1;
* We are coming out of open/visual ungracefully.
* Restore COLUMNS, undo, and fix tty mode.
/* ostop should be doing this
* Post error printing processing.
* Close the i/o file if left open.
* If catching in visual then throw to the visual catch,
* else if a child after a fork, then exit.
* Otherwise, in the normal command mode error case,
* finish state reset, and throw to top.
die
= (getpid() != ppid
); /* Only children die */
globp
= vglobp
= vmacp
= 0;
while (lastchar() != '\n' && lastchar() != EOF
)
if (Outchar
!= vputchar
) {
if (state
== ONEOPEN
|| state
== HARDOPEN
)
* Does an ! character follow in the command stream?
* Make an argument list for e.g. next.
* Advance to next file in argument list.
extern short isalt
; /* defined in ex_io.c */
error("No more files@to edit");
isalt
= (strcmp(altfile
, args
)==0) + 1;
args
= argv
? *++argv
: strend(args
) + 1;
* Eat trailing flags and offsets after a command,
* saving for possible later post-command prints.
serror("Extra chars|Extra characters at end of \"%s\" command", Command
);
* Before quit or respec of arg list, check that there are
* no more files in the arg list.
if (argc
== 0 || morargc
== argc
)
merror("%d more file", argc
);
serror("%s@to edit", plural((long) argc
));
* Before edit of new file check that either an ! follows
* or the file has not been changed.
if (chng
&& dol
> zero
) {
error("No write@since last change (:%s! overrides)", Command
);
* Reset the flavor of the output to print mode with no numbering.
* Print an error message with a %s type argument to printf.
* Message text comes from error message file.
* Set the flavor of the output based on the flags given
* and the number and list options to either number or not number lines
* and either use normally decoded (ARPAnet standard) characters or list mode,
* where end of lines are marked and tabs print as ^I.
setnumb(nflag
|| value(NUMBER
));
setlist(listf
|| value(LIST
));
* Skip white space and tell whether command ends then.
return (endcmd(peekchar()) && peekchar() != '"');
* Set the command name for non-word commands.
* Try to read off the rest of the command word.
* If alphabetics follow, then this is not the command we seek.
tailprim(comm
, i
, notinvis
)
for (cp
= tcommand
; i
> 0; i
--)
while (*comm
&& peekchar() == *comm
)
*cp
++ = getchar(), comm
++;
if (notinvis
|| isalpha(c
)) {
* Of the trailing lp funny business, only dl and dp
* survive the move from ed to ex.
if (tcommand
[0] == 'd' && any(c
, "lp"))
if (tcommand
[0] == 's' && any(c
, "gcr"))
while (cp
< &tcommand
[19] && isalpha(peekchar()))
serror("What?|%s: No such command from open/visual", tcommand
);
serror("What?|%s: Not an editor command", tcommand
);
* Continue after a : command from open/visual.
* We don't know what a shell command may have left on
* the screen, so we move the cursor to the right place
* and then put out a newline. But this makes an extra
* blank line most of the time so we only do it for :sh
* since the prompt gets left on the screen.
* BUG: :!echo longer than current line \\c
* will screw it up, but be reasonable!
merror("[Hit return to continue] ");
* Gobble ^Q/^S since the tty driver should be eating
* them (as far as the user can see)
while (peekkey() == CTRL(Q
) || peekkey() == CTRL(S
))
/* Ugh. Extra newlines, but no other way */
* Put out a newline (before a shell escape)
if (state
!= VISUAL
&& state
!= CRTOPEN
&& destline
<= WECHO
)
vclrbyte(vtube
[WECHO
], WCOLS
);
/* replaced by the ostop above