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