1*57691Sbostic /*- 2*57691Sbostic * Copyright (c) 1992 The Regents of the University of California. 3*57691Sbostic * All rights reserved. 4*57691Sbostic * 5*57691Sbostic * This code is derived from software contributed to Berkeley by 6*57691Sbostic * Rodney Ruddock of the University of Guelph. 7*57691Sbostic * 8*57691Sbostic * %sccs.include.redist.c% 9*57691Sbostic */ 10*57691Sbostic 11*57691Sbostic #ifndef lint 12*57691Sbostic static char sccsid[] = "@(#)k.c 5.1 (Berkeley) 01/23/93"; 13*57691Sbostic #endif /* not lint */ 14*57691Sbostic 15*57691Sbostic #include "ed.h" 16*57691Sbostic 17*57691Sbostic /* 18*57691Sbostic * This the mark command (k); see ed(1). 19*57691Sbostic */ 20*57691Sbostic 21*57691Sbostic void 22*57691Sbostic set_mark(inputt, errnum) 23*57691Sbostic 24*57691Sbostic FILE *inputt; 25*57691Sbostic int *errnum; 26*57691Sbostic 27*57691Sbostic { 28*57691Sbostic int l_mark; 29*57691Sbostic 30*57691Sbostic l_mark = getc(inputt); 31*57691Sbostic if (End_default == 1) 32*57691Sbostic End = current; 33*57691Sbostic if (End == NULL) 34*57691Sbostic { 35*57691Sbostic strcpy(help_msg, "bad address"); 36*57691Sbostic *errnum = -1; 37*57691Sbostic ungetc('\n', inputt); 38*57691Sbostic return; 39*57691Sbostic } 40*57691Sbostic start_default = End_default = 0; 41*57691Sbostic 42*57691Sbostic /* the marks have to be "a" to "z" (inclusive); that is, ye olde 43*57691Sbostic * portable character set (ASCII) lower case alphabet 44*57691Sbostic */ 45*57691Sbostic if ((l_mark < 97) || (l_mark > 122) || (End == NULL)) 46*57691Sbostic { 47*57691Sbostic strcpy(help_msg, "illegal mark character"); 48*57691Sbostic *errnum = -1; 49*57691Sbostic return; 50*57691Sbostic } 51*57691Sbostic l_mark = l_mark - 97; 52*57691Sbostic (mark_matrix[l_mark].address) = End; 53*57691Sbostic 54*57691Sbostic if (rol(inputt, errnum)) 55*57691Sbostic return; 56*57691Sbostic 57*57691Sbostic *errnum = 1; 58*57691Sbostic } /* end-set_mark */ 59*57691Sbostic 60*57691Sbostic 61*57691Sbostic /* 62*57691Sbostic * This gets the address of a marked line. 63*57691Sbostic */ 64*57691Sbostic 65*57691Sbostic LINE 66*57691Sbostic *get_mark(errnum) 67*57691Sbostic 68*57691Sbostic int *errnum; 69*57691Sbostic 70*57691Sbostic { 71*57691Sbostic int l_mark; 72*57691Sbostic 73*57691Sbostic l_mark = getchar(); 74*57691Sbostic /* ditto above comment */ 75*57691Sbostic if ((l_mark < 97) || (l_mark > 122)) 76*57691Sbostic { 77*57691Sbostic strcpy(help_msg, "illegal mark character"); 78*57691Sbostic *errnum = -1; 79*57691Sbostic return(NULL); 80*57691Sbostic } 81*57691Sbostic 82*57691Sbostic l_mark = l_mark - 97; 83*57691Sbostic *errnum = 0; 84*57691Sbostic return( mark_matrix[l_mark].address ); 85*57691Sbostic } /* end-get_mark */ 86*57691Sbostic 87*57691Sbostic 88*57691Sbostic /* 89*57691Sbostic * This is for the restoration of marks during an undo. 90*57691Sbostic */ 91*57691Sbostic 92*57691Sbostic void 93*57691Sbostic ku_chk(begi, fini, val) 94*57691Sbostic 95*57691Sbostic LINE *begi, *fini, *val; 96*57691Sbostic 97*57691Sbostic { 98*57691Sbostic register int l_cnt; 99*57691Sbostic LINE *l_midd; 100*57691Sbostic 101*57691Sbostic l_midd = begi; 102*57691Sbostic while (l_midd != NULL) 103*57691Sbostic { 104*57691Sbostic for (l_cnt=0; l_cnt<26; l_cnt++) 105*57691Sbostic if (mark_matrix[l_cnt].address == l_midd) 106*57691Sbostic { 107*57691Sbostic u_add_stk(&(mark_matrix[l_cnt].address)); 108*57691Sbostic (mark_matrix[l_cnt].address) = val; 109*57691Sbostic } 110*57691Sbostic if (l_midd == fini) 111*57691Sbostic break; 112*57691Sbostic l_midd = l_midd->below; 113*57691Sbostic } /* end-while */ 114*57691Sbostic } /* end-ku_chk */ 115