* Copyright (c) 1980, 1993
* The Regents of the University of California. All rights reserved.
* This module is believed to contain source code proprietary to AT&T.
* Use and redistribution is subject to the Berkeley Software License
* Agreement and your Software Agreement with AT&T (Western Electric).
static char sccsid
[] = "@(#)ex_addr.c 8.1 (Berkeley) 6/9/93";
* 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 + ex_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 (inputline
&& execute(0, dot
)) {
while (loc1
<= inputline
) {
} else if (loc1
< inputline
) {
} while (loc1
< inputline
);
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 (inputline
&& c
== '?') {
inputline
= &linebuf
[LBSIZE
];
error("Fail|Pattern not found");
c
= markreg(ex_getchar());
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