PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ rtpg_chartrim()

char* rtpg_chartrim ( const char *  input,
char *  remove 
)

Definition at line 110 of file rtpg_internal.c.

Referenced by RASTER_reclass().

110  {
111  char *rtn = NULL;
112  char *ptr = NULL;
113  uint32_t offset = 0;
114 
115  if (!input)
116  return NULL;
117  else if (!*input)
118  return (char *) input;
119 
120  /* trim left */
121  while (strchr(remove, *input) != NULL)
122  input++;
123 
124  /* trim right */
125  ptr = ((char *) input) + strlen(input);
126  while (strchr(remove, *--ptr) != NULL)
127  offset++;
128 
129  rtn = palloc(sizeof(char) * (strlen(input) - offset + 1));
130  if (rtn == NULL) {
131  fprintf(stderr, "Not enough memory\n");
132  return NULL;
133  }
134  strncpy(rtn, input, strlen(input) - offset);
135  rtn[strlen(input) - offset] = '\0';
136 
137  return rtn;
138 }
unsigned int uint32_t
Definition: uthash.h:78
Here is the caller graph for this function: