PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ chartrim()

static char * chartrim ( const char *  input,
char *  remove 
)
static

Definition at line 306 of file raster2pgsql.c.

306 {
307 char *rtn = NULL;
308 char *ptr = NULL;
309 uint32_t offset = 0;
310 size_t len = 0;
311
312 if (!input)
313 return NULL;
314 else if (!*input)
315 return (char *) input;
316
317 /* trim left */
318 while (strchr(remove, *input) != NULL)
319 input++;
320
321 /* trim right */
322 ptr = ((char *) input) + strlen(input);
323 while (strchr(remove, *--ptr) != NULL)
324 offset++;
325
326 len = strlen(input) - offset + 1;
327 rtn = rtalloc(sizeof(char) * len);
328 if (NULL == rtn) {
329 rterror(_("chartrim: Not enough memory"));
330 return NULL;
331 }
332 strncpy(rtn, input, len);
333 rtn[strlen(input) - offset] = '\0';
334
335 return rtn;
336}
void rterror(const char *fmt,...) __attribute__((format(printf
Wrappers used for reporting errors and info.
void * rtalloc(size_t size)
Wrappers used for managing memory.
Definition rt_context.c:191
#define _(String)
Definition shpcommon.h:24

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

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

Here is the call graph for this function:
Here is the caller graph for this function: