cmd/sed/process.c
/*
 * Flush append requests.  Always called before reading a line,
 * therefore it also resets the substitution done (sdone) flag.
 */
Flush append requests.  Always called before reading a line,
therefore it also resets the substitution done (sdone) flag.
Flush append requests . Always called before reading a line therefore it also resets the substitution done ( sdone ) flag .
static void
flush_appends()
{
	FILE *f;
	int count, i;
	char buf[8 * 1024];
	for (i = 0; i < appendx; i++) 
		switch (appends[i].type) {
		case AP_STRING:
			fwrite(appends[i].s, sizeof(char), appends[i].len, 
			    stdout);
			break;
		case AP_FILE:
			if ((f = fopen(appends[i].s, "r")) == NULL)
				break;
			while (count = fread(buf, sizeof(char), sizeof(buf), f))
				(void)fwrite(buf, sizeof(char), count, stdout);
			(void)fclose(f);
			break;
		}
	if (ferror(stdout))
		err(FATAL, "stdout: %s", strerror(errno ? errno : EIO));
	appendx = sdone = 0;
}
static void flush_appends ( ) { FILE * f ; int count , i ; char buf [ 8 * 1024 ] ; for ( i = 0 ; i < appendx ; i ++ ) switch ( appends [ i ] . type ) { case AP_STRING : fwrite ( appends [ i ] . s , sizeof ( char ) , appends [ i ] . len , stdout ) ; break ; case AP_FILE : if ( ( f = fopen ( appends [ i ] . s , " " ) ) == NULL ) break ; while ( count = fread ( buf , sizeof ( char ) , sizeof ( buf ) , f ) ) ( void ) fwrite ( buf , sizeof ( char ) , count , stdout ) ; ( void ) fclose ( f ) ; break ; } if ( ferror ( stdout ) ) err ( FATAL , " " , strerror ( errno ? errno : EIO ) ) ; appendx = sdone = 0 ; }
Flush append requests.
Flush append requests .
/*
			 * Read files probably shouldn't be cached.  Since
			 * it's not an error to read a non-existent file,
			 * it's possible that another program is interacting
			 * with the sed script through the file system.  It
			 * would be truly bizarre, but possible.  It's probably
			 * not that big a performance win, anyhow.
			 */