Fossil SCM

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.

florian 2018-11-16 19:39 UTC comment-formatter-utf8
Commit 70dd8f744f22c897a4b090321a958c811ff269ae
1 file changed +1 -2
+1 -2
--- src/comformat.c
+++ src/comformat.c
@@ -257,12 +257,11 @@
257257
}else{
258258
if( origBreak && index>0 ){
259259
const char *zCurrent = &zLine[index];
260260
if( comment_check_orig(zOrigText, zCurrent, &charCnt, &lineCnt) ){
261261
zBuf[iBuf++] = '\n';
262
- comment_calc_indent(zCurrent, origIndent, trimCrLf, trimSpace,
263
- &index);
262
+ comment_calc_indent(zLine, origIndent, trimCrLf, trimSpace, &index);
264263
for( i=0; i<origIndent; i++ ){
265264
zBuf[iBuf++] = ' ';
266265
}
267266
maxChars = lineChars;
268267
}
269268
--- src/comformat.c
+++ src/comformat.c
@@ -257,12 +257,11 @@
257 }else{
258 if( origBreak && index>0 ){
259 const char *zCurrent = &zLine[index];
260 if( comment_check_orig(zOrigText, zCurrent, &charCnt, &lineCnt) ){
261 zBuf[iBuf++] = '\n';
262 comment_calc_indent(zCurrent, origIndent, trimCrLf, trimSpace,
263 &index);
264 for( i=0; i<origIndent; i++ ){
265 zBuf[iBuf++] = ' ';
266 }
267 maxChars = lineChars;
268 }
269
--- src/comformat.c
+++ src/comformat.c
@@ -257,12 +257,11 @@
257 }else{
258 if( origBreak && index>0 ){
259 const char *zCurrent = &zLine[index];
260 if( comment_check_orig(zOrigText, zCurrent, &charCnt, &lineCnt) ){
261 zBuf[iBuf++] = '\n';
262 comment_calc_indent(zLine, origIndent, trimCrLf, trimSpace, &index);
 
263 for( i=0; i<origIndent; i++ ){
264 zBuf[iBuf++] = ' ';
265 }
266 maxChars = lineChars;
267 }
268

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button