* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
static char sccsid
[] = "@(#)ex_print.c 8.6 (Berkeley) 11/2/93";
* ex_list -- :[line [,line]] l[ist] [count] [flags]
* Display the addressed lines such that the output is unambiguous.
&cmdp
->addr1
, &cmdp
->addr2
, cmdp
->flags
| E_F_LIST
))
sp
->lno
= cmdp
->addr2
.lno
;
sp
->cno
= cmdp
->addr2
.cno
;
* ex_number -- :[line [,line]] nu[mber] [count] [flags]
* Display the addressed lines with a leading line number.
&cmdp
->addr1
, &cmdp
->addr2
, cmdp
->flags
| E_F_HASH
))
sp
->lno
= cmdp
->addr2
.lno
;
sp
->cno
= cmdp
->addr2
.cno
;
* ex_pr -- :[line [,line]] p[rint] [count] [flags]
* Display the addressed lines.
if (ex_print(sp
, ep
, &cmdp
->addr1
, &cmdp
->addr2
, cmdp
->flags
))
sp
->lno
= cmdp
->addr2
.lno
;
sp
->cno
= cmdp
->addr2
.cno
;
* Print the selected lines.
ex_print(sp
, ep
, fp
, tp
, flags
)
register int ch
, col
, rlen
;
F_SET(sp
, S_INTERRUPTIBLE
);
for (from
= fp
->lno
, to
= tp
->lno
; from
<= to
; ++from
) {
/* Display the line number. */
col
= ex_printf(EXCOOKIE
, "%7ld ", from
);
* Display the line. The format for E_F_PRINT isn't very good,
* especially in handling end-of-line tabs, but they're almost
if ((p
= file_gline(sp
, ep
, from
, &len
)) == NULL
) {
(void)ex_printf(EXCOOKIE, "\n"); \
(void)ex_printf(EXCOOKIE, "%c", ch); \
for (rlen
= len
; rlen
--;) {
if (ch
!= '\t' && isprint(ch
)) {
sizeof(buf
), "\\%03o", ch
);
for (cnt
= 0; cnt
< len
; ++cnt
)
++col
% O_VAL(sp
, O_TABSTOP
))
(void)ex_printf(EXCOOKIE
, " ");
(void)ex_printf(EXCOOKIE
, "\n");
} else if (isprint(ch
)) {
(void)ex_printf(EXCOOKIE
, "\n");
if (LF_ISSET(E_F_LIST
)) {
* If the line is empty, output a space
* to overwrite the colon prompt.
(void)ex_printf(EXCOOKIE
, "\n");
if (F_ISSET(sp
, S_INTERRUPTED
))