
/*
 * trimcpy.c -- strip [lt]wsp and replace newlines with spaces
 *
 * $Id$
 */

#include <h/mh.h>


char *
trimcpy (char *cp)
{
    register char *sp;

    while (isspace (*cp))
	cp++;
    for (sp = cp + strlen (cp) - 1; sp >= cp; sp--)
	if (isspace (*sp))
	    *sp = 0;
	else
	    break;
    for (sp = cp; *sp; sp++)
	if (isspace (*sp))
	    *sp = ' ';

    return getcpy (cp);
}
