Skip to content

Commit

Permalink
Bug 1319410 fixup - Stay in the COMMENT_LESSTHAN state, annotate fall…
Browse files Browse the repository at this point in the history
…-throughs. r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D82163
  • Loading branch information
sideshowbarker committed Aug 16, 2021
1 parent 7c2dd70 commit 3e04105
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
15 changes: 9 additions & 6 deletions parser/html/javasrc/Tokenizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -2851,8 +2851,7 @@ private void ensureBufferSpace(int inputLength) throws SAXException {
continue stateloop;
case '<':
appendStrBuf(c);
state = transition(state, Tokenizer.COMMENT_LESSTHAN, reconsume, pos);
continue stateloop;
continue;
case '-':
appendStrBuf(c);
state = transition(state, Tokenizer.COMMENT_END_DASH, reconsume, pos);
Expand All @@ -2865,13 +2864,14 @@ private void ensureBufferSpace(int inputLength) throws SAXException {
continue;
case '\u0000':
c = '\uFFFD';
// fall thru
// CPPONLY: MOZ_FALLTHROUGH;
default:
appendStrBuf(c);
state = transition(state, Tokenizer.COMMENT, reconsume, pos);
continue stateloop;
}
}
// CPPONLY: MOZ_FALLTHROUGH;
case COMMENT_LESSTHAN_BANG:
for (;;) {
if (++pos == endPos) {
Expand All @@ -2895,13 +2895,14 @@ private void ensureBufferSpace(int inputLength) throws SAXException {
continue;
case '\u0000':
c = '\uFFFD';
// fall thru
// CPPONLY: MOZ_FALLTHROUGH;
default:
appendStrBuf(c);
state = transition(state, Tokenizer.COMMENT, reconsume, pos);
continue stateloop;
}
}
// CPPONLY: MOZ_FALLTHROUGH;
case COMMENT_LESSTHAN_BANG_DASH:
for (;;) {
if (++pos == endPos) {
Expand All @@ -2925,13 +2926,14 @@ private void ensureBufferSpace(int inputLength) throws SAXException {
continue;
case '\u0000':
c = '\uFFFD';
// fall thru
// CPPONLY: MOZ_FALLTHROUGH;
default:
appendStrBuf(c);
state = transition(state, Tokenizer.COMMENT, reconsume, pos);
continue stateloop;
}
}
// CPPONLY: MOZ_FALLTHROUGH;
case COMMENT_LESSTHAN_BANG_DASH_DASH:
for (;;) {
if (++pos == endPos) {
Expand Down Expand Up @@ -2964,7 +2966,7 @@ private void ensureBufferSpace(int inputLength) throws SAXException {
continue;
case '\u0000':
c = '\uFFFD';
// fall thru
// CPPONLY: MOZ_FALLTHROUGH;
case '!':
errNestedComment();
adjustDoubleHyphenAndAppendToStrBufAndErr(c, reportedConsecutiveHyphens);
Expand All @@ -2979,6 +2981,7 @@ private void ensureBufferSpace(int inputLength) throws SAXException {
continue stateloop;
}
}
// CPPONLY: MOZ_FALLTHROUGH;
// XXX reorder point
case COMMENT_START_DASH:
if (++pos == endPos) {
Expand Down
13 changes: 9 additions & 4 deletions parser/html/nsHtml5Tokenizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1517,10 +1517,7 @@ int32_t nsHtml5Tokenizer::stateLoop(int32_t state, char16_t c, int32_t pos,
}
case '<': {
appendStrBuf(c);
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::COMMENT_LESSTHAN,
reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
continue;
}
case '-': {
appendStrBuf(c);
Expand All @@ -1539,6 +1536,7 @@ int32_t nsHtml5Tokenizer::stateLoop(int32_t state, char16_t c, int32_t pos,
}
case '\0': {
c = 0xfffd;
[[fallthrough]];
}
default: {
appendStrBuf(c);
Expand All @@ -1548,6 +1546,7 @@ int32_t nsHtml5Tokenizer::stateLoop(int32_t state, char16_t c, int32_t pos,
}
}
}
[[fallthrough]];
}
case COMMENT_LESSTHAN_BANG: {
for (;;) {
Expand Down Expand Up @@ -1580,6 +1579,7 @@ int32_t nsHtml5Tokenizer::stateLoop(int32_t state, char16_t c, int32_t pos,
}
case '\0': {
c = 0xfffd;
[[fallthrough]];
}
default: {
appendStrBuf(c);
Expand All @@ -1589,6 +1589,7 @@ int32_t nsHtml5Tokenizer::stateLoop(int32_t state, char16_t c, int32_t pos,
}
}
}
[[fallthrough]];
}
case COMMENT_LESSTHAN_BANG_DASH: {
for (;;) {
Expand Down Expand Up @@ -1622,6 +1623,7 @@ int32_t nsHtml5Tokenizer::stateLoop(int32_t state, char16_t c, int32_t pos,
}
case '\0': {
c = 0xfffd;
[[fallthrough]];
}
default: {
appendStrBuf(c);
Expand All @@ -1631,6 +1633,7 @@ int32_t nsHtml5Tokenizer::stateLoop(int32_t state, char16_t c, int32_t pos,
}
}
}
[[fallthrough]];
}
case COMMENT_LESSTHAN_BANG_DASH_DASH: {
for (;;) {
Expand Down Expand Up @@ -1682,6 +1685,7 @@ int32_t nsHtml5Tokenizer::stateLoop(int32_t state, char16_t c, int32_t pos,
}
case '\0': {
c = 0xfffd;
[[fallthrough]];
}
case '!': {
if (P::reportErrors) {
Expand Down Expand Up @@ -1709,6 +1713,7 @@ int32_t nsHtml5Tokenizer::stateLoop(int32_t state, char16_t c, int32_t pos,
}
}
}
[[fallthrough]];
}
case COMMENT_START_DASH: {
if (++pos == endPos) {
Expand Down

0 comments on commit 3e04105

Please sign in to comment.