# HG changeset patch # User tuomov # Date 978712297 -3600 # Node ID 7e74a8d61b764cce8192c6e134cbe994bd91a927 # Parent e9cad8bd8ec810647baf222b28b6f93ac0898e9b trunk: changeset 35 Added 'stripws'. diff -r e9cad8bd8ec8 -r 7e74a8d61b76 include/libtu/misc.h --- a/include/libtu/misc.h Tue Jan 02 01:45:46 2001 +0100 +++ b/include/libtu/misc.h Fri Jan 05 17:31:37 2001 +0100 @@ -29,6 +29,7 @@ extern char* scat(const char *p1, const char *p2); extern char* scatn(const char *p1, ssize_t n1, const char *p2, ssize_t n2); extern char* scat3(const char *p1, const char *p2, const char *p3); +extern void stripws(char *p); extern const char* simple_basename(const char *name); diff -r e9cad8bd8ec8 -r 7e74a8d61b76 misc.c --- a/misc.c Tue Jan 02 01:45:46 2001 +0100 +++ b/misc.c Fri Jan 05 17:31:37 2001 +0100 @@ -160,6 +160,23 @@ } +void stripws(char *p) +{ + int l; + + l=strspn(p, " "); + if(l!=0) + strcpy(p, p+l); + l=strlen(p); + + while(--l>=0){ + if(*(p+l)!=' ') + break; + } + *(p+l+1)='\0'; +} + + /* */