Differences From Artifact [8e984136d0]:
- File src/comformat.c — part of check-in [70dd8f744f] at 2018-11-16 19:39:00 on branch comment-formatter-utf8 — Fix a bug (already present on trunk) with the (non-legacy) comment printing algorithm, detected while running the regression tests from test/comment.test with UTF-8 text: the function to print the indent (modified to a calculate-only function on this branch) was handed a pointer to the current line index and the current line index, thus performing checks at (current line index * 2), causing random increments of the current line index. (user: florian size: 22151)
To Artifact [cf4a82f353]:
- File src/comformat.c — part of check-in [b86a2fc7eb] at 2018-11-24 07:16:00 on branch comment-formatter-utf8 — Fix two bugs (introduced with this branch) that become manifest with invalid UTF-8 sequences. (user: florian size: 22191)
| ︙ | |||
169 170 171 172 173 174 175 176 177 178 179 180 181 182 | 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | + |
int maxUTF8=1; /* Expected sequence length. */
if( (c&0xe0)==0xc0 )maxUTF8=2; /* UTF-8 lead byte 110vvvvv */
else if( (c&0xf0)==0xe0 )maxUTF8=3; /* UTF-8 lead byte 1110vvvv */
else if( (c&0xf8)==0xf0 )maxUTF8=4; /* UTF-8 lead byte 11110vvv */
while( i<lengthBytes-1 &&
cchUTF8<maxUTF8 &&
(zString[i+1]&0xc0)==0x80 ){ /* UTF-8 trail byte 10vvvvvv */
cchUTF8++;
i++;
}
}
}
return lengthUTF8;
}
|
| ︙ | |||
402 403 404 405 406 407 408 409 410 411 412 413 414 415 | 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 | + |
int maxUTF8=1; /* Expected sequence length. */
if( (c&0xe0)==0xc0 )maxUTF8=2; /* UTF-8 lead byte 110vvvvv */
else if( (c&0xf0)==0xe0 )maxUTF8=3; /* UTF-8 lead byte 1110vvvv */
else if( (c&0xf8)==0xf0 )maxUTF8=4; /* UTF-8 lead byte 11110vvv */
zBuf[k++] = c;
while( cchUTF8<maxUTF8 &&
(zText[i+1]&0xc0)==0x80 ){ /* UTF-8 trail byte 10vvvvvv */
cchUTF8++;
zBuf[k++] = zText[++i];
}
}
else if( fossil_isspace(c) ){
si = i;
sk = k;
if( k==0 || zBuf[k-1]!=' ' ){
|
| ︙ |