Fossil SCM
When available, pass the original comment text as well as the (possibly prefixed) comment into comment_print(). Add COMMENT_PRINT_ORIG_BREAK flag to the new comment printing algorithm. Change the width argument for the test-comment-format command into an option. Add --origbreak option to the test-comment-format command.
Commit
0d0b80fd1cafff21194e6a7f953f006f616fb9ad
Parent
b1b352e1cce404c…
11 files changed
+1
-1
+77
-22
+1
-1
+2
-2
+1
-1
+2
-2
+3
-3
+1
-1
+1
-1
+1
-1
+49
-38
+1
-1
| --- src/bisect.c | ||
| +++ src/bisect.c | ||
| @@ -390,11 +390,11 @@ | ||
| 390 | 390 | for(i=0; i<sizeof(aBisectOption)/sizeof(aBisectOption[0]); i++){ |
| 391 | 391 | char *z = mprintf("bisect-%s", aBisectOption[i].zName); |
| 392 | 392 | fossil_print(" %-15s %-6s ", aBisectOption[i].zName, |
| 393 | 393 | db_lget(z, (char*)aBisectOption[i].zDefault)); |
| 394 | 394 | fossil_free(z); |
| 395 | - comment_print(aBisectOption[i].zDesc, 27, -1, g.comFmtFlags); | |
| 395 | + comment_print(aBisectOption[i].zDesc, 0, 27, -1, g.comFmtFlags); | |
| 396 | 396 | } |
| 397 | 397 | }else if( g.argc==4 || g.argc==5 ){ |
| 398 | 398 | unsigned int i; |
| 399 | 399 | n = strlen(g.argv[3]); |
| 400 | 400 | for(i=0; i<sizeof(aBisectOption)/sizeof(aBisectOption[0]); i++){ |
| 401 | 401 |
| --- src/bisect.c | |
| +++ src/bisect.c | |
| @@ -390,11 +390,11 @@ | |
| 390 | for(i=0; i<sizeof(aBisectOption)/sizeof(aBisectOption[0]); i++){ |
| 391 | char *z = mprintf("bisect-%s", aBisectOption[i].zName); |
| 392 | fossil_print(" %-15s %-6s ", aBisectOption[i].zName, |
| 393 | db_lget(z, (char*)aBisectOption[i].zDefault)); |
| 394 | fossil_free(z); |
| 395 | comment_print(aBisectOption[i].zDesc, 27, -1, g.comFmtFlags); |
| 396 | } |
| 397 | }else if( g.argc==4 || g.argc==5 ){ |
| 398 | unsigned int i; |
| 399 | n = strlen(g.argv[3]); |
| 400 | for(i=0; i<sizeof(aBisectOption)/sizeof(aBisectOption[0]); i++){ |
| 401 |
| --- src/bisect.c | |
| +++ src/bisect.c | |
| @@ -390,11 +390,11 @@ | |
| 390 | for(i=0; i<sizeof(aBisectOption)/sizeof(aBisectOption[0]); i++){ |
| 391 | char *z = mprintf("bisect-%s", aBisectOption[i].zName); |
| 392 | fossil_print(" %-15s %-6s ", aBisectOption[i].zName, |
| 393 | db_lget(z, (char*)aBisectOption[i].zDefault)); |
| 394 | fossil_free(z); |
| 395 | comment_print(aBisectOption[i].zDesc, 0, 27, -1, g.comFmtFlags); |
| 396 | } |
| 397 | }else if( g.argc==4 || g.argc==5 ){ |
| 398 | unsigned int i; |
| 399 | n = strlen(g.argv[3]); |
| 400 | for(i=0; i<sizeof(aBisectOption)/sizeof(aBisectOption[0]); i++){ |
| 401 |
+77
-22
| --- src/comformat.c | ||
| +++ src/comformat.c | ||
| @@ -33,10 +33,11 @@ | ||
| 33 | 33 | #if INTERFACE |
| 34 | 34 | #define COMMENT_PRINT_NONE ((u32)0x00000000) /* No flags. */ |
| 35 | 35 | #define COMMENT_PRINT_LEGACY ((u32)0x00000001) /* Use legacy algorithm. */ |
| 36 | 36 | #define COMMENT_PRINT_TRIM_SPACE ((u32)0x00000002) /* Trim leading/trailing. */ |
| 37 | 37 | #define COMMENT_PRINT_WORD_BREAK ((u32)0x00000004) /* Break lines on words. */ |
| 38 | +#define COMMENT_PRINT_ORIG_BREAK ((u32)0x00000008) /* Break before original. */ | |
| 38 | 39 | #define COMMENT_PRINT_DEFAULT (COMMENT_PRINT_LEGACY) /* Defaults. */ |
| 39 | 40 | #endif |
| 40 | 41 | |
| 41 | 42 | /* |
| 42 | 43 | ** This is the previous value used by most external callers when they |
| @@ -51,10 +52,30 @@ | ||
| 51 | 52 | ** This is the number of spaces to print when a tab character is seen. |
| 52 | 53 | */ |
| 53 | 54 | #ifndef COMMENT_TAB_WIDTH |
| 54 | 55 | # define COMMENT_TAB_WIDTH (8) |
| 55 | 56 | #endif |
| 57 | + | |
| 58 | +/* | |
| 59 | +** This function checks the current line being printed against the original | |
| 60 | +** comment text. Upon matching, it emits a new line and updates the provided | |
| 61 | +** character and line counts, if applicable. | |
| 62 | +*/ | |
| 63 | +static int comment_check_orig( | |
| 64 | + const char *zOrigText, /* [in] Original comment text ONLY, may be NULL. */ | |
| 65 | + const char *zLine, /* [in] The comment line to print. */ | |
| 66 | + int *pCharCnt, /* [in/out] Pointer to the line character count. */ | |
| 67 | + int *pLineCnt /* [in/out] Pointer to the total line count. */ | |
| 68 | +){ | |
| 69 | + if( zOrigText && fossil_strcmp(zLine, zOrigText)==0 ){ | |
| 70 | + fossil_print("\n"); | |
| 71 | + if( pCharCnt ) *pCharCnt = 0; | |
| 72 | + if( pLineCnt ) (*pLineCnt)++; | |
| 73 | + return 1; | |
| 74 | + } | |
| 75 | + return 0; | |
| 76 | +} | |
| 56 | 77 | |
| 57 | 78 | /* |
| 58 | 79 | ** This function scans the specified comment line starting just after the |
| 59 | 80 | ** initial index and returns the index of the next spacing character -OR- |
| 60 | 81 | ** zero if such a character cannot be found. For the purposes of this |
| @@ -98,17 +119,19 @@ | ||
| 98 | 119 | /* |
| 99 | 120 | ** This function prints one logical line of a comment, stopping when it hits |
| 100 | 121 | ** a new line -OR- runs out of space on the logical line. |
| 101 | 122 | */ |
| 102 | 123 | static void comment_print_line( |
| 103 | - const char *zLine, /* [in] The comment line to print. */ | |
| 104 | - int indent, /* [in] Number of spaces to indent, zero for none. */ | |
| 105 | - int lineChars, /* [in] Maximum number of characters to print. */ | |
| 106 | - int trimSpace, /* [in] Non-zero to trim leading/trailing spaces. */ | |
| 107 | - int wordBreak, /* [in] Non-zero to try breaking on word boundaries. */ | |
| 108 | - int *pLineCnt, /* [in/out] Pointer to the total line count. */ | |
| 109 | - const char **pzLine /* [out] Pointer to the end of the logical line. */ | |
| 124 | + const char *zOrigText, /* [in] Original comment text ONLY, may be NULL. */ | |
| 125 | + const char *zLine, /* [in] The comment line to print. */ | |
| 126 | + int indent, /* [in] Number of spaces to indent, zero for none. */ | |
| 127 | + int lineChars, /* [in] Maximum number of characters to print. */ | |
| 128 | + int trimSpace, /* [in] Non-zero to trim leading/trailing spaces. */ | |
| 129 | + int wordBreak, /* [in] Non-zero to try breaking on word boundaries. */ | |
| 130 | + int origBreak, /* [in] Non-zero to break before original comment. */ | |
| 131 | + int *pLineCnt, /* [in/out] Pointer to the total line count. */ | |
| 132 | + const char **pzLine /* [out] Pointer to the end of the logical line. */ | |
| 110 | 133 | ){ |
| 111 | 134 | int index = 0, charCnt = 0, lineCnt = 0, maxChars; |
| 112 | 135 | if( !zLine ) return; |
| 113 | 136 | if( lineChars<=0 ) return; |
| 114 | 137 | comment_print_indent(zLine, indent, trimSpace, &index); |
| @@ -116,10 +139,15 @@ | ||
| 116 | 139 | for(;;){ |
| 117 | 140 | char c = zLine[index]; |
| 118 | 141 | if( c==0 ){ |
| 119 | 142 | break; |
| 120 | 143 | }else{ |
| 144 | + if( origBreak && index>0 ){ | |
| 145 | + if( comment_check_orig(zOrigText, &zLine[index], &charCnt, &lineCnt) ){ | |
| 146 | + maxChars = lineChars; | |
| 147 | + } | |
| 148 | + } | |
| 121 | 149 | index++; |
| 122 | 150 | } |
| 123 | 151 | if( c=='\n' ){ |
| 124 | 152 | charCnt = 0; |
| 125 | 153 | lineCnt++; |
| @@ -284,28 +312,35 @@ | ||
| 284 | 312 | ** If this flag is not specified, honoring the |
| 285 | 313 | ** logical line length may result in breaking |
| 286 | 314 | ** lines in the middle of words. This flag |
| 287 | 315 | ** does not apply to the legacy comment |
| 288 | 316 | ** printing algorithm. |
| 317 | +** | |
| 318 | +** COMMENT_PRINT_ORIG_BREAK: Looks for the original comment text within | |
| 319 | +** the text being printed. Upon matching, a | |
| 320 | +** new line will be emitted, thus preserving | |
| 321 | +** more of the existing formatting. | |
| 289 | 322 | ** |
| 290 | 323 | ** Given a comment string, format that string for printing on a TTY. |
| 291 | 324 | ** Assume that the output cursors is indent spaces from the left margin |
| 292 | 325 | ** and that a single line can contain no more than 'width' characters. |
| 293 | 326 | ** Indent all subsequent lines by 'indent'. |
| 294 | 327 | ** |
| 295 | 328 | ** Returns the number of new lines emitted. |
| 296 | 329 | */ |
| 297 | 330 | int comment_print( |
| 298 | - const char *zText, /* The comment text to be printed. */ | |
| 299 | - int indent, /* Number of spaces to indent each non-initial line. */ | |
| 300 | - int width, /* Maximum number of characters per line. */ | |
| 301 | - int flags /* Zero or more "COMMENT_PRINT_*" flags, see above. */ | |
| 331 | + const char *zText, /* The comment text to be printed. */ | |
| 332 | + const char *zOrigText, /* Original comment text ONLY, may be NULL. */ | |
| 333 | + int indent, /* Spaces to indent each non-initial line. */ | |
| 334 | + int width, /* Maximum number of characters per line. */ | |
| 335 | + int flags /* Zero or more "COMMENT_PRINT_*" flags. */ | |
| 302 | 336 | ){ |
| 303 | 337 | int maxChars = width - indent; |
| 304 | 338 | int legacy = flags & COMMENT_PRINT_LEGACY; |
| 305 | 339 | int trimSpace = flags & COMMENT_PRINT_TRIM_SPACE; |
| 306 | 340 | int wordBreak = flags & COMMENT_PRINT_WORD_BREAK; |
| 341 | + int origBreak = flags & COMMENT_PRINT_ORIG_BREAK; | |
| 307 | 342 | int lineCnt = 0; |
| 308 | 343 | const char *zLine; |
| 309 | 344 | |
| 310 | 345 | if( legacy ){ |
| 311 | 346 | return comment_print_legacy(zText, indent, width); |
| @@ -348,22 +383,22 @@ | ||
| 348 | 383 | lineCnt++; |
| 349 | 384 | return lineCnt; |
| 350 | 385 | } |
| 351 | 386 | zLine = zText; |
| 352 | 387 | for(;;){ |
| 353 | - comment_print_line(zLine, zLine>zText ? indent : 0, maxChars, | |
| 354 | - trimSpace, wordBreak, &lineCnt, &zLine); | |
| 388 | + comment_print_line(zOrigText, zLine, zLine>zText ? indent : 0, maxChars, | |
| 389 | + trimSpace, wordBreak, origBreak, &lineCnt, &zLine); | |
| 355 | 390 | if( !zLine || !zLine[0] ) break; |
| 356 | 391 | } |
| 357 | 392 | return lineCnt; |
| 358 | 393 | } |
| 359 | 394 | |
| 360 | 395 | /* |
| 361 | 396 | ** |
| 362 | 397 | ** COMMAND: test-comment-format |
| 363 | 398 | ** |
| 364 | -** Usage: %fossil test-comment-format ?OPTIONS? PREFIX TEXT ?WIDTH? | |
| 399 | +** Usage: %fossil test-comment-format ?OPTIONS? PREFIX TEXT ?ORIGTEXT? | |
| 365 | 400 | ** |
| 366 | 401 | ** Test comment formatting and printing. Use for testing only. |
| 367 | 402 | ** |
| 368 | 403 | ** Options: |
| 369 | 404 | ** --file The comment text is really just a file name to |
| @@ -371,14 +406,20 @@ | ||
| 371 | 406 | ** --decode Decode the text using the same method used when |
| 372 | 407 | ** handling the value of a C-card from a manifest. |
| 373 | 408 | ** --legacy Use the legacy comment printing algorithm. |
| 374 | 409 | ** --trimspace Enable trimming of leading/trailing spaces. |
| 375 | 410 | ** --wordbreak Attempt to break lines on word boundaries. |
| 411 | +** --origbreak Attempt to break when the original comment text | |
| 412 | +** is detected. | |
| 413 | +** -W|--width <num> Width of lines (default (-1) is to auto-detect). | |
| 414 | +** Zero means no limit. | |
| 376 | 415 | */ |
| 377 | 416 | void test_comment_format(void){ |
| 417 | + const char *zWidth; | |
| 378 | 418 | const char *zPrefix; |
| 379 | 419 | char *zText; |
| 420 | + char *zOrigText; | |
| 380 | 421 | int indent, width; |
| 381 | 422 | int fromFile = find_option("file", 0, 0)!=0; |
| 382 | 423 | int decode = find_option("decode", 0, 0)!=0; |
| 383 | 424 | int flags = COMMENT_PRINT_NONE; |
| 384 | 425 | if( find_option("legacy", 0, 0) ){ |
| @@ -388,33 +429,47 @@ | ||
| 388 | 429 | flags |= COMMENT_PRINT_TRIM_SPACE; |
| 389 | 430 | } |
| 390 | 431 | if( find_option("wordbreak", 0, 0) ){ |
| 391 | 432 | flags |= COMMENT_PRINT_WORD_BREAK; |
| 392 | 433 | } |
| 434 | + if( find_option("origbreak", 0, 0) ){ | |
| 435 | + flags |= COMMENT_PRINT_ORIG_BREAK; | |
| 436 | + } | |
| 437 | + zWidth = find_option("width","W",1); | |
| 438 | + if( zWidth ){ | |
| 439 | + width = atoi(zWidth); | |
| 440 | + }else{ | |
| 441 | + width = -1; /* automatic */ | |
| 442 | + } | |
| 393 | 443 | if( g.argc!=4 && g.argc!=5 ){ |
| 394 | - usage("?OPTIONS? PREFIX TEXT ?WIDTH?"); | |
| 444 | + usage("?OPTIONS? PREFIX TEXT ?ORIGTEXT?"); | |
| 395 | 445 | } |
| 396 | 446 | zPrefix = g.argv[2]; |
| 397 | 447 | zText = g.argv[3]; |
| 448 | + if( g.argc==5 ){ | |
| 449 | + zOrigText = g.argv[4]; | |
| 450 | + }else{ | |
| 451 | + zOrigText = 0; | |
| 452 | + } | |
| 398 | 453 | if( fromFile ){ |
| 399 | 454 | Blob fileData; |
| 400 | 455 | blob_read_from_file(&fileData, zText); |
| 401 | 456 | zText = mprintf("%s", blob_str(&fileData)); |
| 402 | 457 | blob_reset(&fileData); |
| 403 | 458 | } |
| 404 | 459 | if( decode ){ |
| 405 | 460 | zText = mprintf("%s", zText); |
| 406 | 461 | defossilize(zText); |
| 462 | + if( zOrigText ){ | |
| 463 | + zOrigText = mprintf("%s", zOrigText); | |
| 464 | + defossilize(zOrigText); | |
| 465 | + } | |
| 407 | 466 | } |
| 408 | 467 | indent = strlen(zPrefix); |
| 409 | - if( g.argc==5 ){ | |
| 410 | - width = atoi(g.argv[4]); | |
| 411 | - }else{ | |
| 412 | - width = -1; /* automatic */ | |
| 413 | - } | |
| 414 | 468 | if( indent>0 ){ |
| 415 | 469 | fossil_print("%s", zPrefix); |
| 416 | 470 | } |
| 417 | 471 | fossil_print("(%d lines output)\n", |
| 418 | - comment_print(zText, indent, width, flags)); | |
| 419 | - if( zText!=g.argv[3] ) fossil_free(zText); | |
| 472 | + comment_print(zText, zOrigText, indent, width, flags)); | |
| 473 | + if( zOrigText && zOrigText!=g.argv[4] ) fossil_free(zOrigText); | |
| 474 | + if( zText && zText!=g.argv[3] ) fossil_free(zText); | |
| 420 | 475 | } |
| 421 | 476 |
| --- src/comformat.c | |
| +++ src/comformat.c | |
| @@ -33,10 +33,11 @@ | |
| 33 | #if INTERFACE |
| 34 | #define COMMENT_PRINT_NONE ((u32)0x00000000) /* No flags. */ |
| 35 | #define COMMENT_PRINT_LEGACY ((u32)0x00000001) /* Use legacy algorithm. */ |
| 36 | #define COMMENT_PRINT_TRIM_SPACE ((u32)0x00000002) /* Trim leading/trailing. */ |
| 37 | #define COMMENT_PRINT_WORD_BREAK ((u32)0x00000004) /* Break lines on words. */ |
| 38 | #define COMMENT_PRINT_DEFAULT (COMMENT_PRINT_LEGACY) /* Defaults. */ |
| 39 | #endif |
| 40 | |
| 41 | /* |
| 42 | ** This is the previous value used by most external callers when they |
| @@ -51,10 +52,30 @@ | |
| 51 | ** This is the number of spaces to print when a tab character is seen. |
| 52 | */ |
| 53 | #ifndef COMMENT_TAB_WIDTH |
| 54 | # define COMMENT_TAB_WIDTH (8) |
| 55 | #endif |
| 56 | |
| 57 | /* |
| 58 | ** This function scans the specified comment line starting just after the |
| 59 | ** initial index and returns the index of the next spacing character -OR- |
| 60 | ** zero if such a character cannot be found. For the purposes of this |
| @@ -98,17 +119,19 @@ | |
| 98 | /* |
| 99 | ** This function prints one logical line of a comment, stopping when it hits |
| 100 | ** a new line -OR- runs out of space on the logical line. |
| 101 | */ |
| 102 | static void comment_print_line( |
| 103 | const char *zLine, /* [in] The comment line to print. */ |
| 104 | int indent, /* [in] Number of spaces to indent, zero for none. */ |
| 105 | int lineChars, /* [in] Maximum number of characters to print. */ |
| 106 | int trimSpace, /* [in] Non-zero to trim leading/trailing spaces. */ |
| 107 | int wordBreak, /* [in] Non-zero to try breaking on word boundaries. */ |
| 108 | int *pLineCnt, /* [in/out] Pointer to the total line count. */ |
| 109 | const char **pzLine /* [out] Pointer to the end of the logical line. */ |
| 110 | ){ |
| 111 | int index = 0, charCnt = 0, lineCnt = 0, maxChars; |
| 112 | if( !zLine ) return; |
| 113 | if( lineChars<=0 ) return; |
| 114 | comment_print_indent(zLine, indent, trimSpace, &index); |
| @@ -116,10 +139,15 @@ | |
| 116 | for(;;){ |
| 117 | char c = zLine[index]; |
| 118 | if( c==0 ){ |
| 119 | break; |
| 120 | }else{ |
| 121 | index++; |
| 122 | } |
| 123 | if( c=='\n' ){ |
| 124 | charCnt = 0; |
| 125 | lineCnt++; |
| @@ -284,28 +312,35 @@ | |
| 284 | ** If this flag is not specified, honoring the |
| 285 | ** logical line length may result in breaking |
| 286 | ** lines in the middle of words. This flag |
| 287 | ** does not apply to the legacy comment |
| 288 | ** printing algorithm. |
| 289 | ** |
| 290 | ** Given a comment string, format that string for printing on a TTY. |
| 291 | ** Assume that the output cursors is indent spaces from the left margin |
| 292 | ** and that a single line can contain no more than 'width' characters. |
| 293 | ** Indent all subsequent lines by 'indent'. |
| 294 | ** |
| 295 | ** Returns the number of new lines emitted. |
| 296 | */ |
| 297 | int comment_print( |
| 298 | const char *zText, /* The comment text to be printed. */ |
| 299 | int indent, /* Number of spaces to indent each non-initial line. */ |
| 300 | int width, /* Maximum number of characters per line. */ |
| 301 | int flags /* Zero or more "COMMENT_PRINT_*" flags, see above. */ |
| 302 | ){ |
| 303 | int maxChars = width - indent; |
| 304 | int legacy = flags & COMMENT_PRINT_LEGACY; |
| 305 | int trimSpace = flags & COMMENT_PRINT_TRIM_SPACE; |
| 306 | int wordBreak = flags & COMMENT_PRINT_WORD_BREAK; |
| 307 | int lineCnt = 0; |
| 308 | const char *zLine; |
| 309 | |
| 310 | if( legacy ){ |
| 311 | return comment_print_legacy(zText, indent, width); |
| @@ -348,22 +383,22 @@ | |
| 348 | lineCnt++; |
| 349 | return lineCnt; |
| 350 | } |
| 351 | zLine = zText; |
| 352 | for(;;){ |
| 353 | comment_print_line(zLine, zLine>zText ? indent : 0, maxChars, |
| 354 | trimSpace, wordBreak, &lineCnt, &zLine); |
| 355 | if( !zLine || !zLine[0] ) break; |
| 356 | } |
| 357 | return lineCnt; |
| 358 | } |
| 359 | |
| 360 | /* |
| 361 | ** |
| 362 | ** COMMAND: test-comment-format |
| 363 | ** |
| 364 | ** Usage: %fossil test-comment-format ?OPTIONS? PREFIX TEXT ?WIDTH? |
| 365 | ** |
| 366 | ** Test comment formatting and printing. Use for testing only. |
| 367 | ** |
| 368 | ** Options: |
| 369 | ** --file The comment text is really just a file name to |
| @@ -371,14 +406,20 @@ | |
| 371 | ** --decode Decode the text using the same method used when |
| 372 | ** handling the value of a C-card from a manifest. |
| 373 | ** --legacy Use the legacy comment printing algorithm. |
| 374 | ** --trimspace Enable trimming of leading/trailing spaces. |
| 375 | ** --wordbreak Attempt to break lines on word boundaries. |
| 376 | */ |
| 377 | void test_comment_format(void){ |
| 378 | const char *zPrefix; |
| 379 | char *zText; |
| 380 | int indent, width; |
| 381 | int fromFile = find_option("file", 0, 0)!=0; |
| 382 | int decode = find_option("decode", 0, 0)!=0; |
| 383 | int flags = COMMENT_PRINT_NONE; |
| 384 | if( find_option("legacy", 0, 0) ){ |
| @@ -388,33 +429,47 @@ | |
| 388 | flags |= COMMENT_PRINT_TRIM_SPACE; |
| 389 | } |
| 390 | if( find_option("wordbreak", 0, 0) ){ |
| 391 | flags |= COMMENT_PRINT_WORD_BREAK; |
| 392 | } |
| 393 | if( g.argc!=4 && g.argc!=5 ){ |
| 394 | usage("?OPTIONS? PREFIX TEXT ?WIDTH?"); |
| 395 | } |
| 396 | zPrefix = g.argv[2]; |
| 397 | zText = g.argv[3]; |
| 398 | if( fromFile ){ |
| 399 | Blob fileData; |
| 400 | blob_read_from_file(&fileData, zText); |
| 401 | zText = mprintf("%s", blob_str(&fileData)); |
| 402 | blob_reset(&fileData); |
| 403 | } |
| 404 | if( decode ){ |
| 405 | zText = mprintf("%s", zText); |
| 406 | defossilize(zText); |
| 407 | } |
| 408 | indent = strlen(zPrefix); |
| 409 | if( g.argc==5 ){ |
| 410 | width = atoi(g.argv[4]); |
| 411 | }else{ |
| 412 | width = -1; /* automatic */ |
| 413 | } |
| 414 | if( indent>0 ){ |
| 415 | fossil_print("%s", zPrefix); |
| 416 | } |
| 417 | fossil_print("(%d lines output)\n", |
| 418 | comment_print(zText, indent, width, flags)); |
| 419 | if( zText!=g.argv[3] ) fossil_free(zText); |
| 420 | } |
| 421 |
| --- src/comformat.c | |
| +++ src/comformat.c | |
| @@ -33,10 +33,11 @@ | |
| 33 | #if INTERFACE |
| 34 | #define COMMENT_PRINT_NONE ((u32)0x00000000) /* No flags. */ |
| 35 | #define COMMENT_PRINT_LEGACY ((u32)0x00000001) /* Use legacy algorithm. */ |
| 36 | #define COMMENT_PRINT_TRIM_SPACE ((u32)0x00000002) /* Trim leading/trailing. */ |
| 37 | #define COMMENT_PRINT_WORD_BREAK ((u32)0x00000004) /* Break lines on words. */ |
| 38 | #define COMMENT_PRINT_ORIG_BREAK ((u32)0x00000008) /* Break before original. */ |
| 39 | #define COMMENT_PRINT_DEFAULT (COMMENT_PRINT_LEGACY) /* Defaults. */ |
| 40 | #endif |
| 41 | |
| 42 | /* |
| 43 | ** This is the previous value used by most external callers when they |
| @@ -51,10 +52,30 @@ | |
| 52 | ** This is the number of spaces to print when a tab character is seen. |
| 53 | */ |
| 54 | #ifndef COMMENT_TAB_WIDTH |
| 55 | # define COMMENT_TAB_WIDTH (8) |
| 56 | #endif |
| 57 | |
| 58 | /* |
| 59 | ** This function checks the current line being printed against the original |
| 60 | ** comment text. Upon matching, it emits a new line and updates the provided |
| 61 | ** character and line counts, if applicable. |
| 62 | */ |
| 63 | static int comment_check_orig( |
| 64 | const char *zOrigText, /* [in] Original comment text ONLY, may be NULL. */ |
| 65 | const char *zLine, /* [in] The comment line to print. */ |
| 66 | int *pCharCnt, /* [in/out] Pointer to the line character count. */ |
| 67 | int *pLineCnt /* [in/out] Pointer to the total line count. */ |
| 68 | ){ |
| 69 | if( zOrigText && fossil_strcmp(zLine, zOrigText)==0 ){ |
| 70 | fossil_print("\n"); |
| 71 | if( pCharCnt ) *pCharCnt = 0; |
| 72 | if( pLineCnt ) (*pLineCnt)++; |
| 73 | return 1; |
| 74 | } |
| 75 | return 0; |
| 76 | } |
| 77 | |
| 78 | /* |
| 79 | ** This function scans the specified comment line starting just after the |
| 80 | ** initial index and returns the index of the next spacing character -OR- |
| 81 | ** zero if such a character cannot be found. For the purposes of this |
| @@ -98,17 +119,19 @@ | |
| 119 | /* |
| 120 | ** This function prints one logical line of a comment, stopping when it hits |
| 121 | ** a new line -OR- runs out of space on the logical line. |
| 122 | */ |
| 123 | static void comment_print_line( |
| 124 | const char *zOrigText, /* [in] Original comment text ONLY, may be NULL. */ |
| 125 | const char *zLine, /* [in] The comment line to print. */ |
| 126 | int indent, /* [in] Number of spaces to indent, zero for none. */ |
| 127 | int lineChars, /* [in] Maximum number of characters to print. */ |
| 128 | int trimSpace, /* [in] Non-zero to trim leading/trailing spaces. */ |
| 129 | int wordBreak, /* [in] Non-zero to try breaking on word boundaries. */ |
| 130 | int origBreak, /* [in] Non-zero to break before original comment. */ |
| 131 | int *pLineCnt, /* [in/out] Pointer to the total line count. */ |
| 132 | const char **pzLine /* [out] Pointer to the end of the logical line. */ |
| 133 | ){ |
| 134 | int index = 0, charCnt = 0, lineCnt = 0, maxChars; |
| 135 | if( !zLine ) return; |
| 136 | if( lineChars<=0 ) return; |
| 137 | comment_print_indent(zLine, indent, trimSpace, &index); |
| @@ -116,10 +139,15 @@ | |
| 139 | for(;;){ |
| 140 | char c = zLine[index]; |
| 141 | if( c==0 ){ |
| 142 | break; |
| 143 | }else{ |
| 144 | if( origBreak && index>0 ){ |
| 145 | if( comment_check_orig(zOrigText, &zLine[index], &charCnt, &lineCnt) ){ |
| 146 | maxChars = lineChars; |
| 147 | } |
| 148 | } |
| 149 | index++; |
| 150 | } |
| 151 | if( c=='\n' ){ |
| 152 | charCnt = 0; |
| 153 | lineCnt++; |
| @@ -284,28 +312,35 @@ | |
| 312 | ** If this flag is not specified, honoring the |
| 313 | ** logical line length may result in breaking |
| 314 | ** lines in the middle of words. This flag |
| 315 | ** does not apply to the legacy comment |
| 316 | ** printing algorithm. |
| 317 | ** |
| 318 | ** COMMENT_PRINT_ORIG_BREAK: Looks for the original comment text within |
| 319 | ** the text being printed. Upon matching, a |
| 320 | ** new line will be emitted, thus preserving |
| 321 | ** more of the existing formatting. |
| 322 | ** |
| 323 | ** Given a comment string, format that string for printing on a TTY. |
| 324 | ** Assume that the output cursors is indent spaces from the left margin |
| 325 | ** and that a single line can contain no more than 'width' characters. |
| 326 | ** Indent all subsequent lines by 'indent'. |
| 327 | ** |
| 328 | ** Returns the number of new lines emitted. |
| 329 | */ |
| 330 | int comment_print( |
| 331 | const char *zText, /* The comment text to be printed. */ |
| 332 | const char *zOrigText, /* Original comment text ONLY, may be NULL. */ |
| 333 | int indent, /* Spaces to indent each non-initial line. */ |
| 334 | int width, /* Maximum number of characters per line. */ |
| 335 | int flags /* Zero or more "COMMENT_PRINT_*" flags. */ |
| 336 | ){ |
| 337 | int maxChars = width - indent; |
| 338 | int legacy = flags & COMMENT_PRINT_LEGACY; |
| 339 | int trimSpace = flags & COMMENT_PRINT_TRIM_SPACE; |
| 340 | int wordBreak = flags & COMMENT_PRINT_WORD_BREAK; |
| 341 | int origBreak = flags & COMMENT_PRINT_ORIG_BREAK; |
| 342 | int lineCnt = 0; |
| 343 | const char *zLine; |
| 344 | |
| 345 | if( legacy ){ |
| 346 | return comment_print_legacy(zText, indent, width); |
| @@ -348,22 +383,22 @@ | |
| 383 | lineCnt++; |
| 384 | return lineCnt; |
| 385 | } |
| 386 | zLine = zText; |
| 387 | for(;;){ |
| 388 | comment_print_line(zOrigText, zLine, zLine>zText ? indent : 0, maxChars, |
| 389 | trimSpace, wordBreak, origBreak, &lineCnt, &zLine); |
| 390 | if( !zLine || !zLine[0] ) break; |
| 391 | } |
| 392 | return lineCnt; |
| 393 | } |
| 394 | |
| 395 | /* |
| 396 | ** |
| 397 | ** COMMAND: test-comment-format |
| 398 | ** |
| 399 | ** Usage: %fossil test-comment-format ?OPTIONS? PREFIX TEXT ?ORIGTEXT? |
| 400 | ** |
| 401 | ** Test comment formatting and printing. Use for testing only. |
| 402 | ** |
| 403 | ** Options: |
| 404 | ** --file The comment text is really just a file name to |
| @@ -371,14 +406,20 @@ | |
| 406 | ** --decode Decode the text using the same method used when |
| 407 | ** handling the value of a C-card from a manifest. |
| 408 | ** --legacy Use the legacy comment printing algorithm. |
| 409 | ** --trimspace Enable trimming of leading/trailing spaces. |
| 410 | ** --wordbreak Attempt to break lines on word boundaries. |
| 411 | ** --origbreak Attempt to break when the original comment text |
| 412 | ** is detected. |
| 413 | ** -W|--width <num> Width of lines (default (-1) is to auto-detect). |
| 414 | ** Zero means no limit. |
| 415 | */ |
| 416 | void test_comment_format(void){ |
| 417 | const char *zWidth; |
| 418 | const char *zPrefix; |
| 419 | char *zText; |
| 420 | char *zOrigText; |
| 421 | int indent, width; |
| 422 | int fromFile = find_option("file", 0, 0)!=0; |
| 423 | int decode = find_option("decode", 0, 0)!=0; |
| 424 | int flags = COMMENT_PRINT_NONE; |
| 425 | if( find_option("legacy", 0, 0) ){ |
| @@ -388,33 +429,47 @@ | |
| 429 | flags |= COMMENT_PRINT_TRIM_SPACE; |
| 430 | } |
| 431 | if( find_option("wordbreak", 0, 0) ){ |
| 432 | flags |= COMMENT_PRINT_WORD_BREAK; |
| 433 | } |
| 434 | if( find_option("origbreak", 0, 0) ){ |
| 435 | flags |= COMMENT_PRINT_ORIG_BREAK; |
| 436 | } |
| 437 | zWidth = find_option("width","W",1); |
| 438 | if( zWidth ){ |
| 439 | width = atoi(zWidth); |
| 440 | }else{ |
| 441 | width = -1; /* automatic */ |
| 442 | } |
| 443 | if( g.argc!=4 && g.argc!=5 ){ |
| 444 | usage("?OPTIONS? PREFIX TEXT ?ORIGTEXT?"); |
| 445 | } |
| 446 | zPrefix = g.argv[2]; |
| 447 | zText = g.argv[3]; |
| 448 | if( g.argc==5 ){ |
| 449 | zOrigText = g.argv[4]; |
| 450 | }else{ |
| 451 | zOrigText = 0; |
| 452 | } |
| 453 | if( fromFile ){ |
| 454 | Blob fileData; |
| 455 | blob_read_from_file(&fileData, zText); |
| 456 | zText = mprintf("%s", blob_str(&fileData)); |
| 457 | blob_reset(&fileData); |
| 458 | } |
| 459 | if( decode ){ |
| 460 | zText = mprintf("%s", zText); |
| 461 | defossilize(zText); |
| 462 | if( zOrigText ){ |
| 463 | zOrigText = mprintf("%s", zOrigText); |
| 464 | defossilize(zOrigText); |
| 465 | } |
| 466 | } |
| 467 | indent = strlen(zPrefix); |
| 468 | if( indent>0 ){ |
| 469 | fossil_print("%s", zPrefix); |
| 470 | } |
| 471 | fossil_print("(%d lines output)\n", |
| 472 | comment_print(zText, zOrigText, indent, width, flags)); |
| 473 | if( zOrigText && zOrigText!=g.argv[4] ) fossil_free(zOrigText); |
| 474 | if( zText && zText!=g.argv[3] ) fossil_free(zText); |
| 475 | } |
| 476 |
+1
-1
| --- src/descendants.c | ||
| +++ src/descendants.c | ||
| @@ -407,11 +407,11 @@ | ||
| 407 | 407 | } |
| 408 | 408 | n++; |
| 409 | 409 | sqlite3_snprintf(sizeof(zLineNo), zLineNo, "(%d)", n); |
| 410 | 410 | fossil_print("%6s ", zLineNo); |
| 411 | 411 | z = mprintf("%s [%S] %s", zDate, zId, zCom); |
| 412 | - comment_print(z, 7, width, g.comFmtFlags); | |
| 412 | + comment_print(z, zCom, 7, width, g.comFmtFlags); | |
| 413 | 413 | fossil_free(z); |
| 414 | 414 | } |
| 415 | 415 | fossil_free(zLastBr); |
| 416 | 416 | db_finalize(&q); |
| 417 | 417 | } |
| 418 | 418 |
| --- src/descendants.c | |
| +++ src/descendants.c | |
| @@ -407,11 +407,11 @@ | |
| 407 | } |
| 408 | n++; |
| 409 | sqlite3_snprintf(sizeof(zLineNo), zLineNo, "(%d)", n); |
| 410 | fossil_print("%6s ", zLineNo); |
| 411 | z = mprintf("%s [%S] %s", zDate, zId, zCom); |
| 412 | comment_print(z, 7, width, g.comFmtFlags); |
| 413 | fossil_free(z); |
| 414 | } |
| 415 | fossil_free(zLastBr); |
| 416 | db_finalize(&q); |
| 417 | } |
| 418 |
| --- src/descendants.c | |
| +++ src/descendants.c | |
| @@ -407,11 +407,11 @@ | |
| 407 | } |
| 408 | n++; |
| 409 | sqlite3_snprintf(sizeof(zLineNo), zLineNo, "(%d)", n); |
| 410 | fossil_print("%6s ", zLineNo); |
| 411 | z = mprintf("%s [%S] %s", zDate, zId, zCom); |
| 412 | comment_print(z, zCom, 7, width, g.comFmtFlags); |
| 413 | fossil_free(z); |
| 414 | } |
| 415 | fossil_free(zLastBr); |
| 416 | db_finalize(&q); |
| 417 | } |
| 418 |
+2
-2
| --- src/finfo.c | ||
| +++ src/finfo.c | ||
| @@ -202,20 +202,20 @@ | ||
| 202 | 202 | if( iBrief ){ |
| 203 | 203 | fossil_print("%s ", zDate); |
| 204 | 204 | zOut = sqlite3_mprintf( |
| 205 | 205 | "[%S] %s (user: %s, artifact: [%S], branch: %s)", |
| 206 | 206 | zCiUuid, zCom, zUser, zFileUuid, zBr); |
| 207 | - comment_print(zOut, 11, iWidth, g.comFmtFlags); | |
| 207 | + comment_print(zOut, zCom, 11, iWidth, g.comFmtFlags); | |
| 208 | 208 | sqlite3_free(zOut); |
| 209 | 209 | }else{ |
| 210 | 210 | blob_reset(&line); |
| 211 | 211 | blob_appendf(&line, "%.10s ", zCiUuid); |
| 212 | 212 | blob_appendf(&line, "%.10s ", zDate); |
| 213 | 213 | blob_appendf(&line, "%8.8s ", zUser); |
| 214 | 214 | blob_appendf(&line, "%8.8s ", zBr); |
| 215 | 215 | blob_appendf(&line,"%-39.39s", zCom ); |
| 216 | - comment_print(blob_str(&line), 0, iWidth, g.comFmtFlags); | |
| 216 | + comment_print(blob_str(&line), zCom, 0, iWidth, g.comFmtFlags); | |
| 217 | 217 | } |
| 218 | 218 | } |
| 219 | 219 | db_finalize(&q); |
| 220 | 220 | blob_reset(&fname); |
| 221 | 221 | } |
| 222 | 222 |
| --- src/finfo.c | |
| +++ src/finfo.c | |
| @@ -202,20 +202,20 @@ | |
| 202 | if( iBrief ){ |
| 203 | fossil_print("%s ", zDate); |
| 204 | zOut = sqlite3_mprintf( |
| 205 | "[%S] %s (user: %s, artifact: [%S], branch: %s)", |
| 206 | zCiUuid, zCom, zUser, zFileUuid, zBr); |
| 207 | comment_print(zOut, 11, iWidth, g.comFmtFlags); |
| 208 | sqlite3_free(zOut); |
| 209 | }else{ |
| 210 | blob_reset(&line); |
| 211 | blob_appendf(&line, "%.10s ", zCiUuid); |
| 212 | blob_appendf(&line, "%.10s ", zDate); |
| 213 | blob_appendf(&line, "%8.8s ", zUser); |
| 214 | blob_appendf(&line, "%8.8s ", zBr); |
| 215 | blob_appendf(&line,"%-39.39s", zCom ); |
| 216 | comment_print(blob_str(&line), 0, iWidth, g.comFmtFlags); |
| 217 | } |
| 218 | } |
| 219 | db_finalize(&q); |
| 220 | blob_reset(&fname); |
| 221 | } |
| 222 |
| --- src/finfo.c | |
| +++ src/finfo.c | |
| @@ -202,20 +202,20 @@ | |
| 202 | if( iBrief ){ |
| 203 | fossil_print("%s ", zDate); |
| 204 | zOut = sqlite3_mprintf( |
| 205 | "[%S] %s (user: %s, artifact: [%S], branch: %s)", |
| 206 | zCiUuid, zCom, zUser, zFileUuid, zBr); |
| 207 | comment_print(zOut, zCom, 11, iWidth, g.comFmtFlags); |
| 208 | sqlite3_free(zOut); |
| 209 | }else{ |
| 210 | blob_reset(&line); |
| 211 | blob_appendf(&line, "%.10s ", zCiUuid); |
| 212 | blob_appendf(&line, "%.10s ", zDate); |
| 213 | blob_appendf(&line, "%8.8s ", zUser); |
| 214 | blob_appendf(&line, "%8.8s ", zBr); |
| 215 | blob_appendf(&line,"%-39.39s", zCom ); |
| 216 | comment_print(blob_str(&line), zCom, 0, iWidth, g.comFmtFlags); |
| 217 | } |
| 218 | } |
| 219 | db_finalize(&q); |
| 220 | blob_reset(&fname); |
| 221 | } |
| 222 |
+1
-1
| --- src/info.c | ||
| +++ src/info.c | ||
| @@ -132,11 +132,11 @@ | ||
| 132 | 132 | fossil_print("tags: %s\n", zTags); |
| 133 | 133 | } |
| 134 | 134 | free(zTags); |
| 135 | 135 | if( zComment ){ |
| 136 | 136 | fossil_print("comment: "); |
| 137 | - comment_print(zComment, 14, -1, g.comFmtFlags); | |
| 137 | + comment_print(zComment, 0, 14, -1, g.comFmtFlags); | |
| 138 | 138 | free(zComment); |
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | /* |
| 143 | 143 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -132,11 +132,11 @@ | |
| 132 | fossil_print("tags: %s\n", zTags); |
| 133 | } |
| 134 | free(zTags); |
| 135 | if( zComment ){ |
| 136 | fossil_print("comment: "); |
| 137 | comment_print(zComment, 14, -1, g.comFmtFlags); |
| 138 | free(zComment); |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | /* |
| 143 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -132,11 +132,11 @@ | |
| 132 | fossil_print("tags: %s\n", zTags); |
| 133 | } |
| 134 | free(zTags); |
| 135 | if( zComment ){ |
| 136 | fossil_print("comment: "); |
| 137 | comment_print(zComment, 0, 14, -1, g.comFmtFlags); |
| 138 | free(zComment); |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | /* |
| 143 |
+2
-2
| --- src/merge.c | ||
| +++ src/merge.c | ||
| @@ -47,11 +47,11 @@ | ||
| 47 | 47 | indent-1, zLabel, |
| 48 | 48 | db_column_text(&q, 3), |
| 49 | 49 | db_column_text(&q, 1), |
| 50 | 50 | db_column_text(&q, 0), |
| 51 | 51 | indent, ""); |
| 52 | - comment_print(zCom, indent, -1, g.comFmtFlags); | |
| 52 | + comment_print(zCom, db_column_text(&q,2), indent, -1, g.comFmtFlags); | |
| 53 | 53 | fossil_free(zCom); |
| 54 | 54 | } |
| 55 | 55 | db_finalize(&q); |
| 56 | 56 | } |
| 57 | 57 | |
| @@ -210,11 +210,11 @@ | ||
| 210 | 210 | ); |
| 211 | 211 | if( db_step(&q)==SQLITE_ROW ){ |
| 212 | 212 | char *zCom = mprintf("Merging fork [%S] at %s by %s: \"%s\"", |
| 213 | 213 | db_column_text(&q, 0), db_column_text(&q, 1), |
| 214 | 214 | db_column_text(&q, 3), db_column_text(&q, 2)); |
| 215 | - comment_print(zCom, 0, -1, g.comFmtFlags); | |
| 215 | + comment_print(zCom, db_column_text(&q,2), 0, -1, g.comFmtFlags); | |
| 216 | 216 | fossil_free(zCom); |
| 217 | 217 | } |
| 218 | 218 | db_finalize(&q); |
| 219 | 219 | }else{ |
| 220 | 220 | usage("?OPTIONS? ?VERSION?"); |
| 221 | 221 |
| --- src/merge.c | |
| +++ src/merge.c | |
| @@ -47,11 +47,11 @@ | |
| 47 | indent-1, zLabel, |
| 48 | db_column_text(&q, 3), |
| 49 | db_column_text(&q, 1), |
| 50 | db_column_text(&q, 0), |
| 51 | indent, ""); |
| 52 | comment_print(zCom, indent, -1, g.comFmtFlags); |
| 53 | fossil_free(zCom); |
| 54 | } |
| 55 | db_finalize(&q); |
| 56 | } |
| 57 | |
| @@ -210,11 +210,11 @@ | |
| 210 | ); |
| 211 | if( db_step(&q)==SQLITE_ROW ){ |
| 212 | char *zCom = mprintf("Merging fork [%S] at %s by %s: \"%s\"", |
| 213 | db_column_text(&q, 0), db_column_text(&q, 1), |
| 214 | db_column_text(&q, 3), db_column_text(&q, 2)); |
| 215 | comment_print(zCom, 0, -1, g.comFmtFlags); |
| 216 | fossil_free(zCom); |
| 217 | } |
| 218 | db_finalize(&q); |
| 219 | }else{ |
| 220 | usage("?OPTIONS? ?VERSION?"); |
| 221 |
| --- src/merge.c | |
| +++ src/merge.c | |
| @@ -47,11 +47,11 @@ | |
| 47 | indent-1, zLabel, |
| 48 | db_column_text(&q, 3), |
| 49 | db_column_text(&q, 1), |
| 50 | db_column_text(&q, 0), |
| 51 | indent, ""); |
| 52 | comment_print(zCom, db_column_text(&q,2), indent, -1, g.comFmtFlags); |
| 53 | fossil_free(zCom); |
| 54 | } |
| 55 | db_finalize(&q); |
| 56 | } |
| 57 | |
| @@ -210,11 +210,11 @@ | |
| 210 | ); |
| 211 | if( db_step(&q)==SQLITE_ROW ){ |
| 212 | char *zCom = mprintf("Merging fork [%S] at %s by %s: \"%s\"", |
| 213 | db_column_text(&q, 0), db_column_text(&q, 1), |
| 214 | db_column_text(&q, 3), db_column_text(&q, 2)); |
| 215 | comment_print(zCom, db_column_text(&q,2), 0, -1, g.comFmtFlags); |
| 216 | fossil_free(zCom); |
| 217 | } |
| 218 | db_finalize(&q); |
| 219 | }else{ |
| 220 | usage("?OPTIONS? ?VERSION?"); |
| 221 |
+3
-3
| --- src/name.c | ||
| +++ src/name.c | ||
| @@ -582,11 +582,11 @@ | ||
| 582 | 582 | default: zType = "Unknown"; break; |
| 583 | 583 | } |
| 584 | 584 | fossil_print("type: %s by %s on %s\n", zType, db_column_text(&q,2), |
| 585 | 585 | db_column_text(&q, 1)); |
| 586 | 586 | fossil_print("comment: "); |
| 587 | - comment_print(db_column_text(&q,3), 12, -1, g.comFmtFlags); | |
| 587 | + comment_print(db_column_text(&q,3), 0, 12, -1, g.comFmtFlags); | |
| 588 | 588 | } |
| 589 | 589 | db_finalize(&q); |
| 590 | 590 | |
| 591 | 591 | /* Check to see if this object is used as a file in a check-in */ |
| 592 | 592 | db_prepare(&q, |
| @@ -604,11 +604,11 @@ | ||
| 604 | 604 | fossil_print(" part of [%S] by %s on %s\n", |
| 605 | 605 | db_column_text(&q, 1), |
| 606 | 606 | db_column_text(&q, 3), |
| 607 | 607 | db_column_text(&q, 2)); |
| 608 | 608 | fossil_print(" "); |
| 609 | - comment_print(db_column_text(&q,4), 12, -1, g.comFmtFlags); | |
| 609 | + comment_print(db_column_text(&q,4), 0, 12, -1, g.comFmtFlags); | |
| 610 | 610 | } |
| 611 | 611 | db_finalize(&q); |
| 612 | 612 | |
| 613 | 613 | /* Check to see if this object is used as an attachment */ |
| 614 | 614 | db_prepare(&q, |
| @@ -639,11 +639,11 @@ | ||
| 639 | 639 | db_column_text(&q,7)); |
| 640 | 640 | } |
| 641 | 641 | fossil_print(" by user %s on %s\n", |
| 642 | 642 | db_column_text(&q,2), db_column_text(&q,3)); |
| 643 | 643 | fossil_print(" "); |
| 644 | - comment_print(db_column_text(&q,1), 12, -1, g.comFmtFlags); | |
| 644 | + comment_print(db_column_text(&q,1), 0, 12, -1, g.comFmtFlags); | |
| 645 | 645 | } |
| 646 | 646 | db_finalize(&q); |
| 647 | 647 | } |
| 648 | 648 | |
| 649 | 649 | /* |
| 650 | 650 |
| --- src/name.c | |
| +++ src/name.c | |
| @@ -582,11 +582,11 @@ | |
| 582 | default: zType = "Unknown"; break; |
| 583 | } |
| 584 | fossil_print("type: %s by %s on %s\n", zType, db_column_text(&q,2), |
| 585 | db_column_text(&q, 1)); |
| 586 | fossil_print("comment: "); |
| 587 | comment_print(db_column_text(&q,3), 12, -1, g.comFmtFlags); |
| 588 | } |
| 589 | db_finalize(&q); |
| 590 | |
| 591 | /* Check to see if this object is used as a file in a check-in */ |
| 592 | db_prepare(&q, |
| @@ -604,11 +604,11 @@ | |
| 604 | fossil_print(" part of [%S] by %s on %s\n", |
| 605 | db_column_text(&q, 1), |
| 606 | db_column_text(&q, 3), |
| 607 | db_column_text(&q, 2)); |
| 608 | fossil_print(" "); |
| 609 | comment_print(db_column_text(&q,4), 12, -1, g.comFmtFlags); |
| 610 | } |
| 611 | db_finalize(&q); |
| 612 | |
| 613 | /* Check to see if this object is used as an attachment */ |
| 614 | db_prepare(&q, |
| @@ -639,11 +639,11 @@ | |
| 639 | db_column_text(&q,7)); |
| 640 | } |
| 641 | fossil_print(" by user %s on %s\n", |
| 642 | db_column_text(&q,2), db_column_text(&q,3)); |
| 643 | fossil_print(" "); |
| 644 | comment_print(db_column_text(&q,1), 12, -1, g.comFmtFlags); |
| 645 | } |
| 646 | db_finalize(&q); |
| 647 | } |
| 648 | |
| 649 | /* |
| 650 |
| --- src/name.c | |
| +++ src/name.c | |
| @@ -582,11 +582,11 @@ | |
| 582 | default: zType = "Unknown"; break; |
| 583 | } |
| 584 | fossil_print("type: %s by %s on %s\n", zType, db_column_text(&q,2), |
| 585 | db_column_text(&q, 1)); |
| 586 | fossil_print("comment: "); |
| 587 | comment_print(db_column_text(&q,3), 0, 12, -1, g.comFmtFlags); |
| 588 | } |
| 589 | db_finalize(&q); |
| 590 | |
| 591 | /* Check to see if this object is used as a file in a check-in */ |
| 592 | db_prepare(&q, |
| @@ -604,11 +604,11 @@ | |
| 604 | fossil_print(" part of [%S] by %s on %s\n", |
| 605 | db_column_text(&q, 1), |
| 606 | db_column_text(&q, 3), |
| 607 | db_column_text(&q, 2)); |
| 608 | fossil_print(" "); |
| 609 | comment_print(db_column_text(&q,4), 0, 12, -1, g.comFmtFlags); |
| 610 | } |
| 611 | db_finalize(&q); |
| 612 | |
| 613 | /* Check to see if this object is used as an attachment */ |
| 614 | db_prepare(&q, |
| @@ -639,11 +639,11 @@ | |
| 639 | db_column_text(&q,7)); |
| 640 | } |
| 641 | fossil_print(" by user %s on %s\n", |
| 642 | db_column_text(&q,2), db_column_text(&q,3)); |
| 643 | fossil_print(" "); |
| 644 | comment_print(db_column_text(&q,1), 0, 12, -1, g.comFmtFlags); |
| 645 | } |
| 646 | db_finalize(&q); |
| 647 | } |
| 648 | |
| 649 | /* |
| 650 |
+1
-1
| --- src/stash.c | ||
| +++ src/stash.c | ||
| @@ -552,11 +552,11 @@ | ||
| 552 | 552 | db_column_text(&q, 3) |
| 553 | 553 | ); |
| 554 | 554 | zCom = db_column_text(&q, 2); |
| 555 | 555 | if( zCom && zCom[0] ){ |
| 556 | 556 | fossil_print(" "); |
| 557 | - comment_print(zCom, 7, width, g.comFmtFlags); | |
| 557 | + comment_print(zCom, 0, 7, width, g.comFmtFlags); | |
| 558 | 558 | } |
| 559 | 559 | if( verboseFlag ){ |
| 560 | 560 | db_bind_int(&q2, "$id", stashid); |
| 561 | 561 | while( db_step(&q2)==SQLITE_ROW ){ |
| 562 | 562 | int isAdded = db_column_int(&q2, 0); |
| 563 | 563 |
| --- src/stash.c | |
| +++ src/stash.c | |
| @@ -552,11 +552,11 @@ | |
| 552 | db_column_text(&q, 3) |
| 553 | ); |
| 554 | zCom = db_column_text(&q, 2); |
| 555 | if( zCom && zCom[0] ){ |
| 556 | fossil_print(" "); |
| 557 | comment_print(zCom, 7, width, g.comFmtFlags); |
| 558 | } |
| 559 | if( verboseFlag ){ |
| 560 | db_bind_int(&q2, "$id", stashid); |
| 561 | while( db_step(&q2)==SQLITE_ROW ){ |
| 562 | int isAdded = db_column_int(&q2, 0); |
| 563 |
| --- src/stash.c | |
| +++ src/stash.c | |
| @@ -552,11 +552,11 @@ | |
| 552 | db_column_text(&q, 3) |
| 553 | ); |
| 554 | zCom = db_column_text(&q, 2); |
| 555 | if( zCom && zCom[0] ){ |
| 556 | fossil_print(" "); |
| 557 | comment_print(zCom, 0, 7, width, g.comFmtFlags); |
| 558 | } |
| 559 | if( verboseFlag ){ |
| 560 | db_bind_int(&q2, "$id", stashid); |
| 561 | while( db_step(&q2)==SQLITE_ROW ){ |
| 562 | int isAdded = db_column_int(&q2, 0); |
| 563 |
+1
-1
| --- src/timeline.c | ||
| +++ src/timeline.c | ||
| @@ -1603,11 +1603,11 @@ | ||
| 1603 | 1603 | sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*CURRENT* "); |
| 1604 | 1604 | n += strlen(zPrefix); |
| 1605 | 1605 | } |
| 1606 | 1606 | zFree = mprintf("[%S] %s%s", zId, zPrefix, zCom); |
| 1607 | 1607 | /* record another X lines */ |
| 1608 | - nLine += comment_print(zFree, 9, width, g.comFmtFlags); | |
| 1608 | + nLine += comment_print(zFree, zCom, 9, width, g.comFmtFlags); | |
| 1609 | 1609 | fossil_free(zFree); |
| 1610 | 1610 | |
| 1611 | 1611 | if(verboseFlag){ |
| 1612 | 1612 | if( !fchngQueryInit ){ |
| 1613 | 1613 | db_prepare(&fchngQuery, |
| 1614 | 1614 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -1603,11 +1603,11 @@ | |
| 1603 | sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*CURRENT* "); |
| 1604 | n += strlen(zPrefix); |
| 1605 | } |
| 1606 | zFree = mprintf("[%S] %s%s", zId, zPrefix, zCom); |
| 1607 | /* record another X lines */ |
| 1608 | nLine += comment_print(zFree, 9, width, g.comFmtFlags); |
| 1609 | fossil_free(zFree); |
| 1610 | |
| 1611 | if(verboseFlag){ |
| 1612 | if( !fchngQueryInit ){ |
| 1613 | db_prepare(&fchngQuery, |
| 1614 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -1603,11 +1603,11 @@ | |
| 1603 | sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*CURRENT* "); |
| 1604 | n += strlen(zPrefix); |
| 1605 | } |
| 1606 | zFree = mprintf("[%S] %s%s", zId, zPrefix, zCom); |
| 1607 | /* record another X lines */ |
| 1608 | nLine += comment_print(zFree, zCom, 9, width, g.comFmtFlags); |
| 1609 | fossil_free(zFree); |
| 1610 | |
| 1611 | if(verboseFlag){ |
| 1612 | if( !fchngQueryInit ){ |
| 1613 | db_prepare(&fchngQuery, |
| 1614 |
+1
-1
| --- src/tkt.c | ||
| +++ src/tkt.c | ||
| @@ -1264,11 +1264,11 @@ | ||
| 1264 | 1264 | fossil_print(" Change "); |
| 1265 | 1265 | } |
| 1266 | 1266 | fossil_print("%h: ",z); |
| 1267 | 1267 | if( blob_size(&val)>50 || contains_newline(&val)) { |
| 1268 | 1268 | fossil_print("\n ",blob_str(&val)); |
| 1269 | - comment_print(blob_str(&val),4,-1,g.comFmtFlags); | |
| 1269 | + comment_print(blob_str(&val),0,4,-1,g.comFmtFlags); | |
| 1270 | 1270 | }else{ |
| 1271 | 1271 | fossil_print("%s\n",blob_str(&val)); |
| 1272 | 1272 | } |
| 1273 | 1273 | blob_reset(&val); |
| 1274 | 1274 | } |
| 1275 | 1275 |
| --- src/tkt.c | |
| +++ src/tkt.c | |
| @@ -1264,11 +1264,11 @@ | |
| 1264 | fossil_print(" Change "); |
| 1265 | } |
| 1266 | fossil_print("%h: ",z); |
| 1267 | if( blob_size(&val)>50 || contains_newline(&val)) { |
| 1268 | fossil_print("\n ",blob_str(&val)); |
| 1269 | comment_print(blob_str(&val),4,-1,g.comFmtFlags); |
| 1270 | }else{ |
| 1271 | fossil_print("%s\n",blob_str(&val)); |
| 1272 | } |
| 1273 | blob_reset(&val); |
| 1274 | } |
| 1275 |
| --- src/tkt.c | |
| +++ src/tkt.c | |
| @@ -1264,11 +1264,11 @@ | |
| 1264 | fossil_print(" Change "); |
| 1265 | } |
| 1266 | fossil_print("%h: ",z); |
| 1267 | if( blob_size(&val)>50 || contains_newline(&val)) { |
| 1268 | fossil_print("\n ",blob_str(&val)); |
| 1269 | comment_print(blob_str(&val),0,4,-1,g.comFmtFlags); |
| 1270 | }else{ |
| 1271 | fossil_print("%s\n",blob_str(&val)); |
| 1272 | } |
| 1273 | blob_reset(&val); |
| 1274 | } |
| 1275 |
+49
-38
| --- test/comment.test | ||
| +++ test/comment.test | ||
| @@ -26,101 +26,101 @@ | ||
| 26 | 26 | fossil test-comment-format --decode "" "" |
| 27 | 27 | test comment-2 {$RESULT eq "\n(1 lines output)"} |
| 28 | 28 | |
| 29 | 29 | ############################################################################### |
| 30 | 30 | |
| 31 | -fossil test-comment-format " " "this is a short comment." 26 | |
| 31 | +fossil test-comment-format --width 26 " " "this is a short comment." | |
| 32 | 32 | test comment-3 {$RESULT eq " this is a short comment.\n(1 lines output)"} |
| 33 | 33 | |
| 34 | 34 | ############################################################################### |
| 35 | 35 | |
| 36 | -fossil test-comment-format --decode " " "this is a short comment." 26 | |
| 36 | +fossil test-comment-format --width 26 --decode " " "this is a short comment." | |
| 37 | 37 | test comment-4 {$RESULT eq " this is a short comment.\n(1 lines output)"} |
| 38 | 38 | |
| 39 | 39 | ############################################################################### |
| 40 | 40 | |
| 41 | -fossil test-comment-format "*PREFIX* " "this is a short comment." 26 | |
| 41 | +fossil test-comment-format --width 26 "*PREFIX* " "this is a short comment." | |
| 42 | 42 | test comment-5 {$RESULT eq "*PREFIX* this is a short c\n omment.\n(2 lines output)"} |
| 43 | 43 | |
| 44 | 44 | ############################################################################### |
| 45 | 45 | |
| 46 | -fossil test-comment-format --decode "*PREFIX* " "this is a short comment." 26 | |
| 46 | +fossil test-comment-format --width 26 --decode "*PREFIX* " "this is a short comment." | |
| 47 | 47 | test comment-6 {$RESULT eq "*PREFIX* this is a short c\n omment.\n(2 lines output)"} |
| 48 | 48 | |
| 49 | 49 | ############################################################################### |
| 50 | 50 | |
| 51 | -fossil test-comment-format "" "this\\sis\\sa\\sshort\\scomment." 26 | |
| 51 | +fossil test-comment-format --width 26 "" "this\\sis\\sa\\sshort\\scomment." | |
| 52 | 52 | test comment-7 {$RESULT eq "this\\sis\\sa\\sshort\\scommen\nt.\n(2 lines output)"} |
| 53 | 53 | |
| 54 | 54 | ############################################################################### |
| 55 | 55 | |
| 56 | -fossil test-comment-format --decode "" "this\\sis\\sa\\sshort\\scomment." 26 | |
| 56 | +fossil test-comment-format --width 26 --decode "" "this\\sis\\sa\\sshort\\scomment." | |
| 57 | 57 | test comment-8 {$RESULT eq "this is a short comment.\n(1 lines output)"} |
| 58 | 58 | |
| 59 | 59 | ############################################################################### |
| 60 | 60 | |
| 61 | -fossil test-comment-format --decode --trimspace "HH:MM:SS " "this is a long comment that should span multiple lines if the test is working correctly." 78 | |
| 61 | +fossil test-comment-format --width 78 --decode --trimspace "HH:MM:SS " "this is a long comment that should span multiple lines if the test is working correctly." | |
| 62 | 62 | test comment-9 {$RESULT eq "HH:MM:SS this is a long comment that should span multiple lines if the test is\n working correctly.\n(2 lines output)"} |
| 63 | 63 | |
| 64 | 64 | ############################################################################### |
| 65 | 65 | |
| 66 | -fossil test-comment-format --decode --trimspace "HH:MM:SS " "this is a long comment that should span multiple lines if the test is working correctly. more text here describing the issue.\\nanother line here..................................................................................*" 78 | |
| 66 | +fossil test-comment-format --width 78 --decode --trimspace "HH:MM:SS " "this is a long comment that should span multiple lines if the test is working correctly. more text here describing the issue.\\nanother line here..................................................................................*" | |
| 67 | 67 | test comment-10 {$RESULT eq "HH:MM:SS this is a long comment that should span multiple lines if the test is\n working correctly. more text here describing the issue.\n another line here....................................................\n ..............................*\n(4 lines output)"} |
| 68 | 68 | |
| 69 | 69 | ############################################################################### |
| 70 | 70 | |
| 71 | -fossil test-comment-format "HH:MM:SS " "....................................................................................*" 78 | |
| 71 | +fossil test-comment-format --width 78 "HH:MM:SS " "....................................................................................*" | |
| 72 | 72 | test comment-11 {$RESULT eq "HH:MM:SS .....................................................................\n ...............*\n(2 lines output)"} |
| 73 | 73 | |
| 74 | 74 | ############################################################################### |
| 75 | 75 | |
| 76 | -fossil test-comment-format "HH:MM:SS " ".....................................................................*" 78 | |
| 76 | +fossil test-comment-format --width 78 "HH:MM:SS " ".....................................................................*" 78 | |
| 77 | 77 | test comment-12 {$RESULT eq "HH:MM:SS .....................................................................\n *\n(2 lines output)"} |
| 78 | 78 | |
| 79 | 79 | ############################################################################### |
| 80 | 80 | |
| 81 | -fossil test-comment-format "*TEST* " "this\tis a test." 26 | |
| 81 | +fossil test-comment-format --width 26 "*TEST* " "this\tis a test." | |
| 82 | 82 | test comment-13 {$RESULT eq "*TEST* this\tis a te\n st.\n(2 lines output)"} |
| 83 | 83 | |
| 84 | 84 | ############################################################################### |
| 85 | 85 | |
| 86 | -fossil test-comment-format "*TEST* " "this is a test......................................................................................................................." 60 | |
| 86 | +fossil test-comment-format --width 60 "*TEST* " "this is a test......................................................................................................................." | |
| 87 | 87 | test comment-14 {$RESULT eq "*TEST* this is a test.......................................\n .....................................................\n ...........................\n(3 lines output)"} |
| 88 | 88 | |
| 89 | 89 | ############################################################################### |
| 90 | 90 | |
| 91 | -fossil test-comment-format --wordbreak "*TEST* " "this is a test......................................................................................................................." 60 | |
| 91 | +fossil test-comment-format --width 60 --wordbreak "*TEST* " "this is a test......................................................................................................................." | |
| 92 | 92 | test comment-15 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"} |
| 93 | 93 | |
| 94 | 94 | ############################################################################### |
| 95 | 95 | |
| 96 | -fossil test-comment-format "*TEST* " "this is a test......................................................................................................................." 60 | |
| 96 | +fossil test-comment-format --width 60 "*TEST* " "this is a test......................................................................................................................." | |
| 97 | 97 | test comment-16 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"} |
| 98 | 98 | |
| 99 | 99 | ############################################################################### |
| 100 | 100 | |
| 101 | -fossil test-comment-format --wordbreak "*TEST* " "this is a test......................................................................................................................." 60 | |
| 101 | +fossil test-comment-format --width 60 --wordbreak "*TEST* " "this is a test......................................................................................................................." | |
| 102 | 102 | test comment-17 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"} |
| 103 | 103 | |
| 104 | 104 | ############################################################################### |
| 105 | 105 | |
| 106 | -fossil test-comment-format "*TEST* " "one two three four five six seven eight nine ten eleven twelve" 60 | |
| 106 | +fossil test-comment-format --width 60 "*TEST* " "one two three four five six seven eight nine ten eleven twelve" | |
| 107 | 107 | test comment-18 {$RESULT eq "*TEST* one two three four five six seven eight nine ten elev\n en twelve\n(2 lines output)"} |
| 108 | 108 | |
| 109 | 109 | ############################################################################### |
| 110 | 110 | |
| 111 | -fossil test-comment-format --wordbreak "*TEST* " "one two three four five six seven eight nine ten eleven twelve" 60 | |
| 111 | +fossil test-comment-format --width 60 --wordbreak "*TEST* " "one two three four five six seven eight nine ten eleven twelve" | |
| 112 | 112 | test comment-19 {$RESULT eq "*TEST* one two three four five six seven eight nine ten\n eleven twelve\n(2 lines output)"} |
| 113 | 113 | |
| 114 | 114 | ############################################################################### |
| 115 | 115 | |
| 116 | -fossil test-comment-format "*TEST* " "one two three four five six seven eight nine ten eleven twelve" 60 | |
| 116 | +fossil test-comment-format --width 60 "*TEST* " "one two three four five six seven eight nine ten eleven twelve" | |
| 117 | 117 | test comment-20 {$RESULT eq "*TEST* one two three four five\n six seven eight nine ten\n eleven twelve\n(3 lines output)"} |
| 118 | 118 | |
| 119 | 119 | ############################################################################### |
| 120 | 120 | |
| 121 | -fossil test-comment-format --wordbreak "*TEST* " "one two three four five six seven eight nine ten eleven twelve" 60 | |
| 121 | +fossil test-comment-format --width 60 --wordbreak "*TEST* " "one two three four five six seven eight nine ten eleven twelve" | |
| 122 | 122 | test comment-21 {$RESULT eq "*TEST* one two three four five\n six seven eight nine ten\n eleven twelve\n(3 lines output)"} |
| 123 | 123 | |
| 124 | 124 | ############################################################################### |
| 125 | 125 | |
| 126 | 126 | fossil test-comment-format --legacy "" "" |
| @@ -131,97 +131,108 @@ | ||
| 131 | 131 | fossil test-comment-format --legacy --decode "" "" |
| 132 | 132 | test comment-23 {$RESULT eq "\n(1 lines output)"} |
| 133 | 133 | |
| 134 | 134 | ############################################################################### |
| 135 | 135 | |
| 136 | -fossil test-comment-format --legacy " " "this is a short comment." 26 | |
| 136 | +fossil test-comment-format --width 26 --legacy " " "this is a short comment." | |
| 137 | 137 | test comment-24 {$RESULT eq " this is a short comment.\n(1 lines output)"} |
| 138 | 138 | |
| 139 | 139 | ############################################################################### |
| 140 | 140 | |
| 141 | -fossil test-comment-format --legacy --decode " " "this is a short comment." 26 | |
| 141 | +fossil test-comment-format --width 26 --legacy --decode " " "this is a short comment." | |
| 142 | 142 | test comment-25 {$RESULT eq " this is a short comment.\n(1 lines output)"} |
| 143 | 143 | |
| 144 | 144 | ############################################################################### |
| 145 | 145 | |
| 146 | -fossil test-comment-format --legacy "*PREFIX* " "this is a short comment." 25 | |
| 146 | +fossil test-comment-format --width 25 --legacy "*PREFIX* " "this is a short comment." | |
| 147 | 147 | test comment-26 {$RESULT eq "*PREFIX* this is a short\n comment.\n(2 lines output)"} |
| 148 | 148 | |
| 149 | 149 | ############################################################################### |
| 150 | 150 | |
| 151 | -fossil test-comment-format --legacy --decode "*PREFIX* " "this is a short comment." 25 | |
| 151 | +fossil test-comment-format --width 25 --legacy --decode "*PREFIX* " "this is a short comment." | |
| 152 | 152 | test comment-27 {$RESULT eq "*PREFIX* this is a short\n comment.\n(2 lines output)"} |
| 153 | 153 | |
| 154 | 154 | ############################################################################### |
| 155 | 155 | |
| 156 | -fossil test-comment-format --legacy "" "this\\sis\\sa\\sshort\\scomment." 26 | |
| 156 | +fossil test-comment-format --width 26 --legacy "" "this\\sis\\sa\\sshort\\scomment." | |
| 157 | 157 | test comment-28 {$RESULT eq "this\\sis\\sa\\sshort\\scommen\nt.\n(2 lines output)"} |
| 158 | 158 | |
| 159 | 159 | ############################################################################### |
| 160 | 160 | |
| 161 | -fossil test-comment-format --legacy --decode "" "this\\sis\\sa\\sshort\\scomment." 26 | |
| 161 | +fossil test-comment-format --width 26 --legacy --decode "" "this\\sis\\sa\\sshort\\scomment." | |
| 162 | 162 | test comment-29 {$RESULT eq "this is a short comment.\n(1 lines output)"} |
| 163 | 163 | |
| 164 | 164 | ############################################################################### |
| 165 | 165 | |
| 166 | -fossil test-comment-format --legacy --decode "HH:MM:SS " "this is a long comment that should span multiple lines if the test is working correctly." 78 | |
| 166 | +fossil test-comment-format --width 78 --legacy --decode "HH:MM:SS " "this is a long comment that should span multiple lines if the test is working correctly." | |
| 167 | 167 | test comment-30 {$RESULT eq "HH:MM:SS this is a long comment that should span multiple lines if the test\n is working correctly.\n(2 lines output)"} |
| 168 | 168 | |
| 169 | 169 | ############################################################################### |
| 170 | 170 | |
| 171 | -fossil test-comment-format --legacy --decode "HH:MM:SS " "this is a long comment that should span multiple lines if the test is working correctly. more text here describing the issue.\\nanother line here..................................................................................*" 78 | |
| 171 | +fossil test-comment-format --width 78 --legacy --decode "HH:MM:SS " "this is a long comment that should span multiple lines if the test is working correctly. more text here describing the issue.\\nanother line here..................................................................................*" | |
| 172 | 172 | test comment-31 {$RESULT eq "HH:MM:SS this is a long comment that should span multiple lines if the test\n is working correctly. more text here describing the issue. another\n line\n here.................................................................\n .................*\n(5 lines output)"} |
| 173 | 173 | |
| 174 | 174 | ############################################################################### |
| 175 | 175 | |
| 176 | -fossil test-comment-format --legacy "HH:MM:SS " "....................................................................................*" 78 | |
| 176 | +fossil test-comment-format --width 78 --legacy "HH:MM:SS " "....................................................................................*" | |
| 177 | 177 | test comment-32 {$RESULT eq "HH:MM:SS .....................................................................\n ...............*\n(2 lines output)"} |
| 178 | 178 | |
| 179 | 179 | ############################################################################### |
| 180 | 180 | |
| 181 | -fossil test-comment-format --legacy "HH:MM:SS " ".....................................................................*" 78 | |
| 181 | +fossil test-comment-format --width 78 --legacy "HH:MM:SS " ".....................................................................*" | |
| 182 | 182 | test comment-33 {$RESULT eq "HH:MM:SS .....................................................................\n *\n(2 lines output)"} |
| 183 | 183 | |
| 184 | 184 | ############################################################################### |
| 185 | 185 | |
| 186 | -fossil test-comment-format --legacy "*TEST* " "this\tis a test." 26 | |
| 186 | +fossil test-comment-format --width 26 --legacy "*TEST* " "this\tis a test." | |
| 187 | 187 | test comment-34 {$RESULT eq "*TEST* this is a test.\n(1 lines output)"} |
| 188 | 188 | |
| 189 | 189 | ############################################################################### |
| 190 | 190 | |
| 191 | -fossil test-comment-format --legacy "*TEST* " "this is a test......................................................................................................................." 60 | |
| 191 | +fossil test-comment-format --width 60 --legacy "*TEST* " "this is a test......................................................................................................................." | |
| 192 | 192 | test comment-35 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"} |
| 193 | 193 | |
| 194 | 194 | ############################################################################### |
| 195 | 195 | |
| 196 | -fossil test-comment-format --legacy --wordbreak "*TEST* " "this is a test......................................................................................................................." 60 | |
| 196 | +fossil test-comment-format --width 60 --legacy --wordbreak "*TEST* " "this is a test......................................................................................................................." | |
| 197 | 197 | test comment-36 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"} |
| 198 | 198 | |
| 199 | 199 | ############################################################################### |
| 200 | 200 | |
| 201 | -fossil test-comment-format --legacy "*TEST* " "this is a test......................................................................................................................." 60 | |
| 201 | +fossil test-comment-format --width 60 --legacy "*TEST* " "this is a test......................................................................................................................." | |
| 202 | 202 | test comment-37 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"} |
| 203 | 203 | |
| 204 | 204 | ############################################################################### |
| 205 | 205 | |
| 206 | -fossil test-comment-format --legacy --wordbreak "*TEST* " "this is a test......................................................................................................................." 60 | |
| 206 | +fossil test-comment-format --width 60 --legacy --wordbreak "*TEST* " "this is a test......................................................................................................................." | |
| 207 | 207 | test comment-38 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"} |
| 208 | 208 | |
| 209 | 209 | ############################################################################### |
| 210 | 210 | |
| 211 | -fossil test-comment-format --legacy "*TEST* " "one two three four five six seven eight nine ten eleven twelve" 60 | |
| 211 | +fossil test-comment-format --width 60 --legacy "*TEST* " "one two three four five six seven eight nine ten eleven twelve" | |
| 212 | 212 | test comment-39 {$RESULT eq "*TEST* one two three four five six seven eight nine ten\n eleven twelve\n(2 lines output)"} |
| 213 | 213 | |
| 214 | 214 | ############################################################################### |
| 215 | 215 | |
| 216 | -fossil test-comment-format --legacy --wordbreak "*TEST* " "one two three four five six seven eight nine ten eleven twelve" 60 | |
| 216 | +fossil test-comment-format --width 60 --legacy --wordbreak "*TEST* " "one two three four five six seven eight nine ten eleven twelve" | |
| 217 | 217 | test comment-40 {$RESULT eq "*TEST* one two three four five six seven eight nine ten\n eleven twelve\n(2 lines output)"} |
| 218 | 218 | |
| 219 | 219 | ############################################################################### |
| 220 | 220 | |
| 221 | -fossil test-comment-format --legacy "*TEST* " "one two three four five six seven eight nine ten eleven twelve" 60 | |
| 221 | +fossil test-comment-format --width 60 --legacy "*TEST* " "one two three four five six seven eight nine ten eleven twelve" | |
| 222 | 222 | test comment-41 {$RESULT eq "*TEST* one two three four five six seven eight nine ten\n eleven twelve\n(2 lines output)"} |
| 223 | 223 | |
| 224 | 224 | ############################################################################### |
| 225 | 225 | |
| 226 | -fossil test-comment-format --legacy --wordbreak "*TEST* " "one two three four five six seven eight nine ten eleven twelve" 60 | |
| 226 | +fossil test-comment-format --width 60 --legacy --wordbreak "*TEST* " "one two three four five six seven eight nine ten eleven twelve" | |
| 227 | 227 | test comment-42 {$RESULT eq "*TEST* one two three four five six seven eight nine ten\n eleven twelve\n(2 lines output)"} |
| 228 | + | |
| 229 | +############################################################################### | |
| 230 | + | |
| 231 | +set orig "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." | |
| 232 | +fossil test-comment-format --width 73 --decode --origbreak "" $orig $orig | |
| 233 | +test comment-43 {$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)"} | |
| 234 | + | |
| 235 | +############################################################################### | |
| 236 | + | |
| 237 | +fossil test-comment-format --width 73 --decode --origbreak "" "00:00:00 \[0000000000\] *CURRENT* $orig" $orig | |
| 238 | +test comment-44 {$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)"} | |
| 228 | 239 |
| --- test/comment.test | |
| +++ test/comment.test | |
| @@ -26,101 +26,101 @@ | |
| 26 | fossil test-comment-format --decode "" "" |
| 27 | test comment-2 {$RESULT eq "\n(1 lines output)"} |
| 28 | |
| 29 | ############################################################################### |
| 30 | |
| 31 | fossil test-comment-format " " "this is a short comment." 26 |
| 32 | test comment-3 {$RESULT eq " this is a short comment.\n(1 lines output)"} |
| 33 | |
| 34 | ############################################################################### |
| 35 | |
| 36 | fossil test-comment-format --decode " " "this is a short comment." 26 |
| 37 | test comment-4 {$RESULT eq " this is a short comment.\n(1 lines output)"} |
| 38 | |
| 39 | ############################################################################### |
| 40 | |
| 41 | fossil test-comment-format "*PREFIX* " "this is a short comment." 26 |
| 42 | test comment-5 {$RESULT eq "*PREFIX* this is a short c\n omment.\n(2 lines output)"} |
| 43 | |
| 44 | ############################################################################### |
| 45 | |
| 46 | fossil test-comment-format --decode "*PREFIX* " "this is a short comment." 26 |
| 47 | test comment-6 {$RESULT eq "*PREFIX* this is a short c\n omment.\n(2 lines output)"} |
| 48 | |
| 49 | ############################################################################### |
| 50 | |
| 51 | fossil test-comment-format "" "this\\sis\\sa\\sshort\\scomment." 26 |
| 52 | test comment-7 {$RESULT eq "this\\sis\\sa\\sshort\\scommen\nt.\n(2 lines output)"} |
| 53 | |
| 54 | ############################################################################### |
| 55 | |
| 56 | fossil test-comment-format --decode "" "this\\sis\\sa\\sshort\\scomment." 26 |
| 57 | test comment-8 {$RESULT eq "this is a short comment.\n(1 lines output)"} |
| 58 | |
| 59 | ############################################################################### |
| 60 | |
| 61 | fossil test-comment-format --decode --trimspace "HH:MM:SS " "this is a long comment that should span multiple lines if the test is working correctly." 78 |
| 62 | test comment-9 {$RESULT eq "HH:MM:SS this is a long comment that should span multiple lines if the test is\n working correctly.\n(2 lines output)"} |
| 63 | |
| 64 | ############################################################################### |
| 65 | |
| 66 | fossil test-comment-format --decode --trimspace "HH:MM:SS " "this is a long comment that should span multiple lines if the test is working correctly. more text here describing the issue.\\nanother line here..................................................................................*" 78 |
| 67 | test comment-10 {$RESULT eq "HH:MM:SS this is a long comment that should span multiple lines if the test is\n working correctly. more text here describing the issue.\n another line here....................................................\n ..............................*\n(4 lines output)"} |
| 68 | |
| 69 | ############################################################################### |
| 70 | |
| 71 | fossil test-comment-format "HH:MM:SS " "....................................................................................*" 78 |
| 72 | test comment-11 {$RESULT eq "HH:MM:SS .....................................................................\n ...............*\n(2 lines output)"} |
| 73 | |
| 74 | ############################################################################### |
| 75 | |
| 76 | fossil test-comment-format "HH:MM:SS " ".....................................................................*" 78 |
| 77 | test comment-12 {$RESULT eq "HH:MM:SS .....................................................................\n *\n(2 lines output)"} |
| 78 | |
| 79 | ############################################################################### |
| 80 | |
| 81 | fossil test-comment-format "*TEST* " "this\tis a test." 26 |
| 82 | test comment-13 {$RESULT eq "*TEST* this\tis a te\n st.\n(2 lines output)"} |
| 83 | |
| 84 | ############################################################################### |
| 85 | |
| 86 | fossil test-comment-format "*TEST* " "this is a test......................................................................................................................." 60 |
| 87 | test comment-14 {$RESULT eq "*TEST* this is a test.......................................\n .....................................................\n ...........................\n(3 lines output)"} |
| 88 | |
| 89 | ############################################################################### |
| 90 | |
| 91 | fossil test-comment-format --wordbreak "*TEST* " "this is a test......................................................................................................................." 60 |
| 92 | test comment-15 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"} |
| 93 | |
| 94 | ############################################################################### |
| 95 | |
| 96 | fossil test-comment-format "*TEST* " "this is a test......................................................................................................................." 60 |
| 97 | test comment-16 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"} |
| 98 | |
| 99 | ############################################################################### |
| 100 | |
| 101 | fossil test-comment-format --wordbreak "*TEST* " "this is a test......................................................................................................................." 60 |
| 102 | test comment-17 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"} |
| 103 | |
| 104 | ############################################################################### |
| 105 | |
| 106 | fossil test-comment-format "*TEST* " "one two three four five six seven eight nine ten eleven twelve" 60 |
| 107 | test comment-18 {$RESULT eq "*TEST* one two three four five six seven eight nine ten elev\n en twelve\n(2 lines output)"} |
| 108 | |
| 109 | ############################################################################### |
| 110 | |
| 111 | fossil test-comment-format --wordbreak "*TEST* " "one two three four five six seven eight nine ten eleven twelve" 60 |
| 112 | test comment-19 {$RESULT eq "*TEST* one two three four five six seven eight nine ten\n eleven twelve\n(2 lines output)"} |
| 113 | |
| 114 | ############################################################################### |
| 115 | |
| 116 | fossil test-comment-format "*TEST* " "one two three four five six seven eight nine ten eleven twelve" 60 |
| 117 | test comment-20 {$RESULT eq "*TEST* one two three four five\n six seven eight nine ten\n eleven twelve\n(3 lines output)"} |
| 118 | |
| 119 | ############################################################################### |
| 120 | |
| 121 | fossil test-comment-format --wordbreak "*TEST* " "one two three four five six seven eight nine ten eleven twelve" 60 |
| 122 | test comment-21 {$RESULT eq "*TEST* one two three four five\n six seven eight nine ten\n eleven twelve\n(3 lines output)"} |
| 123 | |
| 124 | ############################################################################### |
| 125 | |
| 126 | fossil test-comment-format --legacy "" "" |
| @@ -131,97 +131,108 @@ | |
| 131 | fossil test-comment-format --legacy --decode "" "" |
| 132 | test comment-23 {$RESULT eq "\n(1 lines output)"} |
| 133 | |
| 134 | ############################################################################### |
| 135 | |
| 136 | fossil test-comment-format --legacy " " "this is a short comment." 26 |
| 137 | test comment-24 {$RESULT eq " this is a short comment.\n(1 lines output)"} |
| 138 | |
| 139 | ############################################################################### |
| 140 | |
| 141 | fossil test-comment-format --legacy --decode " " "this is a short comment." 26 |
| 142 | test comment-25 {$RESULT eq " this is a short comment.\n(1 lines output)"} |
| 143 | |
| 144 | ############################################################################### |
| 145 | |
| 146 | fossil test-comment-format --legacy "*PREFIX* " "this is a short comment." 25 |
| 147 | test comment-26 {$RESULT eq "*PREFIX* this is a short\n comment.\n(2 lines output)"} |
| 148 | |
| 149 | ############################################################################### |
| 150 | |
| 151 | fossil test-comment-format --legacy --decode "*PREFIX* " "this is a short comment." 25 |
| 152 | test comment-27 {$RESULT eq "*PREFIX* this is a short\n comment.\n(2 lines output)"} |
| 153 | |
| 154 | ############################################################################### |
| 155 | |
| 156 | fossil test-comment-format --legacy "" "this\\sis\\sa\\sshort\\scomment." 26 |
| 157 | test comment-28 {$RESULT eq "this\\sis\\sa\\sshort\\scommen\nt.\n(2 lines output)"} |
| 158 | |
| 159 | ############################################################################### |
| 160 | |
| 161 | fossil test-comment-format --legacy --decode "" "this\\sis\\sa\\sshort\\scomment." 26 |
| 162 | test comment-29 {$RESULT eq "this is a short comment.\n(1 lines output)"} |
| 163 | |
| 164 | ############################################################################### |
| 165 | |
| 166 | fossil test-comment-format --legacy --decode "HH:MM:SS " "this is a long comment that should span multiple lines if the test is working correctly." 78 |
| 167 | test comment-30 {$RESULT eq "HH:MM:SS this is a long comment that should span multiple lines if the test\n is working correctly.\n(2 lines output)"} |
| 168 | |
| 169 | ############################################################################### |
| 170 | |
| 171 | fossil test-comment-format --legacy --decode "HH:MM:SS " "this is a long comment that should span multiple lines if the test is working correctly. more text here describing the issue.\\nanother line here..................................................................................*" 78 |
| 172 | test comment-31 {$RESULT eq "HH:MM:SS this is a long comment that should span multiple lines if the test\n is working correctly. more text here describing the issue. another\n line\n here.................................................................\n .................*\n(5 lines output)"} |
| 173 | |
| 174 | ############################################################################### |
| 175 | |
| 176 | fossil test-comment-format --legacy "HH:MM:SS " "....................................................................................*" 78 |
| 177 | test comment-32 {$RESULT eq "HH:MM:SS .....................................................................\n ...............*\n(2 lines output)"} |
| 178 | |
| 179 | ############################################################################### |
| 180 | |
| 181 | fossil test-comment-format --legacy "HH:MM:SS " ".....................................................................*" 78 |
| 182 | test comment-33 {$RESULT eq "HH:MM:SS .....................................................................\n *\n(2 lines output)"} |
| 183 | |
| 184 | ############################################################################### |
| 185 | |
| 186 | fossil test-comment-format --legacy "*TEST* " "this\tis a test." 26 |
| 187 | test comment-34 {$RESULT eq "*TEST* this is a test.\n(1 lines output)"} |
| 188 | |
| 189 | ############################################################################### |
| 190 | |
| 191 | fossil test-comment-format --legacy "*TEST* " "this is a test......................................................................................................................." 60 |
| 192 | test comment-35 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"} |
| 193 | |
| 194 | ############################################################################### |
| 195 | |
| 196 | fossil test-comment-format --legacy --wordbreak "*TEST* " "this is a test......................................................................................................................." 60 |
| 197 | test comment-36 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"} |
| 198 | |
| 199 | ############################################################################### |
| 200 | |
| 201 | fossil test-comment-format --legacy "*TEST* " "this is a test......................................................................................................................." 60 |
| 202 | test comment-37 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"} |
| 203 | |
| 204 | ############################################################################### |
| 205 | |
| 206 | fossil test-comment-format --legacy --wordbreak "*TEST* " "this is a test......................................................................................................................." 60 |
| 207 | test comment-38 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"} |
| 208 | |
| 209 | ############################################################################### |
| 210 | |
| 211 | fossil test-comment-format --legacy "*TEST* " "one two three four five six seven eight nine ten eleven twelve" 60 |
| 212 | test comment-39 {$RESULT eq "*TEST* one two three four five six seven eight nine ten\n eleven twelve\n(2 lines output)"} |
| 213 | |
| 214 | ############################################################################### |
| 215 | |
| 216 | fossil test-comment-format --legacy --wordbreak "*TEST* " "one two three four five six seven eight nine ten eleven twelve" 60 |
| 217 | test comment-40 {$RESULT eq "*TEST* one two three four five six seven eight nine ten\n eleven twelve\n(2 lines output)"} |
| 218 | |
| 219 | ############################################################################### |
| 220 | |
| 221 | fossil test-comment-format --legacy "*TEST* " "one two three four five six seven eight nine ten eleven twelve" 60 |
| 222 | test comment-41 {$RESULT eq "*TEST* one two three four five six seven eight nine ten\n eleven twelve\n(2 lines output)"} |
| 223 | |
| 224 | ############################################################################### |
| 225 | |
| 226 | fossil test-comment-format --legacy --wordbreak "*TEST* " "one two three four five six seven eight nine ten eleven twelve" 60 |
| 227 | test comment-42 {$RESULT eq "*TEST* one two three four five six seven eight nine ten\n eleven twelve\n(2 lines output)"} |
| 228 |
| --- test/comment.test | |
| +++ test/comment.test | |
| @@ -26,101 +26,101 @@ | |
| 26 | fossil test-comment-format --decode "" "" |
| 27 | test comment-2 {$RESULT eq "\n(1 lines output)"} |
| 28 | |
| 29 | ############################################################################### |
| 30 | |
| 31 | fossil test-comment-format --width 26 " " "this is a short comment." |
| 32 | test comment-3 {$RESULT eq " this is a short comment.\n(1 lines output)"} |
| 33 | |
| 34 | ############################################################################### |
| 35 | |
| 36 | fossil test-comment-format --width 26 --decode " " "this is a short comment." |
| 37 | test comment-4 {$RESULT eq " this is a short comment.\n(1 lines output)"} |
| 38 | |
| 39 | ############################################################################### |
| 40 | |
| 41 | fossil test-comment-format --width 26 "*PREFIX* " "this is a short comment." |
| 42 | test comment-5 {$RESULT eq "*PREFIX* this is a short c\n omment.\n(2 lines output)"} |
| 43 | |
| 44 | ############################################################################### |
| 45 | |
| 46 | fossil test-comment-format --width 26 --decode "*PREFIX* " "this is a short comment." |
| 47 | test comment-6 {$RESULT eq "*PREFIX* this is a short c\n omment.\n(2 lines output)"} |
| 48 | |
| 49 | ############################################################################### |
| 50 | |
| 51 | fossil test-comment-format --width 26 "" "this\\sis\\sa\\sshort\\scomment." |
| 52 | test comment-7 {$RESULT eq "this\\sis\\sa\\sshort\\scommen\nt.\n(2 lines output)"} |
| 53 | |
| 54 | ############################################################################### |
| 55 | |
| 56 | fossil test-comment-format --width 26 --decode "" "this\\sis\\sa\\sshort\\scomment." |
| 57 | test comment-8 {$RESULT eq "this is a short comment.\n(1 lines output)"} |
| 58 | |
| 59 | ############################################################################### |
| 60 | |
| 61 | fossil test-comment-format --width 78 --decode --trimspace "HH:MM:SS " "this is a long comment that should span multiple lines if the test is working correctly." |
| 62 | test comment-9 {$RESULT eq "HH:MM:SS this is a long comment that should span multiple lines if the test is\n working correctly.\n(2 lines output)"} |
| 63 | |
| 64 | ############################################################################### |
| 65 | |
| 66 | fossil test-comment-format --width 78 --decode --trimspace "HH:MM:SS " "this is a long comment that should span multiple lines if the test is working correctly. more text here describing the issue.\\nanother line here..................................................................................*" |
| 67 | test comment-10 {$RESULT eq "HH:MM:SS this is a long comment that should span multiple lines if the test is\n working correctly. more text here describing the issue.\n another line here....................................................\n ..............................*\n(4 lines output)"} |
| 68 | |
| 69 | ############################################################################### |
| 70 | |
| 71 | fossil test-comment-format --width 78 "HH:MM:SS " "....................................................................................*" |
| 72 | test comment-11 {$RESULT eq "HH:MM:SS .....................................................................\n ...............*\n(2 lines output)"} |
| 73 | |
| 74 | ############################################################################### |
| 75 | |
| 76 | fossil test-comment-format --width 78 "HH:MM:SS " ".....................................................................*" 78 |
| 77 | test comment-12 {$RESULT eq "HH:MM:SS .....................................................................\n *\n(2 lines output)"} |
| 78 | |
| 79 | ############################################################################### |
| 80 | |
| 81 | fossil test-comment-format --width 26 "*TEST* " "this\tis a test." |
| 82 | test comment-13 {$RESULT eq "*TEST* this\tis a te\n st.\n(2 lines output)"} |
| 83 | |
| 84 | ############################################################################### |
| 85 | |
| 86 | fossil test-comment-format --width 60 "*TEST* " "this is a test......................................................................................................................." |
| 87 | test comment-14 {$RESULT eq "*TEST* this is a test.......................................\n .....................................................\n ...........................\n(3 lines output)"} |
| 88 | |
| 89 | ############################################################################### |
| 90 | |
| 91 | fossil test-comment-format --width 60 --wordbreak "*TEST* " "this is a test......................................................................................................................." |
| 92 | test comment-15 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"} |
| 93 | |
| 94 | ############################################################################### |
| 95 | |
| 96 | fossil test-comment-format --width 60 "*TEST* " "this is a test......................................................................................................................." |
| 97 | test comment-16 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"} |
| 98 | |
| 99 | ############################################################################### |
| 100 | |
| 101 | fossil test-comment-format --width 60 --wordbreak "*TEST* " "this is a test......................................................................................................................." |
| 102 | test comment-17 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"} |
| 103 | |
| 104 | ############################################################################### |
| 105 | |
| 106 | fossil test-comment-format --width 60 "*TEST* " "one two three four five six seven eight nine ten eleven twelve" |
| 107 | test comment-18 {$RESULT eq "*TEST* one two three four five six seven eight nine ten elev\n en twelve\n(2 lines output)"} |
| 108 | |
| 109 | ############################################################################### |
| 110 | |
| 111 | fossil test-comment-format --width 60 --wordbreak "*TEST* " "one two three four five six seven eight nine ten eleven twelve" |
| 112 | test comment-19 {$RESULT eq "*TEST* one two three four five six seven eight nine ten\n eleven twelve\n(2 lines output)"} |
| 113 | |
| 114 | ############################################################################### |
| 115 | |
| 116 | fossil test-comment-format --width 60 "*TEST* " "one two three four five six seven eight nine ten eleven twelve" |
| 117 | test comment-20 {$RESULT eq "*TEST* one two three four five\n six seven eight nine ten\n eleven twelve\n(3 lines output)"} |
| 118 | |
| 119 | ############################################################################### |
| 120 | |
| 121 | fossil test-comment-format --width 60 --wordbreak "*TEST* " "one two three four five six seven eight nine ten eleven twelve" |
| 122 | test comment-21 {$RESULT eq "*TEST* one two three four five\n six seven eight nine ten\n eleven twelve\n(3 lines output)"} |
| 123 | |
| 124 | ############################################################################### |
| 125 | |
| 126 | fossil test-comment-format --legacy "" "" |
| @@ -131,97 +131,108 @@ | |
| 131 | fossil test-comment-format --legacy --decode "" "" |
| 132 | test comment-23 {$RESULT eq "\n(1 lines output)"} |
| 133 | |
| 134 | ############################################################################### |
| 135 | |
| 136 | fossil test-comment-format --width 26 --legacy " " "this is a short comment." |
| 137 | test comment-24 {$RESULT eq " this is a short comment.\n(1 lines output)"} |
| 138 | |
| 139 | ############################################################################### |
| 140 | |
| 141 | fossil test-comment-format --width 26 --legacy --decode " " "this is a short comment." |
| 142 | test comment-25 {$RESULT eq " this is a short comment.\n(1 lines output)"} |
| 143 | |
| 144 | ############################################################################### |
| 145 | |
| 146 | fossil test-comment-format --width 25 --legacy "*PREFIX* " "this is a short comment." |
| 147 | test comment-26 {$RESULT eq "*PREFIX* this is a short\n comment.\n(2 lines output)"} |
| 148 | |
| 149 | ############################################################################### |
| 150 | |
| 151 | fossil test-comment-format --width 25 --legacy --decode "*PREFIX* " "this is a short comment." |
| 152 | test comment-27 {$RESULT eq "*PREFIX* this is a short\n comment.\n(2 lines output)"} |
| 153 | |
| 154 | ############################################################################### |
| 155 | |
| 156 | fossil test-comment-format --width 26 --legacy "" "this\\sis\\sa\\sshort\\scomment." |
| 157 | test comment-28 {$RESULT eq "this\\sis\\sa\\sshort\\scommen\nt.\n(2 lines output)"} |
| 158 | |
| 159 | ############################################################################### |
| 160 | |
| 161 | fossil test-comment-format --width 26 --legacy --decode "" "this\\sis\\sa\\sshort\\scomment." |
| 162 | test comment-29 {$RESULT eq "this is a short comment.\n(1 lines output)"} |
| 163 | |
| 164 | ############################################################################### |
| 165 | |
| 166 | fossil test-comment-format --width 78 --legacy --decode "HH:MM:SS " "this is a long comment that should span multiple lines if the test is working correctly." |
| 167 | test comment-30 {$RESULT eq "HH:MM:SS this is a long comment that should span multiple lines if the test\n is working correctly.\n(2 lines output)"} |
| 168 | |
| 169 | ############################################################################### |
| 170 | |
| 171 | fossil test-comment-format --width 78 --legacy --decode "HH:MM:SS " "this is a long comment that should span multiple lines if the test is working correctly. more text here describing the issue.\\nanother line here..................................................................................*" |
| 172 | test comment-31 {$RESULT eq "HH:MM:SS this is a long comment that should span multiple lines if the test\n is working correctly. more text here describing the issue. another\n line\n here.................................................................\n .................*\n(5 lines output)"} |
| 173 | |
| 174 | ############################################################################### |
| 175 | |
| 176 | fossil test-comment-format --width 78 --legacy "HH:MM:SS " "....................................................................................*" |
| 177 | test comment-32 {$RESULT eq "HH:MM:SS .....................................................................\n ...............*\n(2 lines output)"} |
| 178 | |
| 179 | ############################################################################### |
| 180 | |
| 181 | fossil test-comment-format --width 78 --legacy "HH:MM:SS " ".....................................................................*" |
| 182 | test comment-33 {$RESULT eq "HH:MM:SS .....................................................................\n *\n(2 lines output)"} |
| 183 | |
| 184 | ############################################################################### |
| 185 | |
| 186 | fossil test-comment-format --width 26 --legacy "*TEST* " "this\tis a test." |
| 187 | test comment-34 {$RESULT eq "*TEST* this is a test.\n(1 lines output)"} |
| 188 | |
| 189 | ############################################################################### |
| 190 | |
| 191 | fossil test-comment-format --width 60 --legacy "*TEST* " "this is a test......................................................................................................................." |
| 192 | test comment-35 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"} |
| 193 | |
| 194 | ############################################################################### |
| 195 | |
| 196 | fossil test-comment-format --width 60 --legacy --wordbreak "*TEST* " "this is a test......................................................................................................................." |
| 197 | test comment-36 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"} |
| 198 | |
| 199 | ############################################################################### |
| 200 | |
| 201 | fossil test-comment-format --width 60 --legacy "*TEST* " "this is a test......................................................................................................................." |
| 202 | test comment-37 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"} |
| 203 | |
| 204 | ############################################################################### |
| 205 | |
| 206 | fossil test-comment-format --width 60 --legacy --wordbreak "*TEST* " "this is a test......................................................................................................................." |
| 207 | test comment-38 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"} |
| 208 | |
| 209 | ############################################################################### |
| 210 | |
| 211 | fossil test-comment-format --width 60 --legacy "*TEST* " "one two three four five six seven eight nine ten eleven twelve" |
| 212 | test comment-39 {$RESULT eq "*TEST* one two three four five six seven eight nine ten\n eleven twelve\n(2 lines output)"} |
| 213 | |
| 214 | ############################################################################### |
| 215 | |
| 216 | fossil test-comment-format --width 60 --legacy --wordbreak "*TEST* " "one two three four five six seven eight nine ten eleven twelve" |
| 217 | test comment-40 {$RESULT eq "*TEST* one two three four five six seven eight nine ten\n eleven twelve\n(2 lines output)"} |
| 218 | |
| 219 | ############################################################################### |
| 220 | |
| 221 | fossil test-comment-format --width 60 --legacy "*TEST* " "one two three four five six seven eight nine ten eleven twelve" |
| 222 | test comment-41 {$RESULT eq "*TEST* one two three four five six seven eight nine ten\n eleven twelve\n(2 lines output)"} |
| 223 | |
| 224 | ############################################################################### |
| 225 | |
| 226 | fossil test-comment-format --width 60 --legacy --wordbreak "*TEST* " "one two three four five six seven eight nine ten eleven twelve" |
| 227 | test comment-42 {$RESULT eq "*TEST* one two three four five six seven eight nine ten\n eleven twelve\n(2 lines output)"} |
| 228 | |
| 229 | ############################################################################### |
| 230 | |
| 231 | set orig "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." |
| 232 | fossil test-comment-format --width 73 --decode --origbreak "" $orig $orig |
| 233 | test comment-43 {$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)"} |
| 234 | |
| 235 | ############################################################################### |
| 236 | |
| 237 | fossil test-comment-format --width 73 --decode --origbreak "" "00:00:00 \[0000000000\] *CURRENT* $orig" $orig |
| 238 | test comment-44 {$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)"} |
| 239 |