MCPcopy Create free account
hub / github.com/OSGeo/PROJ / pj_chomp

Function pj_chomp

src/internal.cpp:153–189  ·  view source on GitHub ↗

/

Source from the content-addressed store, hash-verified

151
152/*****************************************************************************/
153char *pj_chomp(char *c) {
154 /******************************************************************************
155 Strip pre- and postfix whitespace. Inline comments (indicated by '#') are
156 considered whitespace.
157 ******************************************************************************/
158 size_t i, n;
159 char *comment;
160 char *start = c;
161
162 if (nullptr == c)
163 return nullptr;
164
165 comment = strchr(c, '#');
166 if (comment)
167 *comment = 0;
168
169 n = strlen(c);
170 if (0 == n)
171 return c;
172
173 /* Eliminate postfix whitespace */
174 for (i = n - 1; (i > 0) && (isspace(c[i]) || ';' == c[i]); i--)
175 c[i] = 0;
176
177 /* Find start of non-whitespace */
178 while (0 != *start && (';' == *start || isspace(*start)))
179 start++;
180
181 n = strlen(start);
182 if (0 == n) {
183 c[0] = 0;
184 return c;
185 }
186
187 memmove(c, start, n + 1);
188 return c;
189}
190
191/*****************************************************************************/
192char *pj_shrink(char *c) {

Callers 3

pj_shrinkFunction · 0.85
get_init_stringFunction · 0.85
nextlineFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected