1 /*- 2 * Copyright (c) 1992, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Rodney Ruddock of the University of Guelph. 7 * 8 * %sccs.include.redist.c% 9 */ 10 11 #ifndef lint 12 static char sccsid[] = "@(#)z.c 8.1 (Berkeley) 05/31/93"; 13 #endif /* not lint */ 14 15 #include <sys/types.h> 16 17 #include <regex.h> 18 #include <setjmp.h> 19 #include <stdio.h> 20 #include <string.h> 21 22 #ifdef DBI 23 #include <db.h> 24 #endif 25 26 #include "ed.h" 27 #include "extern.h" 28 29 /* 30 * This prints out the next group of lines (as spec'd by the skicky 31 * number; 22 by default). It's really useful for scrolling in chunks 32 * through the buffer (better than l, n, or p). Shame on POSIX for 33 * not including it; yaaa! BSD for keeping it! :-) 34 */ 35 void 36 z(inputt, errnum) 37 FILE *inputt; 38 int *errnum; 39 { 40 register int l_cnt; 41 42 if (current == NULL) { 43 *errnum = -1; 44 strcpy(help_msg, "buffer empty"); 45 return; 46 } 47 /* Set zsnum if need be here. */ 48 ss = getc(inputt); 49 if ((ss > 48) && (ss < 57)) 50 /* Default set in main. */ 51 zsnum = dig_num_conv(inputt, errnum); 52 else 53 if ((ss != '\n') && (ss != EOF)) { 54 ungetc(ss, inputt); 55 if (rol(inputt, errnum)) 56 return; 57 } 58 if (top == NULL) { 59 strcpy(help_msg, "buffer empty"); 60 *errnum = -1; 61 ungetc('\n', inputt); 62 return; 63 } 64 if (End_default) { 65 if ((current->below) != NULL) 66 Start = current->below; 67 else { 68 strcpy(help_msg, "at end of buffer"); 69 *errnum = -1; 70 ungetc('\n', inputt); 71 return; 72 } 73 } else 74 Start = End; 75 if (Start == NULL) { 76 strcpy(help_msg, "bad address"); 77 *errnum = -1; 78 ungetc('\n', inputt); 79 return; 80 } 81 Start_default = End_default = 0; 82 83 current = Start; 84 l_cnt = 1; /* Yes, set to = 1. */ 85 while (1) { 86 /* Scroll-out the next 'zsnum' of lines or until bottom. */ 87 if (current == NULL) 88 break; 89 if (sigint_flag && (!sigspecial)) 90 SIGINT_ACTION; 91 get_line(current->handle, current->len); 92 printf("%s\n", text); 93 if (current == bottom) 94 break; 95 l_cnt++; 96 if (zsnum < l_cnt) 97 break; 98 current = current->below; 99 } 100 *errnum = 1; 101 } 102