usr.bin/sed/compile.c
/*
 * Compile the text following an a or i command.
 */
Compile the text following an a or i command.
Compile the text following an a or i command .
static char *
compile_text()
{
	int asize, size;
	char *text, *p, *op, *s;
	char lbuf[_POSIX2_LINE_MAX + 1];
	asize = 2 * _POSIX2_LINE_MAX + 1;
	text = xmalloc(asize);
	size = 0;
	while (cu_fgets(lbuf, sizeof(lbuf))) {
		op = s = text + size;
		p = lbuf;
		EATSPACE();
		for (; *p; p++) {
			if (*p == '\\')
				p++;
			*s++ = *p;
		}
		size += s - op;
		if (p[-2] != '\\') {
			*s = '\0';
			break;
		}
		if (asize - size < _POSIX2_LINE_MAX + 1) {
			asize *= 2;
			text = xmalloc(asize);
		}
	}
	return (xrealloc(text, size + 1));
}
static char * compile_text ( ) { int asize , size ; char * text , * p , * op , * s ; char lbuf [ _POSIX2_LINE_MAX + 1 ] ; asize = 2 * _POSIX2_LINE_MAX + 1 ; text = xmalloc ( asize ) ; size = 0 ; while ( cu_fgets ( lbuf , sizeof ( lbuf ) ) ) { op = s = text + size ; p = lbuf ; EATSPACE ( ) ; for ( ; * p ; p ++ ) { if ( * p == ' \\ ' ) p ++ ; * s ++ = * p ; } size += s - op ; if ( p [ -2 ] != ' \\ ' ) { * s = ' \0 ' ; break ; } if ( asize - size < _POSIX2_LINE_MAX + 1 ) { asize *= 2 ; text = xmalloc ( asize ) ; } } return ( xrealloc ( text , size + 1 ) ) ; }
Compile the text following an a or i command.
Compile the text following an a or i command .