Fossil SCM

Add --file option to the test-comment-format test command.

mistachkin 2014-07-23 18:26 trunk
Commit b1b352e1cce404c84f8ec86b53d627823ad2f09b
1 file changed +11 -3
+11 -3
--- src/comformat.c
+++ src/comformat.c
@@ -364,10 +364,12 @@
364364
** Usage: %fossil test-comment-format ?OPTIONS? PREFIX TEXT ?WIDTH?
365365
**
366366
** Test comment formatting and printing. Use for testing only.
367367
**
368368
** Options:
369
+** --file The comment text is really just a file name to
370
+** read it from.
369371
** --decode Decode the text using the same method used when
370372
** handling the value of a C-card from a manifest.
371373
** --legacy Use the legacy comment printing algorithm.
372374
** --trimspace Enable trimming of leading/trailing spaces.
373375
** --wordbreak Attempt to break lines on word boundaries.
@@ -374,10 +376,11 @@
374376
*/
375377
void test_comment_format(void){
376378
const char *zPrefix;
377379
char *zText;
378380
int indent, width;
381
+ int fromFile = find_option("file", 0, 0)!=0;
379382
int decode = find_option("decode", 0, 0)!=0;
380383
int flags = COMMENT_PRINT_NONE;
381384
if( find_option("legacy", 0, 0) ){
382385
flags |= COMMENT_PRINT_LEGACY;
383386
}
@@ -389,15 +392,20 @@
389392
}
390393
if( g.argc!=4 && g.argc!=5 ){
391394
usage("?OPTIONS? PREFIX TEXT ?WIDTH?");
392395
}
393396
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
+ }
394404
if( decode ){
395
- zText = mprintf("%s", g.argv[3]);
405
+ zText = mprintf("%s", zText);
396406
defossilize(zText);
397
- }else{
398
- zText = g.argv[3];
399407
}
400408
indent = strlen(zPrefix);
401409
if( g.argc==5 ){
402410
width = atoi(g.argv[4]);
403411
}else{
404412
--- 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

Keyboard Shortcuts

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