evolve4src/src/evolve_simulator/phascii.cpp
char *Phascii_MakeString(char *buf)
{
	char *p, *q, *newp;
	int count;

	count = 0;
	for(p=buf; *p; p++) {
		count++;
		if( *p == '\a' ) count++;
		else if( *p == '\b' ) count++;
		else if( *p == '\f' ) count++;
		else if( *p == '\n' ) count++;
		else if( *p == '\r' ) count++;
		else if( *p == '\t' ) count++;
		else if( *p == '\v' ) count++;
		else if( *p == '"' ) count++;
		else if( *p == '\\' ) count++;
	}

	newp = (char*) malloc( count+3 );

	p=buf;
	q=newp;
	*q++ = '"';
	while( *p ) {
		if( strchr("\a\b\f\n\r\t\v\"\\", *p) ) {
			*q++ = '\\';

			switch( *p ) {
			case '\a':	*q++ = 'a'; break;
			case '\b':	*q++ = 'b'; break;
			case '\f':	*q++ = 'f'; break;
			case '\n':	*q++ = 'n'; break;
			case '\r':	*q++ = 'r'; break;
			case '\t':	*q++ = 't'; break;
			case '\v':	*q++ = 'v'; break;
			case '"':	*q++ = '"'; break;
			case '\\':	*q++ = '\\'; break;
			}
			p++;
		} else
			*q++ = *p++;
	}
	*q++ = '"';
	*q = '\0';

	return newp;
}
/***********************************************************************
 * Phascii_Makestring(char *):
 *
 * This function is for people WRITTING out photon ascii files. Often
 * a string it to be generated, this function makes it easy to
 * build a string that is SAFE for reading again.
 *
 * Create a string that contains the same information
 * as buf, except the new string is surrounded by double quotes, and
 * the following characters will be converted to proper config escape
 * sequences:
 *
 *	THIS CHAR IS		CONVERT TO THIS SEQUENCE
 *	double quote (")	\"
 *	back slash (\)		\\
 *	bell			\a
 *	backspace		\b
 *	carrage return		\r
 *	new page		\v
 *	newline			\n
 *	tab			\t
 *
 * If the input string contains bogus characters, then the output
 * string may not be readable by the Phascii_XXXX() routines.
 */
Phascii_Makestring(char *):
This function is for people WRITTING out photon ascii files. Often
a string it to be generated, this function makes it easy to
build a string that is SAFE for reading again.

Create a string that contains the same information
as buf, except the new string is surrounded by double quotes, and
the following characters will be converted to proper config escape
sequences.



If the input string contains bogus characters, then the output
string may not be readable by the Phascii_XXXX() routines.
Phascii_Makestring ( char * ) : This function is for people WRITTING out photon ascii files . Often a string it to be generated this function makes it easy to build a string that is SAFE for reading again . Create a string that contains the same information as buf except the new string is surrounded by double quotes and the following characters will be converted to proper config escape sequences . If the input string contains bogus characters then the output string may not be readable by the Phascii_XXXX () routines .
char *Phascii_MakeString(char *buf)
{
	char *p, *q, *newp;
	int count;
	count = 0;
	for(p=buf; *p; p++) {
		count++;
		if( *p == '\a' ) count++;
		else if( *p == '\b' ) count++;
		else if( *p == '\f' ) count++;
		else if( *p == '\n' ) count++;
		else if( *p == '\r' ) count++;
		else if( *p == '\t' ) count++;
		else if( *p == '\v' ) count++;
		else if( *p == '"' ) count++;
		else if( *p == '\\' ) count++;
	}
	newp = (char*) malloc( count+3 );
	p=buf;
	q=newp;
	*q++ = '"';
	while( *p ) {
		if( strchr("\a\b\f\n\r\t\v\"\\", *p) ) {
			*q++ = '\\';
			switch( *p ) {
			case '\a':	*q++ = 'a'; break;
			case '\b':	*q++ = 'b'; break;
			case '\f':	*q++ = 'f'; break;
			case '\n':	*q++ = 'n'; break;
			case '\r':	*q++ = 'r'; break;
			case '\t':	*q++ = 't'; break;
			case '\v':	*q++ = 'v'; break;
			case '"':	*q++ = '"'; break;
			case '\\':	*q++ = '\\'; break;
			}
			p++;
		} else
			*q++ = *p++;
	}
	*q++ = '"';
	*q = '\0';
	return newp;
}
char * Phascii_MakeString ( char * buf ) { char * p , * q , * newp ; int count ; count = 0 ; for ( p = buf ; * p ; p ++ ) { count ++ ; if ( * p == ' \a ' ) count ++ ; else if ( * p == ' \b ' ) count ++ ; else if ( * p == ' \f ' ) count ++ ; else if ( * p == ' \n ' ) count ++ ; else if ( * p == ' \r ' ) count ++ ; else if ( * p == ' \t ' ) count ++ ; else if ( * p == ' \v ' ) count ++ ; else if ( * p == ' ' ) count ++ ; else if ( * p == ' \\ ' ) count ++ ; } newp = ( char * ) malloc ( count + 3 ) ; p = buf ; q = newp ; * q ++ = ' ' ; while ( * p ) { if ( strchr ( " \a \b \f \n \r \t \v \" \\ " , * p ) ) { * q ++ = ' \\ ' ; switch ( * p ) { case ' \a ' : * q ++ = ' ' ; break ; case ' \b ' : * q ++ = ' ' ; break ; case ' \f ' : * q ++ = ' ' ; break ; case ' \n ' : * q ++ = ' ' ; break ; case ' \r ' : * q ++ = ' ' ; break ; case ' \t ' : * q ++ = ' ' ; break ; case ' \v ' : * q ++ = ' ' ; break ; case ' ' : * q ++ = ' ' ; break ; case ' \\ ' : * q ++ = ' \\ ' ; break ; } p ++ ; } else * q ++ = * p ++ ; } * q ++ = ' ' ; * q = ' \0 ' ; return newp ; }
Phascii_Makestring(char *):
 This function is for people WRITTING out photon ascii files.
Phascii_Makestring ( char * ) : This function is for people WRITTING out photon ascii files .