* getNextNonCommentLine() * * Input: sa (output from cpp, by line) * start (starting index to search) * &next ( index of first uncommented line after * the start line) * Return: 0 if OK, 1 on error * * Notes: * (1) Skips over all consecutive comment lines, beginning at 'start' * (2) If all lines to the end are '
| 222 | * (2) If all lines to the end are '#' comments, return next = -1 |
| 223 | */ |
| 224 | static l_int32 |
| 225 | getNextNonCommentLine(SARRAY *sa, |
| 226 | l_int32 start, |
| 227 | l_int32 *pnext) |
| 228 | { |
| 229 | char *str; |
| 230 | l_int32 i, n; |
| 231 | |
| 232 | PROCNAME("getNextNonCommentLine"); |
| 233 | |
| 234 | if (!sa) |
| 235 | return ERROR_INT("sa not defined", procName, 1); |
| 236 | if (!pnext) |
| 237 | return ERROR_INT("&pnext not defined", procName, 1); |
| 238 | |
| 239 | /* Init for situation where this line and all following are comments */ |
| 240 | *pnext = -1; |
| 241 | |
| 242 | n = sarrayGetCount(sa); |
| 243 | for (i = start; i < n; i++) { |
| 244 | if ((str = sarrayGetString(sa, i, L_NOCOPY)) == NULL) |
| 245 | return ERROR_INT("str not returned; shouldn't happen", procName, 1); |
| 246 | if (str[0] != '#') { |
| 247 | *pnext = i; |
| 248 | return 0; |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | return 0; |
| 253 | } |
| 254 | |
| 255 | |
| 256 | /* |
no test coverage detected