mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 564369 - streamline TokenStream::getChar(), part 2. r=cdleary.
--HG-- extra : rebase_source : 4148cba1faa670ee8a5147b78a339bf676d5fcae
This commit is contained in:
parent
c33fb75973
commit
6abfef34e4
@ -400,43 +400,30 @@ TokenStream::getChar()
|
|||||||
olen = len;
|
olen = len;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure linebuf contains \n for EOL (don't do this in
|
* Normalize all EOL sequences to \n in linebuf (don't do this in
|
||||||
* userbuf because the user's string might be readonly).
|
* userbuf because the user's string might be readonly).
|
||||||
*/
|
*/
|
||||||
if (nl < userbuf.limit) {
|
if (nl < userbuf.limit) {
|
||||||
if (*nl == '\r') {
|
if (*nl == '\r') {
|
||||||
if (linebuf.base[len-1] == '\r') {
|
// If nl points to a \r that means it mustn't be followed
|
||||||
/*
|
// by a \n, in which case \r must have been the last char
|
||||||
* Does the line segment end in \r? We must check
|
// copied. Replace it with \n.
|
||||||
* for a \n at the front of the next segment before
|
JS_ASSERT(linebuf.base[len-1] == '\r');
|
||||||
* storing a \n into linebuf. This case matters
|
linebuf.base[len-1] = '\n';
|
||||||
* only when we're reading from a file.
|
|
||||||
*/
|
|
||||||
if (nl + 1 == userbuf.limit && file) {
|
|
||||||
len--;
|
|
||||||
flags |= TSF_CRFLAG; /* clear NLFLAG? */
|
|
||||||
if (len == 0) {
|
|
||||||
/*
|
|
||||||
* This can happen when a segment ends in
|
|
||||||
* \r\r. Start over. ptr == limit in this
|
|
||||||
* case, so we'll fall into buffer-filling
|
|
||||||
* code.
|
|
||||||
*/
|
|
||||||
return getChar();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
linebuf.base[len-1] = '\n';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (*nl == '\n') {
|
} else if (*nl == '\n') {
|
||||||
if (nl > userbuf.base &&
|
if (nl > userbuf.base && nl[-1] == '\r') {
|
||||||
nl[-1] == '\r' &&
|
// If nl points to a \n that's preceded by a \r, we
|
||||||
linebuf.base[len-2] == '\r') {
|
// overwrite the \r with \n and pull len back by one
|
||||||
|
// so the \n pointed to by nl ends up beyond
|
||||||
|
// linebuf.limit.
|
||||||
|
JS_ASSERT(linebuf.base[len-2] == '\r' &&
|
||||||
|
linebuf.base[len-1] == '\n');
|
||||||
|
linebuf.base[len-2] = '\n';
|
||||||
len--;
|
len--;
|
||||||
JS_ASSERT(linebuf.base[len] == '\n');
|
|
||||||
linebuf.base[len-1] = '\n';
|
|
||||||
}
|
}
|
||||||
} else if (*nl == LINE_SEPARATOR || *nl == PARA_SEPARATOR) {
|
} else if (*nl == LINE_SEPARATOR || *nl == PARA_SEPARATOR) {
|
||||||
|
JS_ASSERT(linebuf.base[len-1] == LINE_SEPARATOR ||
|
||||||
|
linebuf.base[len-1] == PARA_SEPARATOR);
|
||||||
linebuf.base[len-1] = '\n';
|
linebuf.base[len-1] = '\n';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user