// Skips newlines, and handles different line endings.
static qbool Parse_Newline(struct qparser_state_s *state)
{
- if(*state->pos == '\n')
- goto newline;
- if(*state->pos == '\r')
+ if(Token_Newline(&state->pos))
{
- if(*state->pos + 1 == '\n')
- state->pos++;
- goto newline;
+ state->col = 1;
+ state->line++;
+ return true;
}
return false;
-newline:
- state->col = 1;
- state->line++;
- state->pos++;
- return true;
}
// Skip all whitespace, as we normally know it.
return out;
}
+
+// Skips newlines, and handles different line endings.
+qbool Token_Newline(const char **data)
+{
+ if(**data == '\n')
+ goto newline;
+ if(**data == '\r')
+ {
+ if(**data + 1 == '\n')
+ (*data)++;
+ goto newline;
+ }
+ return false;
+newline:
+ (*data)++;
+ return true;
+}