*/
void strproc(char *string)
{
- int a;
+ int a, b;
if (string == NULL) return;
if (IsEmptyStr(string)) return;
if (string[a]>126) string[a]=32;
}
+ /* a is now the length of our string. */
/* Remove leading and trailing blanks */
- while( (string[0]<33) && (!IsEmptyStr(string)) )
- strcpy(string,&string[1]);
- while( (string[strlen(string)-1]<33) && (!IsEmptyStr(string)) )
- string[strlen(string)-1]=0;
+ while( (string[a-1]<33) && (!IsEmptyStr(string)) )
+ string[--a]=0;
+ b = 0;
+ while( (string[b]<33) && (!IsEmptyStr(&string[b])) )
+ b++;
+ if (b > 0)
+ memmove(string,&string[b], a - b + 1);
/* Remove double blanks */
for (a=0; !IsEmptyStr(&string[a]); ++a) {
*/
void striplt(char *buf)
{
+ size_t len;
+ int a;
if (IsEmptyStr(buf)) return;
- while ((!IsEmptyStr(buf)) && (isspace(buf[0])))
- strcpy(buf, &buf[1]);
+ len = strlen(buf);
+ while ((!IsEmptyStr(buf)) && (isspace(buf[len - 1])))
+ buf[--len] = 0;
if (IsEmptyStr(buf)) return;
- while ((!IsEmptyStr(buf)) && (isspace(buf[strlen(buf) - 1])))
- buf[strlen(buf) - 1] = 0;
+ a = 0;
+ while ((!IsEmptyStr(buf)) && (isspace(buf[a])))
+ a++;
+ if (a > 0)
+ memmove(buf, &buf[a], len - a + 1);
}
char IndexBuf[32];
int IndexLen = 0;
+ memset (IndexBuf, 0, sizeof (IndexBuf));
/* Generate an index */
IndexLen = GenerateRelationshipIndex(IndexBuf,
newvisit->v_roomnum,