/** remove comments **/ int tokenize_next(tokenize_t *t) { int res; if (t->hasnext) { t->hasnext = 0; return 0; } restart: res = tokenize_next_internal(t); if (res == EOF) return EOF; // block comment? if (!strncmp(t->token,"/*",2)) { while (1) { res = tokenize_next_internal(t); if (res == EOF) return -10; int len = strlen(t->token); if (len >= 2 && !strncmp(&t->token[len-2],"*/", 2)) break; } goto restart; } // end of line comment? If so, instantly consume the rest of this line. if (!strncmp(t->token,"//", 2)) { tokenize_flush_line(t); goto restart; } return res; }
int tokenize_next(tokenize_t *t) { int res; if (t->hasnext) { t->hasnext = 0; return 0; } res = tokenize_next_internal(t); if (res == EOF) return EOF; return res; }