-
-
Notifications
You must be signed in to change notification settings - Fork 302
/
strip.c
41 lines (31 loc) · 902 Bytes
/
strip.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*!
\file lib/db/dbmi_base/strip.c
\brief DBMI Library (base) - strip strings
(C) 1999-2009, 2011 by the GRASS Development Team
This program is free software under the GNU General Public License
(>=v2). Read the file COPYING that comes with GRASS for details.
\author Joel Jones (CERL/UIUC), Radim Blazek
\author Doxygenized by Martin Landa <landa.martin gmail.com> (2011)
*/
#include <grass/dbmi.h>
/*!
\brief Strip given string
'buf' is rewritten in place with leading and trailing white
space removed.
\param buf string buffer
*/
void db_strip(char *buf)
{
char *a, *b;
/* remove leading white space */
for (a = b = buf; *a == ' ' || *a == '\t'; a++) ;
if (a != b)
while ((*b++ = *a++)) ;
/* remove trailing white space */
for (a = buf; *a; a++) ;
if (a != buf) {
for (a--; *a == ' ' || *a == '\t'; a--) ;
a++;
*a = 0;
}
}