PostGIS  2.4.9dev-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 268 of file stringbuffer.c.

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

269 {
270  char *ptr = s->str_end;
271  int dist = 0;
272 
273  /* Roll backwards until we hit a non-space. */
274  while( ptr > s->str_start )
275  {
276  ptr--;
277  if( (*ptr == ' ') || (*ptr == '\t') )
278  {
279  continue;
280  }
281  else
282  {
283  ptr++;
284  dist = s->str_end - ptr;
285  *ptr = '\0';
286  s->str_end = ptr;
287  return dist;
288  }
289  }
290  return dist;
291 }
char * str_start
Definition: stringbuffer.h:41