* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
static char *sccsid
= "@(#)ex_addr.c 7.3 (Berkeley) %G%";
* Routines for address parsing and assignment and checking of address bounds
* in command mode. The routine address is called from ex_cmds.c
* to parse each component of a command (terminated by , ; or the beginning
* of the command itself. It is also called by the scanning routine
* in ex_voperate.c from within open/visual.
* Other routines here manipulate the externals addr1 and addr2.
* These are the first and last lines for the current command.
* The variable bigmove remembers whether a non-local glitch of . was
* involved in an address expression, so we can set the previous context
* mark '' when such a motion occurs.
* Set up addr1 and addr2 for commands whose default address is dot.
* Call setdot1 to set up default addresses without ever
* setting the previous context mark.
error("Addr1 > addr2|First address exceeds second");
* to delete 5 lines, etc.
* Such nonsense is implemented by setcount.
if (!isdigit(peekchar())) {
error("Bad count|Nonzero count required");
* Parse a number out of the command input stream.
for (cnt
= 0; isdigit(peekcd());)
cnt
= cnt
* 10 + getchar() - '0';
* Set the default addresses for commands which use the whole
* buffer as default, notably write.
* Don't want to set previous context mark so use setdot1().
* No address allowed on, e.g. the file command.
error("No address allowed@on this command");
* Just about any sequence of address characters is legal.
* If you are tricky you can use this routine and the = command
* to do simple addition and subtraction of cardinals less
* than the number of lines in the file.
error("Badly formed address");
if (inline && execute(0, dot
)) {
} else if (loc1
< inline) {
if (value(WRAPSCAN
) == 0)
error("No match to BOTTOM|Address search hit BOTTOM without matching pattern");
if (value(WRAPSCAN
) == 0)
error("No match to TOP|Address search hit TOP without matching pattern");
if (inline && c
== '?') {
inline = &linebuf
[LBSIZE
];
error("Fail|Pattern not found");
error("Marks are ' and a-z");
error("Undefined mark@referenced");
error("Negative address@- first buffer line is 1");
error("Not that many lines@in buffer");
* Abbreviations to make code smaller
* Left over from squashing ex version 1.1 into