Commit 33b7f918 authored by rswindell's avatar rswindell
Browse files

Created skipsp() to return a pointer to the first non white-space character in

the passed string.
Using isspace() in truncsp().
parent 50125626
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2006 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2007 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License *
......@@ -497,6 +497,15 @@ clock_t DLLCALL msclock(void)
}
#endif
/****************************************************************************/
/* Skips all white-space chars at beginning of 'str' */
/****************************************************************************/
char* DLLCALL skipsp(char* str)
{
SKIP_WHITESPACE(str);
return(str);
}
/****************************************************************************/
/* Truncates all white-space chars off end of 'str' (needed by STRERRROR) */
/****************************************************************************/
......@@ -505,7 +514,7 @@ char* DLLCALL truncsp(char* str)
size_t i,len;
i=len=strlen(str);
while(i && (str[i-1]==' ' || str[i-1]=='\t' || str[i-1]=='\r' || str[i-1]=='\n'))
while(i && isspace(str[i-1]))
i--;
if(i!=len)
str[i]=0; /* truncate */
......
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2006 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2007 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License *
......@@ -184,6 +184,8 @@ extern "C" {
#endif
#endif
/* Skip white-space chars at beginning of string */
DLLEXPORT char* DLLCALL skipsp(char* str);
/* Truncate white-space chars off end of string */
DLLEXPORT char* DLLCALL truncsp(char* str);
/* Truncate white-space chars off end of every \n-terminated line in string */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment