/* * $Id: //devel/tools/main/backstealth/stripW.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. * * Wide-char version! */ #include "bscommon.h" #include "bsdefs.h" wchar_t * __stdcall stripW(wchar_t *str) { wchar_t *old = str; /* save ptr to original string */ wchar_t *lnsp = str; /* ptr to last non-space in string */ assert(str != 0); for ( ; *str; str++) if (!iswspace(*str)) lnsp = str; lnsp[1] = '\0'; return old; }