Fossil SCM
Fix boundary case in the new comment printing algorithm that sometimes results in extra new lines.
Commit
4532733830d26f524b3ec7a6ee431ac1b44cce38
Parent
f39d8a3d24a2d07…
2 files changed
+5
-5
+31
+5
-5
| --- src/comformat.c | ||
| +++ src/comformat.c | ||
| @@ -147,15 +147,15 @@ | ||
| 147 | 147 | int trimSpace, /* [in] Non-zero to trim leading/trailing spaces. */ |
| 148 | 148 | int *piIndex /* [in/out] Pointer to first non-space character. */ |
| 149 | 149 | ){ |
| 150 | 150 | if( indent>0 ){ |
| 151 | 151 | fossil_print("%*s", indent, ""); |
| 152 | - if( trimSpace && zLine && piIndex ){ | |
| 153 | - int index = *piIndex; | |
| 154 | - while( fossil_isspace(zLine[index]) ){ index++; } | |
| 155 | - *piIndex = index; | |
| 156 | - } | |
| 152 | + } | |
| 153 | + if( trimSpace && zLine && piIndex ){ | |
| 154 | + int index = *piIndex; | |
| 155 | + while( fossil_isspace(zLine[index]) ){ index++; } | |
| 156 | + *piIndex = index; | |
| 157 | 157 | } |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | /* |
| 161 | 161 | ** This function prints one logical line of a comment, stopping when it hits |
| 162 | 162 |
| --- src/comformat.c | |
| +++ src/comformat.c | |
| @@ -147,15 +147,15 @@ | |
| 147 | int trimSpace, /* [in] Non-zero to trim leading/trailing spaces. */ |
| 148 | int *piIndex /* [in/out] Pointer to first non-space character. */ |
| 149 | ){ |
| 150 | if( indent>0 ){ |
| 151 | fossil_print("%*s", indent, ""); |
| 152 | if( trimSpace && zLine && piIndex ){ |
| 153 | int index = *piIndex; |
| 154 | while( fossil_isspace(zLine[index]) ){ index++; } |
| 155 | *piIndex = index; |
| 156 | } |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | /* |
| 161 | ** This function prints one logical line of a comment, stopping when it hits |
| 162 |
| --- src/comformat.c | |
| +++ src/comformat.c | |
| @@ -147,15 +147,15 @@ | |
| 147 | int trimSpace, /* [in] Non-zero to trim leading/trailing spaces. */ |
| 148 | int *piIndex /* [in/out] Pointer to first non-space character. */ |
| 149 | ){ |
| 150 | if( indent>0 ){ |
| 151 | fossil_print("%*s", indent, ""); |
| 152 | } |
| 153 | if( trimSpace && zLine && piIndex ){ |
| 154 | int index = *piIndex; |
| 155 | while( fossil_isspace(zLine[index]) ){ index++; } |
| 156 | *piIndex = index; |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | /* |
| 161 | ** This function prints one logical line of a comment, stopping when it hits |
| 162 |
+31
| --- test/comment.test | ||
| +++ test/comment.test | ||
| @@ -254,5 +254,36 @@ | ||
| 254 | 254 | |
| 255 | 255 | ############################################################################### |
| 256 | 256 | |
| 257 | 257 | fossil test-comment-format --width 82 --indent 9 --decode --origbreak "00:00:00 " "\[0000000000\] *CURRENT* $orig" $orig |
| 258 | 258 | test comment-48 {$RESULT eq "00:00:00 \[0000000000\] *CURRENT* \n xxxx xx xxxxxxx xxxx xxxxxx xxxxxxx, xxxxxxx, x xxxx xxxxxx xx xxxx xxxx\n xxxxxxx xxxxx xxxx xxxx xx xxxxxxx xxxxxxx (xxxxxx xxxxxxxxx x xxxxx).\n xxx'x xxx xxx xx xxxxx xxxx xxx xxx --xxxxxxxxxxx xxxxxx xx xx xxxx. x\n xxxxx x xxxxxx xxxx xxxx xxxx xxxx xxxx x xxxxx xx xxx x xxxxxxxx\n xxxxxxx.\n(6 lines output)"} |
| 259 | + | |
| 260 | +############################################################################### | |
| 261 | + | |
| 262 | +fossil test-comment-format --width 72 --decode --trimspace --origbreak "" $orig | |
| 263 | +test comment-49 {$RESULT eq "xxxx xx xxxxxxx xxxx xxxxxx xxxxxxx, xxxxxxx, x xxxx xxxxxx xx xxxx xxxx\nxxxxxxx xxxxx xxxx xxxx xx xxxxxxx xxxxxxx (xxxxxx xxxxxxxxx x xxxxx).\nxxx'x xxx xxx xx xxxxx xxxx xxx xxx --xxxxxxxxxxx xxxxxx xx xx xxxx. x\nxxxxx x xxxxxx xxxx xxxx xxxx xxxx xxxx x xxxxx xx xxx x xxxxxxxx\nxxxxxxx.\n(5 lines output)"} | |
| 264 | + | |
| 265 | +############################################################################### | |
| 266 | + | |
| 267 | +fossil test-comment-format --width 72 --decode --trimspace --origbreak "" $orig $orig | |
| 268 | +test comment-50 {$RESULT eq "xxxx xx xxxxxxx xxxx xxxxxx xxxxxxx, xxxxxxx, x xxxx xxxxxx xx xxxx xxxx\nxxxxxxx xxxxx xxxx xxxx xx xxxxxxx xxxxxxx (xxxxxx xxxxxxxxx x xxxxx).\nxxx'x xxx xxx xx xxxxx xxxx xxx xxx --xxxxxxxxxxx xxxxxx xx xx xxxx. x\nxxxxx x xxxxxx xxxx xxxx xxxx xxxx xxxx x xxxxx xx xxx x xxxxxxxx\nxxxxxxx.\n(5 lines output)"} | |
| 269 | + | |
| 270 | +############################################################################### | |
| 271 | + | |
| 272 | +fossil test-comment-format --width 72 --decode --trimspace --origbreak "" "00:00:00 \[0000000000\] *CURRENT* $orig" $orig | |
| 273 | +puts $RESULT | |
| 274 | +test comment-51 {$RESULT eq "00:00:00 \[0000000000\] *CURRENT* \nxxxx xx xxxxxxx xxxx xxxxxx xxxxxxx, xxxxxxx, x xxxx xxxxxx xx xxxx xxxx\nxxxxxxx xxxxx xxxx xxxx xx xxxxxxx xxxxxxx (xxxxxx xxxxxxxxx x xxxxx).\nxxx'x xxx xxx xx xxxxx xxxx xxx xxx --xxxxxxxxxxx xxxxxx xx xx xxxx. x\nxxxxx x xxxxxx xxxx xxxx xxxx xxxx xxxx x xxxxx xx xxx x xxxxxxxx\nxxxxxxx.\n(6 lines output)"} | |
| 275 | + | |
| 276 | +############################################################################### | |
| 277 | + | |
| 278 | +fossil test-comment-format --width 81 --indent 9 --decode --trimspace --origbreak " " $orig | |
| 279 | +test comment-52 {$RESULT eq " xxxx xx xxxxxxx xxxx xxxxxx xxxxxxx, xxxxxxx, x xxxx xxxxxx xx xxxx xxxx\n xxxxxxx xxxxx xxxx xxxx xx xxxxxxx xxxxxxx (xxxxxx xxxxxxxxx x xxxxx).\n xxx'x xxx xxx xx xxxxx xxxx xxx xxx --xxxxxxxxxxx xxxxxx xx xx xxxx. x\n xxxxx x xxxxxx xxxx xxxx xxxx xxxx xxxx x xxxxx xx xxx x xxxxxxxx\n xxxxxxx.\n(5 lines output)"} | |
| 280 | + | |
| 281 | +############################################################################### | |
| 282 | + | |
| 283 | +fossil test-comment-format --width 81 --indent 9 --decode --trimspace --origbreak " " $orig $orig | |
| 284 | +test comment-53 {$RESULT eq " xxxx xx xxxxxxx xxxx xxxxxx xxxxxxx, xxxxxxx, x xxxx xxxxxx xx xxxx xxxx\n xxxxxxx xxxxx xxxx xxxx xx xxxxxxx xxxxxxx (xxxxxx xxxxxxxxx x xxxxx).\n xxx'x xxx xxx xx xxxxx xxxx xxx xxx --xxxxxxxxxxx xxxxxx xx xx xxxx. x\n xxxxx x xxxxxx xxxx xxxx xxxx xxxx xxxx x xxxxx xx xxx x xxxxxxxx\n xxxxxxx.\n(5 lines output)"} | |
| 285 | + | |
| 286 | +############################################################################### | |
| 287 | + | |
| 288 | +fossil test-comment-format --width 81 --indent 9 --decode --trimspace --origbreak "00:00:00 " "\[0000000000\] *CURRENT* $orig" $orig | |
| 289 | +test comment-54 {$RESULT eq "00:00:00 \[0000000000\] *CURRENT* \n xxxx xx xxxxxxx xxxx xxxxxx xxxxxxx, xxxxxxx, x xxxx xxxxxx xx xxxx xxxx\n xxxxxxx xxxxx xxxx xxxx xx xxxxxxx xxxxxxx (xxxxxx xxxxxxxxx x xxxxx).\n xxx'x xxx xxx xx xxxxx xxxx xxx xxx --xxxxxxxxxxx xxxxxx xx xx xxxx. x\n xxxxx x xxxxxx xxxx xxxx xxxx xxxx xxxx x xxxxx xx xxx x xxxxxxxx\n xxxxxxx.\n(6 lines output)"} | |
| 259 | 290 |
| --- test/comment.test | |
| +++ test/comment.test | |
| @@ -254,5 +254,36 @@ | |
| 254 | |
| 255 | ############################################################################### |
| 256 | |
| 257 | fossil test-comment-format --width 82 --indent 9 --decode --origbreak "00:00:00 " "\[0000000000\] *CURRENT* $orig" $orig |
| 258 | test comment-48 {$RESULT eq "00:00:00 \[0000000000\] *CURRENT* \n xxxx xx xxxxxxx xxxx xxxxxx xxxxxxx, xxxxxxx, x xxxx xxxxxx xx xxxx xxxx\n xxxxxxx xxxxx xxxx xxxx xx xxxxxxx xxxxxxx (xxxxxx xxxxxxxxx x xxxxx).\n xxx'x xxx xxx xx xxxxx xxxx xxx xxx --xxxxxxxxxxx xxxxxx xx xx xxxx. x\n xxxxx x xxxxxx xxxx xxxx xxxx xxxx xxxx x xxxxx xx xxx x xxxxxxxx\n xxxxxxx.\n(6 lines output)"} |
| 259 |
| --- test/comment.test | |
| +++ test/comment.test | |
| @@ -254,5 +254,36 @@ | |
| 254 | |
| 255 | ############################################################################### |
| 256 | |
| 257 | fossil test-comment-format --width 82 --indent 9 --decode --origbreak "00:00:00 " "\[0000000000\] *CURRENT* $orig" $orig |
| 258 | test comment-48 {$RESULT eq "00:00:00 \[0000000000\] *CURRENT* \n xxxx xx xxxxxxx xxxx xxxxxx xxxxxxx, xxxxxxx, x xxxx xxxxxx xx xxxx xxxx\n xxxxxxx xxxxx xxxx xxxx xx xxxxxxx xxxxxxx (xxxxxx xxxxxxxxx x xxxxx).\n xxx'x xxx xxx xx xxxxx xxxx xxx xxx --xxxxxxxxxxx xxxxxx xx xx xxxx. x\n xxxxx x xxxxxx xxxx xxxx xxxx xxxx xxxx x xxxxx xx xxx x xxxxxxxx\n xxxxxxx.\n(6 lines output)"} |
| 259 | |
| 260 | ############################################################################### |
| 261 | |
| 262 | fossil test-comment-format --width 72 --decode --trimspace --origbreak "" $orig |
| 263 | test comment-49 {$RESULT eq "xxxx xx xxxxxxx xxxx xxxxxx xxxxxxx, xxxxxxx, x xxxx xxxxxx xx xxxx xxxx\nxxxxxxx xxxxx xxxx xxxx xx xxxxxxx xxxxxxx (xxxxxx xxxxxxxxx x xxxxx).\nxxx'x xxx xxx xx xxxxx xxxx xxx xxx --xxxxxxxxxxx xxxxxx xx xx xxxx. x\nxxxxx x xxxxxx xxxx xxxx xxxx xxxx xxxx x xxxxx xx xxx x xxxxxxxx\nxxxxxxx.\n(5 lines output)"} |
| 264 | |
| 265 | ############################################################################### |
| 266 | |
| 267 | fossil test-comment-format --width 72 --decode --trimspace --origbreak "" $orig $orig |
| 268 | test comment-50 {$RESULT eq "xxxx xx xxxxxxx xxxx xxxxxx xxxxxxx, xxxxxxx, x xxxx xxxxxx xx xxxx xxxx\nxxxxxxx xxxxx xxxx xxxx xx xxxxxxx xxxxxxx (xxxxxx xxxxxxxxx x xxxxx).\nxxx'x xxx xxx xx xxxxx xxxx xxx xxx --xxxxxxxxxxx xxxxxx xx xx xxxx. x\nxxxxx x xxxxxx xxxx xxxx xxxx xxxx xxxx x xxxxx xx xxx x xxxxxxxx\nxxxxxxx.\n(5 lines output)"} |
| 269 | |
| 270 | ############################################################################### |
| 271 | |
| 272 | fossil test-comment-format --width 72 --decode --trimspace --origbreak "" "00:00:00 \[0000000000\] *CURRENT* $orig" $orig |
| 273 | puts $RESULT |
| 274 | test comment-51 {$RESULT eq "00:00:00 \[0000000000\] *CURRENT* \nxxxx xx xxxxxxx xxxx xxxxxx xxxxxxx, xxxxxxx, x xxxx xxxxxx xx xxxx xxxx\nxxxxxxx xxxxx xxxx xxxx xx xxxxxxx xxxxxxx (xxxxxx xxxxxxxxx x xxxxx).\nxxx'x xxx xxx xx xxxxx xxxx xxx xxx --xxxxxxxxxxx xxxxxx xx xx xxxx. x\nxxxxx x xxxxxx xxxx xxxx xxxx xxxx xxxx x xxxxx xx xxx x xxxxxxxx\nxxxxxxx.\n(6 lines output)"} |
| 275 | |
| 276 | ############################################################################### |
| 277 | |
| 278 | fossil test-comment-format --width 81 --indent 9 --decode --trimspace --origbreak " " $orig |
| 279 | test comment-52 {$RESULT eq " xxxx xx xxxxxxx xxxx xxxxxx xxxxxxx, xxxxxxx, x xxxx xxxxxx xx xxxx xxxx\n xxxxxxx xxxxx xxxx xxxx xx xxxxxxx xxxxxxx (xxxxxx xxxxxxxxx x xxxxx).\n xxx'x xxx xxx xx xxxxx xxxx xxx xxx --xxxxxxxxxxx xxxxxx xx xx xxxx. x\n xxxxx x xxxxxx xxxx xxxx xxxx xxxx xxxx x xxxxx xx xxx x xxxxxxxx\n xxxxxxx.\n(5 lines output)"} |
| 280 | |
| 281 | ############################################################################### |
| 282 | |
| 283 | fossil test-comment-format --width 81 --indent 9 --decode --trimspace --origbreak " " $orig $orig |
| 284 | test comment-53 {$RESULT eq " xxxx xx xxxxxxx xxxx xxxxxx xxxxxxx, xxxxxxx, x xxxx xxxxxx xx xxxx xxxx\n xxxxxxx xxxxx xxxx xxxx xx xxxxxxx xxxxxxx (xxxxxx xxxxxxxxx x xxxxx).\n xxx'x xxx xxx xx xxxxx xxxx xxx xxx --xxxxxxxxxxx xxxxxx xx xx xxxx. x\n xxxxx x xxxxxx xxxx xxxx xxxx xxxx xxxx x xxxxx xx xxx x xxxxxxxx\n xxxxxxx.\n(5 lines output)"} |
| 285 | |
| 286 | ############################################################################### |
| 287 | |
| 288 | fossil test-comment-format --width 81 --indent 9 --decode --trimspace --origbreak "00:00:00 " "\[0000000000\] *CURRENT* $orig" $orig |
| 289 | test comment-54 {$RESULT eq "00:00:00 \[0000000000\] *CURRENT* \n xxxx xx xxxxxxx xxxx xxxxxx xxxxxxx, xxxxxxx, x xxxx xxxxxx xx xxxx xxxx\n xxxxxxx xxxxx xxxx xxxx xx xxxxxxx xxxxxxx (xxxxxx xxxxxxxxx x xxxxx).\n xxx'x xxx xxx xx xxxxx xxxx xxx xxx --xxxxxxxxxxx xxxxxx xx xx xxxx. x\n xxxxx x xxxxxx xxxx xxxx xxxx xxxx xxxx x xxxxx xx xxx x xxxxxxxx\n xxxxxxx.\n(6 lines output)"} |
| 290 |