Fossil SCM
Add --file option to the test-comment-format test command.
Commit
b1b352e1cce404c84f8ec86b53d627823ad2f09b
Parent
f1b148df7fd0e58…
1 file changed
+11
-3
+11
-3
| --- src/comformat.c | ||
| +++ src/comformat.c | ||
| @@ -364,10 +364,12 @@ | ||
| 364 | 364 | ** Usage: %fossil test-comment-format ?OPTIONS? PREFIX TEXT ?WIDTH? |
| 365 | 365 | ** |
| 366 | 366 | ** Test comment formatting and printing. Use for testing only. |
| 367 | 367 | ** |
| 368 | 368 | ** Options: |
| 369 | +** --file The comment text is really just a file name to | |
| 370 | +** read it from. | |
| 369 | 371 | ** --decode Decode the text using the same method used when |
| 370 | 372 | ** handling the value of a C-card from a manifest. |
| 371 | 373 | ** --legacy Use the legacy comment printing algorithm. |
| 372 | 374 | ** --trimspace Enable trimming of leading/trailing spaces. |
| 373 | 375 | ** --wordbreak Attempt to break lines on word boundaries. |
| @@ -374,10 +376,11 @@ | ||
| 374 | 376 | */ |
| 375 | 377 | void test_comment_format(void){ |
| 376 | 378 | const char *zPrefix; |
| 377 | 379 | char *zText; |
| 378 | 380 | int indent, width; |
| 381 | + int fromFile = find_option("file", 0, 0)!=0; | |
| 379 | 382 | int decode = find_option("decode", 0, 0)!=0; |
| 380 | 383 | int flags = COMMENT_PRINT_NONE; |
| 381 | 384 | if( find_option("legacy", 0, 0) ){ |
| 382 | 385 | flags |= COMMENT_PRINT_LEGACY; |
| 383 | 386 | } |
| @@ -389,15 +392,20 @@ | ||
| 389 | 392 | } |
| 390 | 393 | if( g.argc!=4 && g.argc!=5 ){ |
| 391 | 394 | usage("?OPTIONS? PREFIX TEXT ?WIDTH?"); |
| 392 | 395 | } |
| 393 | 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 | + } | |
| 394 | 404 | if( decode ){ |
| 395 | - zText = mprintf("%s", g.argv[3]); | |
| 405 | + zText = mprintf("%s", zText); | |
| 396 | 406 | defossilize(zText); |
| 397 | - }else{ | |
| 398 | - zText = g.argv[3]; | |
| 399 | 407 | } |
| 400 | 408 | indent = strlen(zPrefix); |
| 401 | 409 | if( g.argc==5 ){ |
| 402 | 410 | width = atoi(g.argv[4]); |
| 403 | 411 | }else{ |
| 404 | 412 |
| --- src/comformat.c | |
| +++ src/comformat.c | |
| @@ -364,10 +364,12 @@ | |
| 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 | ** --decode Decode the text using the same method used when |
| 370 | ** handling the value of a C-card from a manifest. |
| 371 | ** --legacy Use the legacy comment printing algorithm. |
| 372 | ** --trimspace Enable trimming of leading/trailing spaces. |
| 373 | ** --wordbreak Attempt to break lines on word boundaries. |
| @@ -374,10 +376,11 @@ | |
| 374 | */ |
| 375 | void test_comment_format(void){ |
| 376 | const char *zPrefix; |
| 377 | char *zText; |
| 378 | int indent, width; |
| 379 | int decode = find_option("decode", 0, 0)!=0; |
| 380 | int flags = COMMENT_PRINT_NONE; |
| 381 | if( find_option("legacy", 0, 0) ){ |
| 382 | flags |= COMMENT_PRINT_LEGACY; |
| 383 | } |
| @@ -389,15 +392,20 @@ | |
| 389 | } |
| 390 | if( g.argc!=4 && g.argc!=5 ){ |
| 391 | usage("?OPTIONS? PREFIX TEXT ?WIDTH?"); |
| 392 | } |
| 393 | zPrefix = g.argv[2]; |
| 394 | if( decode ){ |
| 395 | zText = mprintf("%s", g.argv[3]); |
| 396 | defossilize(zText); |
| 397 | }else{ |
| 398 | zText = g.argv[3]; |
| 399 | } |
| 400 | indent = strlen(zPrefix); |
| 401 | if( g.argc==5 ){ |
| 402 | width = atoi(g.argv[4]); |
| 403 | }else{ |
| 404 |
| --- src/comformat.c | |
| +++ src/comformat.c | |
| @@ -364,10 +364,12 @@ | |
| 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 |
| 370 | ** read it from. |
| 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. |
| @@ -374,10 +376,11 @@ | |
| 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) ){ |
| 385 | flags |= COMMENT_PRINT_LEGACY; |
| 386 | } |
| @@ -389,15 +392,20 @@ | |
| 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 |