String Strim(String s) { int firstnonspace=Sfirstnotin(s," \t"); int lastnonspace=Slastnotin(s," \t"); String answer = ( firstnonspace>lastnonspace ? Snew("") : Ssub(s,firstnonspace+1,lastnonspace+2) ); // printf("%i-%i/%i\n>%s<\n>%s<\n",firstnonspace,lastnonspace,Slen(s),s,answer); return answer; }
/* * Compare two strings in a more liberal manner than Sequal(). * Spaces and tabs are equivalent. Spaces at the beginning and end of * the strings are ignored. Any number of spaces are equivalent. * Upper and lower case are equivalent. Returns 1 if the two * strings are the same. Returns zero otherwise. */ int Smatch(char *text1, char *text2) { return (Ssub(text1,text2) && Ssub(text2,text1)); }