auto bool_t grr_skip_spaces_or_comment(FILE *rd); /* Skips spaces until a newline ('\012') or a '#' character. If the latter, skips any additional characters until the newline. Consumes the newline. Returns TRUE normally, FALSE if syntax error. */ bool_t grr_skip_spaces_or_comment(FILE *rd) { int c; do { c = fgetc(rd); } while ((c=='\000') || (c==' ') || (c=='\011')); if (c == EOF) { return FALSE; } if (c == '#') { do { c = fgetc(rd); } while ((c != '\012') && (c != EOF)); if (c == EOF) { return FALSE; } } ungetc(c, rd); return (c == '\012'); } void grr_skip_spaces_and_comment_lines(FILE *rd) { while(1) { fget_skip_spaces(rd); if (fget_test_char(rd, '#')) { ungetc('#', rd); if (! grr_skip_spaces_or_comment(rd)) { grr_file_error(NULL, NORULE, "bad comment"); } fget_eol(rd); } else if (fget_test_char(rd, '\012')) { /* OK, continue */ } else { return; } } }