MCPcopy Index your code
hub / github.com/MapServer/MapServer / msGetExpressionString

Function msGetExpressionString

mapfile.c:2143–2174  ·  view source on GitHub ↗

msGetExpressionString() * * Returns the string representation of this expression, including delimiters * and any flags (e.g. i = case-insensitive). * * Returns a newly allocated buffer that should be freed by the caller or NULL. */

Source from the content-addressed store, hash-verified

2141 * Returns a newly allocated buffer that should be freed by the caller or NULL.
2142 */
2143char *msGetExpressionString(expressionObj *exp)
2144{
2145 if(exp->string) {
2146 char *exprstring;
2147 size_t buffer_size;
2148 const char *case_insensitive = "";
2149
2150 if(exp->flags & MS_EXP_INSENSITIVE)
2151 case_insensitive = "i";
2152
2153 /* Alloc buffer big enough for string + 2 delimiters + 'i' + \0 */
2154 buffer_size = strlen(exp->string)+4;
2155 exprstring = (char*)msSmallMalloc(buffer_size);
2156
2157 switch(exp->type) {
2158 case(MS_REGEX):
2159 snprintf(exprstring, buffer_size, "/%s/%s", exp->string, case_insensitive);
2160 return exprstring;
2161 case(MS_STRING):
2162 snprintf(exprstring, buffer_size, "\"%s\"%s", exp->string, case_insensitive);
2163 return exprstring;
2164 case(MS_EXPRESSION):
2165 snprintf(exprstring, buffer_size, "(%s)", exp->string);
2166 return exprstring;
2167 default:
2168 /* We should never get to here really! */
2169 free(exprstring);
2170 return NULL;
2171 }
2172 }
2173 return NULL;
2174}
2175
2176static void writeExpression(FILE *stream, int indent, const char *name, expressionObj *exp)
2177{

Callers 5

layerObj_getFilterFunction · 0.85
classObj_getTextStringFunction · 0.85

Calls 1

msSmallMallocFunction · 0.85

Tested by

no test coverage detected