1/* sub.c: This file contains the substitution routines for the ed 2 line editor */ 3/*- 4 * Copyright (c) 1993 Andrew Moore, Talke Studio. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 13 unchanged lines hidden (view full) --- 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 */ 28 29#include <sys/cdefs.h> |
30__FBSDID("$FreeBSD: head/bin/ed/sub.c 241720 2012-10-19 05:43:38Z ed $"); |
31 32#include "ed.h" 33 34 |
35static char *rhbuf; /* rhs substitution buffer */ 36static int rhbufsz; /* rhs substitution buffer size */ 37static int rhbufi; /* rhs substitution buffer index */ |
38 39/* extract_subst_tail: extract substitution tail from the command buffer */ 40int 41extract_subst_tail(int *flagp, long *np) 42{ 43 char delimiter; 44 45 *flagp = *np = 0; --- 54 unchanged lines hidden (view full) --- 100 } 101 } 102 REALLOC(rhbuf, rhbufsz, i + 1, NULL); 103 rhbuf[rhbufi = i] = '\0'; 104 return rhbuf; 105} 106 107 |
108static char *rbuf; /* substitute_matching_text buffer */ 109static int rbufsz; /* substitute_matching_text buffer size */ |
110 111/* search_and_replace: for each line in a range, change text matching a pattern 112 according to a substitution template; return status */ 113int 114search_and_replace(pattern_t *pat, int gflag, int kth) 115{ 116 undo_t *up; 117 const char *txt; --- 137 unchanged lines hidden --- |