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