All pastes #1195233 Raw Edit

Mine

public c v1 · immutable
#1195233 ·published 2008-09-05 21:49 UTC
rendered paste body
char* appends( char* str, char* text ) {	// not allocated!	if ( !str ) { 		str = malloc( strlen( text ) + 1 );		strcpy( str, text );		return str;	}			int size = ( ( strlen( str ) + strlen( text ) ) ) + 2;	str = realloc( str, size );	strcat( str, text );	return str;}char* HTMLEntities( char* input ) {	int i;	int length = strlen( input );	char* copy = NULL;	for( i = 0; i < length; i++ ){		switch( input[i] ) {			case '<':   copy = appends( copy, "&lt;" ); break;			case '>':   copy = appends( copy, "&gt;" ); break;			case '&':   copy = appends( copy, "&amp;" ); break;			case '"':   copy = appends( copy, "&quot;" ); break;			case '\'':  copy = appends( copy, "&apos;" ); break;			default:    copy = appendc( copy, input[i] ); break;		}	}	return copy;}