PostGIS  2.1.10dev-r@@SVN_REVISION@@
static char* trim ( const char *  input)
static

Definition at line 263 of file raster2pgsql.c.

References _, input(), rtalloc(), and rterror().

Referenced by main(), and rt_raster_get_perimeter().

263  {
264  char *rtn;
265  char *ptr;
266  uint32_t offset = 0;
267 
268  if (!input)
269  return NULL;
270  else if (!*input)
271  return (char *) input;
272 
273  /* trim left */
274  while (isspace(*input))
275  input++;
276 
277  /* trim right */
278  ptr = ((char *) input) + strlen(input);
279  while (isspace(*--ptr))
280  offset++;
281 
282  rtn = rtalloc(sizeof(char) * (strlen(input) - offset + 1));
283  if (NULL == rtn) {
284  rterror(_("trim: Not enough memory"));
285  return NULL;
286  }
287  strncpy(rtn, input, strlen(input) - offset);
288  rtn[strlen(input) - offset] = '\0';
289 
290  return rtn;
291 }
#define _(String)
Definition: shpcommon.h:23
static int input(void)
void * rtalloc(size_t size)
Raster core memory management functions.
Definition: rt_api.c:867
void rterror(const char *fmt,...)
Raster core error and info handlers.
Definition: rt_api.c:895

Here is the call graph for this function:

Here is the caller graph for this function: