process.c (50477) | process.c (80286) |
---|---|
1/*- 2 * Copyright (c) 1992 Diomidis Spinellis. 3 * Copyright (c) 1992, 1993, 1994 4 * The Regents of the University of California. All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * Diomidis Spinellis of Imperial College, University of London. 8 * --- 26 unchanged lines hidden (view full) --- 35 * SUCH DAMAGE. 36 */ 37 38#ifndef lint 39#if 0 40static char sccsid[] = "@(#)process.c 8.6 (Berkeley) 4/20/94"; 41#endif 42static const char rcsid[] = | 1/*- 2 * Copyright (c) 1992 Diomidis Spinellis. 3 * Copyright (c) 1992, 1993, 1994 4 * The Regents of the University of California. All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * Diomidis Spinellis of Imperial College, University of London. 8 * --- 26 unchanged lines hidden (view full) --- 35 * SUCH DAMAGE. 36 */ 37 38#ifndef lint 39#if 0 40static char sccsid[] = "@(#)process.c 8.6 (Berkeley) 4/20/94"; 41#endif 42static const char rcsid[] = |
43 "$FreeBSD: head/usr.bin/sed/process.c 50477 1999-08-28 01:08:13Z peter $"; | 43 "$FreeBSD: head/usr.bin/sed/process.c 80286 2001-07-24 14:05:21Z obrien $"; |
44#endif /* not lint */ 45 46#include <sys/types.h> 47#include <sys/stat.h> 48#include <sys/ioctl.h> 49#include <sys/uio.h> 50 51#include <ctype.h> --- 56 unchanged lines hidden (view full) --- 108 continue; 109 } 110 switch (cp->code) { 111 case '{': 112 cp = cp->u.c; 113 goto redirect; 114 case 'a': 115 if (appendx >= appendnum) | 44#endif /* not lint */ 45 46#include <sys/types.h> 47#include <sys/stat.h> 48#include <sys/ioctl.h> 49#include <sys/uio.h> 50 51#include <ctype.h> --- 56 unchanged lines hidden (view full) --- 108 continue; 109 } 110 switch (cp->code) { 111 case '{': 112 cp = cp->u.c; 113 goto redirect; 114 case 'a': 115 if (appendx >= appendnum) |
116 appends = xrealloc(appends, | 116 if ((appends = realloc(appends, |
117 sizeof(struct s_appends) * | 117 sizeof(struct s_appends) * |
118 (appendnum *= 2)); | 118 (appendnum *= 2))) == NULL) 119 err(1, "realloc"); |
119 appends[appendx].type = AP_STRING; 120 appends[appendx].s = cp->t; 121 appends[appendx].len = strlen(cp->t); 122 appendx++; 123 break; 124 case 'b': 125 cp = cp->u.c; 126 goto redirect; --- 69 unchanged lines hidden (view full) --- 196 break; 197 case 'q': 198 if (!nflag && !pd) 199 OUT(ps) 200 flush_appends(); 201 exit(0); 202 case 'r': 203 if (appendx >= appendnum) | 120 appends[appendx].type = AP_STRING; 121 appends[appendx].s = cp->t; 122 appends[appendx].len = strlen(cp->t); 123 appendx++; 124 break; 125 case 'b': 126 cp = cp->u.c; 127 goto redirect; --- 69 unchanged lines hidden (view full) --- 197 break; 198 case 'q': 199 if (!nflag && !pd) 200 OUT(ps) 201 flush_appends(); 202 exit(0); 203 case 'r': 204 if (appendx >= appendnum) |
204 appends = xrealloc(appends, | 205 if ((appends = realloc(appends, |
205 sizeof(struct s_appends) * | 206 sizeof(struct s_appends) * |
206 (appendnum *= 2)); | 207 (appendnum *= 2))) == NULL) 208 err(1, "realloc"); |
207 appends[appendx].type = AP_FILE; 208 appends[appendx].s = cp->t; 209 appends[appendx].len = strlen(cp->t); 210 appendx++; 211 break; 212 case 's': 213 sdone |= substitute(cp); 214 break; --- 328 unchanged lines hidden (view full) --- 543 char *string, *src; 544{ 545 register int len, no; 546 register char c, *dst; 547 548#define NEEDSP(reqlen) \ 549 if (sp->len >= sp->blen - (reqlen) - 1) { \ 550 sp->blen += (reqlen) + 1024; \ | 209 appends[appendx].type = AP_FILE; 210 appends[appendx].s = cp->t; 211 appends[appendx].len = strlen(cp->t); 212 appendx++; 213 break; 214 case 's': 215 sdone |= substitute(cp); 216 break; --- 328 unchanged lines hidden (view full) --- 545 char *string, *src; 546{ 547 register int len, no; 548 register char c, *dst; 549 550#define NEEDSP(reqlen) \ 551 if (sp->len >= sp->blen - (reqlen) - 1) { \ 552 sp->blen += (reqlen) + 1024; \ |
551 sp->space = sp->back = xrealloc(sp->back, sp->blen); \ | 553 if ((sp->space = sp->back = realloc(sp->back, sp->blen)) \ 554 == NULL) \ 555 err(1, "realloc"); \ |
552 dst = sp->space + sp->len; \ 553 } 554 555 dst = sp->space + sp->len; 556 while ((c = *src++) != '\0') { 557 if (c == '&') 558 no = 0; 559 else if (c == '\\' && isdigit((unsigned char)*src)) --- 31 unchanged lines hidden (view full) --- 591 enum e_spflag spflag; 592{ 593 size_t tlen; 594 595 /* Make sure SPACE has enough memory and ramp up quickly. */ 596 tlen = sp->len + len + 1; 597 if (tlen > sp->blen) { 598 sp->blen = tlen + 1024; | 556 dst = sp->space + sp->len; \ 557 } 558 559 dst = sp->space + sp->len; 560 while ((c = *src++) != '\0') { 561 if (c == '&') 562 no = 0; 563 else if (c == '\\' && isdigit((unsigned char)*src)) --- 31 unchanged lines hidden (view full) --- 595 enum e_spflag spflag; 596{ 597 size_t tlen; 598 599 /* Make sure SPACE has enough memory and ramp up quickly. */ 600 tlen = sp->len + len + 1; 601 if (tlen > sp->blen) { 602 sp->blen = tlen + 1024; |
599 sp->space = sp->back = xrealloc(sp->back, sp->blen); | 603 if ((sp->space = sp->back = realloc(sp->back, sp->blen)) == 604 NULL) 605 err(1, "realloc"); |
600 } 601 602 if (spflag == REPLACE) 603 sp->len = 0; 604 605 memmove(sp->space + sp->len, p, len); 606 607 sp->space[sp->len += len] = '\0'; --- 27 unchanged lines hidden --- | 606 } 607 608 if (spflag == REPLACE) 609 sp->len = 0; 610 611 memmove(sp->space + sp->len, p, len); 612 613 sp->space[sp->len += len] = '\0'; --- 27 unchanged lines hidden --- |