PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ stringbuffer_trim_trailing_white()

int stringbuffer_trim_trailing_white ( stringbuffer_t s)

Trims whitespace off the end of the stringbuffer.

Returns the number of characters trimmed.

Definition at line 261 of file stringbuffer.c.

References stringbuffer_t::str_end, and stringbuffer_t::str_start.

262 {
263  char *ptr = s->str_end;
264  int dist = 0;
265 
266  /* Roll backwards until we hit a non-space. */
267  while( ptr > s->str_start )
268  {
269  ptr--;
270  if( (*ptr == ' ') || (*ptr == '\t') )
271  {
272  continue;
273  }
274  else
275  {
276  ptr++;
277  dist = s->str_end - ptr;
278  *ptr = '\0';
279  s->str_end = ptr;
280  return dist;
281  }
282  }
283  return dist;
284 }
char * str_start
Definition: stringbuffer.h:52