/* * $Id: //devel/tools/main/backstealth/stripA.cpp#1 $ * * written by: Stephen J. Friedl * Software Consultant * Tustin, California USA * steve@unixwiz.net * * Remove trailing whitespace from the given string and return the * newly-shortened string to the caller. We consider "whitespace" to * be anything for which "isspace()" is true. */ #include "bscommon.h" #include #include "bsdefs.h" char * __stdcall stripA(char *str) { char *old = str; /* save ptr to original string */ char *lnsp = str; /* ptr to last non-space in string */ assert(str != 0); for ( ; *str; str++) if (!isspace(*str)) lnsp = str; lnsp[1] = '\0'; return old; }