PostGIS  2.1.10dev-r@@SVN_REVISION@@
static char* chartrim ( const char *  input,
char *  remove 
)
static

Definition at line 294 of file raster2pgsql.c.

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

Referenced by add_overview_constraints(), add_raster_constraints(), and create_index().

294  {
295  char *rtn = NULL;
296  char *ptr = NULL;
297  uint32_t offset = 0;
298 
299  if (!input)
300  return NULL;
301  else if (!*input)
302  return (char *) input;
303 
304  /* trim left */
305  while (strchr(remove, *input) != NULL)
306  input++;
307 
308  /* trim right */
309  ptr = ((char *) input) + strlen(input);
310  while (strchr(remove, *--ptr) != NULL)
311  offset++;
312 
313  rtn = rtalloc(sizeof(char) * (strlen(input) - offset + 1));
314  if (NULL == rtn) {
315  rterror(_("chartrim: Not enough memory"));
316  return NULL;
317  }
318  strncpy(rtn, input, strlen(input) - offset);
319  rtn[strlen(input) - offset] = '\0';
320 
321  return rtn;
322 }
#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: