From: boca4711 <boc...@us...> - 2005-05-08 11:03:25
|
Update of /cvsroot/anyedit/AnyEditv2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5245 Modified Files: Misc.cpp Misc.h Log Message: Add: NormalizeStrings deletes leading & trailing blanks, double blanks, newlines Index: Misc.cpp =================================================================== RCS file: /cvsroot/anyedit/AnyEditv2/Misc.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Misc.cpp 23 Sep 2004 21:30:44 -0000 1.13 --- Misc.cpp 8 May 2005 11:03:03 -0000 1.14 *************** *** 534,535 **** --- 534,571 ---- return false; } + + /* -------------------------------------------------------------------- */ + /* normalizeString() deletes leading & trailing blanks etc. */ + /* coverd from Fred's Citadel BBS */ + /* http://sourceforge.net/projects/fredcit */ + /* FORMAT.C */ + /* -------------------------------------------------------------------- */ + void CMisc::NormalizeString(char *s) + { + char *pc; + + pc = s; + + /* find end of string */ + while (*pc) { + if (*pc < ' ' && (*pc != 1)) /* less then space & not ^A */ + *pc = ' '; /* zap tabs etc... */ + pc++; + } + + /* no trailing spaces: */ + while (pc > s && isspace(*(pc - 1))) + pc--; + *pc = '\0'; + + /* no leading spaces: */ + while (isspace(*s)) + strcpy(s, s + 1); + + /* no double blanks */ + for (; *s;) + if (isspace(*s) && isspace(*(s + 1))) + strcpy(s, s + 1); + else + s++; + } Index: Misc.h =================================================================== RCS file: /cvsroot/anyedit/AnyEditv2/Misc.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Misc.h 23 Sep 2004 21:30:44 -0000 1.11 --- Misc.h 8 May 2005 11:03:03 -0000 1.12 *************** *** 15,18 **** --- 15,19 ---- { public: + void NormalizeString(char *s); BOOL ShortToLongPath(CString &sShortPath, CString &sLongPath); CString RemovePath(LPCTSTR filName); |