/
| 151 | |
| 152 | /*****************************************************************************/ |
| 153 | char *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 | /*****************************************************************************/ |
| 192 | char *pj_shrink(char *c) { |
no outgoing calls
no test coverage detected