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.

mistachkin 2014-07-23 21:37 trunk
Commit 0d0b80fd1cafff21194e6a7f953f006f616fb9ad
+1 -1
--- src/bisect.c
+++ src/bisect.c
@@ -390,11 +390,11 @@
390390
for(i=0; i<sizeof(aBisectOption)/sizeof(aBisectOption[0]); i++){
391391
char *z = mprintf("bisect-%s", aBisectOption[i].zName);
392392
fossil_print(" %-15s %-6s ", aBisectOption[i].zName,
393393
db_lget(z, (char*)aBisectOption[i].zDefault));
394394
fossil_free(z);
395
- comment_print(aBisectOption[i].zDesc, 27, -1, g.comFmtFlags);
395
+ comment_print(aBisectOption[i].zDesc, 0, 27, -1, g.comFmtFlags);
396396
}
397397
}else if( g.argc==4 || g.argc==5 ){
398398
unsigned int i;
399399
n = strlen(g.argv[3]);
400400
for(i=0; i<sizeof(aBisectOption)/sizeof(aBisectOption[0]); i++){
401401
--- 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 @@
3333
#if INTERFACE
3434
#define COMMENT_PRINT_NONE ((u32)0x00000000) /* No flags. */
3535
#define COMMENT_PRINT_LEGACY ((u32)0x00000001) /* Use legacy algorithm. */
3636
#define COMMENT_PRINT_TRIM_SPACE ((u32)0x00000002) /* Trim leading/trailing. */
3737
#define COMMENT_PRINT_WORD_BREAK ((u32)0x00000004) /* Break lines on words. */
38
+#define COMMENT_PRINT_ORIG_BREAK ((u32)0x00000008) /* Break before original. */
3839
#define COMMENT_PRINT_DEFAULT (COMMENT_PRINT_LEGACY) /* Defaults. */
3940
#endif
4041
4142
/*
4243
** This is the previous value used by most external callers when they
@@ -51,10 +52,30 @@
5152
** This is the number of spaces to print when a tab character is seen.
5253
*/
5354
#ifndef COMMENT_TAB_WIDTH
5455
# define COMMENT_TAB_WIDTH (8)
5556
#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
+}
5677
5778
/*
5879
** This function scans the specified comment line starting just after the
5980
** initial index and returns the index of the next spacing character -OR-
6081
** zero if such a character cannot be found. For the purposes of this
@@ -98,17 +119,19 @@
98119
/*
99120
** This function prints one logical line of a comment, stopping when it hits
100121
** a new line -OR- runs out of space on the logical line.
101122
*/
102123
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. */
110133
){
111134
int index = 0, charCnt = 0, lineCnt = 0, maxChars;
112135
if( !zLine ) return;
113136
if( lineChars<=0 ) return;
114137
comment_print_indent(zLine, indent, trimSpace, &index);
@@ -116,10 +139,15 @@
116139
for(;;){
117140
char c = zLine[index];
118141
if( c==0 ){
119142
break;
120143
}else{
144
+ if( origBreak && index>0 ){
145
+ if( comment_check_orig(zOrigText, &zLine[index], &charCnt, &lineCnt) ){
146
+ maxChars = lineChars;
147
+ }
148
+ }
121149
index++;
122150
}
123151
if( c=='\n' ){
124152
charCnt = 0;
125153
lineCnt++;
@@ -284,28 +312,35 @@
284312
** If this flag is not specified, honoring the
285313
** logical line length may result in breaking
286314
** lines in the middle of words. This flag
287315
** does not apply to the legacy comment
288316
** 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.
289322
**
290323
** Given a comment string, format that string for printing on a TTY.
291324
** Assume that the output cursors is indent spaces from the left margin
292325
** and that a single line can contain no more than 'width' characters.
293326
** Indent all subsequent lines by 'indent'.
294327
**
295328
** Returns the number of new lines emitted.
296329
*/
297330
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. */
302336
){
303337
int maxChars = width - indent;
304338
int legacy = flags & COMMENT_PRINT_LEGACY;
305339
int trimSpace = flags & COMMENT_PRINT_TRIM_SPACE;
306340
int wordBreak = flags & COMMENT_PRINT_WORD_BREAK;
341
+ int origBreak = flags & COMMENT_PRINT_ORIG_BREAK;
307342
int lineCnt = 0;
308343
const char *zLine;
309344
310345
if( legacy ){
311346
return comment_print_legacy(zText, indent, width);
@@ -348,22 +383,22 @@
348383
lineCnt++;
349384
return lineCnt;
350385
}
351386
zLine = zText;
352387
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);
355390
if( !zLine || !zLine[0] ) break;
356391
}
357392
return lineCnt;
358393
}
359394
360395
/*
361396
**
362397
** COMMAND: test-comment-format
363398
**
364
-** Usage: %fossil test-comment-format ?OPTIONS? PREFIX TEXT ?WIDTH?
399
+** Usage: %fossil test-comment-format ?OPTIONS? PREFIX TEXT ?ORIGTEXT?
365400
**
366401
** Test comment formatting and printing. Use for testing only.
367402
**
368403
** Options:
369404
** --file The comment text is really just a file name to
@@ -371,14 +406,20 @@
371406
** --decode Decode the text using the same method used when
372407
** handling the value of a C-card from a manifest.
373408
** --legacy Use the legacy comment printing algorithm.
374409
** --trimspace Enable trimming of leading/trailing spaces.
375410
** --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.
376415
*/
377416
void test_comment_format(void){
417
+ const char *zWidth;
378418
const char *zPrefix;
379419
char *zText;
420
+ char *zOrigText;
380421
int indent, width;
381422
int fromFile = find_option("file", 0, 0)!=0;
382423
int decode = find_option("decode", 0, 0)!=0;
383424
int flags = COMMENT_PRINT_NONE;
384425
if( find_option("legacy", 0, 0) ){
@@ -388,33 +429,47 @@
388429
flags |= COMMENT_PRINT_TRIM_SPACE;
389430
}
390431
if( find_option("wordbreak", 0, 0) ){
391432
flags |= COMMENT_PRINT_WORD_BREAK;
392433
}
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
+ }
393443
if( g.argc!=4 && g.argc!=5 ){
394
- usage("?OPTIONS? PREFIX TEXT ?WIDTH?");
444
+ usage("?OPTIONS? PREFIX TEXT ?ORIGTEXT?");
395445
}
396446
zPrefix = g.argv[2];
397447
zText = g.argv[3];
448
+ if( g.argc==5 ){
449
+ zOrigText = g.argv[4];
450
+ }else{
451
+ zOrigText = 0;
452
+ }
398453
if( fromFile ){
399454
Blob fileData;
400455
blob_read_from_file(&fileData, zText);
401456
zText = mprintf("%s", blob_str(&fileData));
402457
blob_reset(&fileData);
403458
}
404459
if( decode ){
405460
zText = mprintf("%s", zText);
406461
defossilize(zText);
462
+ if( zOrigText ){
463
+ zOrigText = mprintf("%s", zOrigText);
464
+ defossilize(zOrigText);
465
+ }
407466
}
408467
indent = strlen(zPrefix);
409
- if( g.argc==5 ){
410
- width = atoi(g.argv[4]);
411
- }else{
412
- width = -1; /* automatic */
413
- }
414468
if( indent>0 ){
415469
fossil_print("%s", zPrefix);
416470
}
417471
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);
420475
}
421476
--- 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
--- src/descendants.c
+++ src/descendants.c
@@ -407,11 +407,11 @@
407407
}
408408
n++;
409409
sqlite3_snprintf(sizeof(zLineNo), zLineNo, "(%d)", n);
410410
fossil_print("%6s ", zLineNo);
411411
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);
413413
fossil_free(z);
414414
}
415415
fossil_free(zLastBr);
416416
db_finalize(&q);
417417
}
418418
--- 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 @@
202202
if( iBrief ){
203203
fossil_print("%s ", zDate);
204204
zOut = sqlite3_mprintf(
205205
"[%S] %s (user: %s, artifact: [%S], branch: %s)",
206206
zCiUuid, zCom, zUser, zFileUuid, zBr);
207
- comment_print(zOut, 11, iWidth, g.comFmtFlags);
207
+ comment_print(zOut, zCom, 11, iWidth, g.comFmtFlags);
208208
sqlite3_free(zOut);
209209
}else{
210210
blob_reset(&line);
211211
blob_appendf(&line, "%.10s ", zCiUuid);
212212
blob_appendf(&line, "%.10s ", zDate);
213213
blob_appendf(&line, "%8.8s ", zUser);
214214
blob_appendf(&line, "%8.8s ", zBr);
215215
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);
217217
}
218218
}
219219
db_finalize(&q);
220220
blob_reset(&fname);
221221
}
222222
--- 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 @@
132132
fossil_print("tags: %s\n", zTags);
133133
}
134134
free(zTags);
135135
if( zComment ){
136136
fossil_print("comment: ");
137
- comment_print(zComment, 14, -1, g.comFmtFlags);
137
+ comment_print(zComment, 0, 14, -1, g.comFmtFlags);
138138
free(zComment);
139139
}
140140
}
141141
142142
/*
143143
--- 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 @@
4747
indent-1, zLabel,
4848
db_column_text(&q, 3),
4949
db_column_text(&q, 1),
5050
db_column_text(&q, 0),
5151
indent, "");
52
- comment_print(zCom, indent, -1, g.comFmtFlags);
52
+ comment_print(zCom, db_column_text(&q,2), indent, -1, g.comFmtFlags);
5353
fossil_free(zCom);
5454
}
5555
db_finalize(&q);
5656
}
5757
@@ -210,11 +210,11 @@
210210
);
211211
if( db_step(&q)==SQLITE_ROW ){
212212
char *zCom = mprintf("Merging fork [%S] at %s by %s: \"%s\"",
213213
db_column_text(&q, 0), db_column_text(&q, 1),
214214
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);
216216
fossil_free(zCom);
217217
}
218218
db_finalize(&q);
219219
}else{
220220
usage("?OPTIONS? ?VERSION?");
221221
--- 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 @@
582582
default: zType = "Unknown"; break;
583583
}
584584
fossil_print("type: %s by %s on %s\n", zType, db_column_text(&q,2),
585585
db_column_text(&q, 1));
586586
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);
588588
}
589589
db_finalize(&q);
590590
591591
/* Check to see if this object is used as a file in a check-in */
592592
db_prepare(&q,
@@ -604,11 +604,11 @@
604604
fossil_print(" part of [%S] by %s on %s\n",
605605
db_column_text(&q, 1),
606606
db_column_text(&q, 3),
607607
db_column_text(&q, 2));
608608
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);
610610
}
611611
db_finalize(&q);
612612
613613
/* Check to see if this object is used as an attachment */
614614
db_prepare(&q,
@@ -639,11 +639,11 @@
639639
db_column_text(&q,7));
640640
}
641641
fossil_print(" by user %s on %s\n",
642642
db_column_text(&q,2), db_column_text(&q,3));
643643
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);
645645
}
646646
db_finalize(&q);
647647
}
648648
649649
/*
650650
--- 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 @@
552552
db_column_text(&q, 3)
553553
);
554554
zCom = db_column_text(&q, 2);
555555
if( zCom && zCom[0] ){
556556
fossil_print(" ");
557
- comment_print(zCom, 7, width, g.comFmtFlags);
557
+ comment_print(zCom, 0, 7, width, g.comFmtFlags);
558558
}
559559
if( verboseFlag ){
560560
db_bind_int(&q2, "$id", stashid);
561561
while( db_step(&q2)==SQLITE_ROW ){
562562
int isAdded = db_column_int(&q2, 0);
563563
--- 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 @@
16031603
sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*CURRENT* ");
16041604
n += strlen(zPrefix);
16051605
}
16061606
zFree = mprintf("[%S] %s%s", zId, zPrefix, zCom);
16071607
/* record another X lines */
1608
- nLine += comment_print(zFree, 9, width, g.comFmtFlags);
1608
+ nLine += comment_print(zFree, zCom, 9, width, g.comFmtFlags);
16091609
fossil_free(zFree);
16101610
16111611
if(verboseFlag){
16121612
if( !fchngQueryInit ){
16131613
db_prepare(&fchngQuery,
16141614
--- 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 @@
12641264
fossil_print(" Change ");
12651265
}
12661266
fossil_print("%h: ",z);
12671267
if( blob_size(&val)>50 || contains_newline(&val)) {
12681268
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);
12701270
}else{
12711271
fossil_print("%s\n",blob_str(&val));
12721272
}
12731273
blob_reset(&val);
12741274
}
12751275
--- 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 @@
2626
fossil test-comment-format --decode "" ""
2727
test comment-2 {$RESULT eq "\n(1 lines output)"}
2828
2929
###############################################################################
3030
31
-fossil test-comment-format " " "this is a short comment." 26
31
+fossil test-comment-format --width 26 " " "this is a short comment."
3232
test comment-3 {$RESULT eq " this is a short comment.\n(1 lines output)"}
3333
3434
###############################################################################
3535
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."
3737
test comment-4 {$RESULT eq " this is a short comment.\n(1 lines output)"}
3838
3939
###############################################################################
4040
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."
4242
test comment-5 {$RESULT eq "*PREFIX* this is a short c\n omment.\n(2 lines output)"}
4343
4444
###############################################################################
4545
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."
4747
test comment-6 {$RESULT eq "*PREFIX* this is a short c\n omment.\n(2 lines output)"}
4848
4949
###############################################################################
5050
51
-fossil test-comment-format "" "this\\sis\\sa\\sshort\\scomment." 26
51
+fossil test-comment-format --width 26 "" "this\\sis\\sa\\sshort\\scomment."
5252
test comment-7 {$RESULT eq "this\\sis\\sa\\sshort\\scommen\nt.\n(2 lines output)"}
5353
5454
###############################################################################
5555
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."
5757
test comment-8 {$RESULT eq "this is a short comment.\n(1 lines output)"}
5858
5959
###############################################################################
6060
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."
6262
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)"}
6363
6464
###############################################################################
6565
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..................................................................................*"
6767
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)"}
6868
6969
###############################################################################
7070
71
-fossil test-comment-format "HH:MM:SS " "....................................................................................*" 78
71
+fossil test-comment-format --width 78 "HH:MM:SS " "....................................................................................*"
7272
test comment-11 {$RESULT eq "HH:MM:SS .....................................................................\n ...............*\n(2 lines output)"}
7373
7474
###############################################################################
7575
76
-fossil test-comment-format "HH:MM:SS " ".....................................................................*" 78
76
+fossil test-comment-format --width 78 "HH:MM:SS " ".....................................................................*" 78
7777
test comment-12 {$RESULT eq "HH:MM:SS .....................................................................\n *\n(2 lines output)"}
7878
7979
###############################################################################
8080
81
-fossil test-comment-format "*TEST* " "this\tis a test." 26
81
+fossil test-comment-format --width 26 "*TEST* " "this\tis a test."
8282
test comment-13 {$RESULT eq "*TEST* this\tis a te\n st.\n(2 lines output)"}
8383
8484
###############################################################################
8585
86
-fossil test-comment-format "*TEST* " "this is a test......................................................................................................................." 60
86
+fossil test-comment-format --width 60 "*TEST* " "this is a test......................................................................................................................."
8787
test comment-14 {$RESULT eq "*TEST* this is a test.......................................\n .....................................................\n ...........................\n(3 lines output)"}
8888
8989
###############################################################################
9090
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......................................................................................................................."
9292
test comment-15 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"}
9393
9494
###############################################################################
9595
96
-fossil test-comment-format "*TEST* " "this is a test......................................................................................................................." 60
96
+fossil test-comment-format --width 60 "*TEST* " "this is a test......................................................................................................................."
9797
test comment-16 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"}
9898
9999
###############################################################################
100100
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......................................................................................................................."
102102
test comment-17 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"}
103103
104104
###############################################################################
105105
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"
107107
test comment-18 {$RESULT eq "*TEST* one two three four five six seven eight nine ten elev\n en twelve\n(2 lines output)"}
108108
109109
###############################################################################
110110
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"
112112
test comment-19 {$RESULT eq "*TEST* one two three four five six seven eight nine ten\n eleven twelve\n(2 lines output)"}
113113
114114
###############################################################################
115115
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"
117117
test comment-20 {$RESULT eq "*TEST* one two three four five\n six seven eight nine ten\n eleven twelve\n(3 lines output)"}
118118
119119
###############################################################################
120120
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"
122122
test comment-21 {$RESULT eq "*TEST* one two three four five\n six seven eight nine ten\n eleven twelve\n(3 lines output)"}
123123
124124
###############################################################################
125125
126126
fossil test-comment-format --legacy "" ""
@@ -131,97 +131,108 @@
131131
fossil test-comment-format --legacy --decode "" ""
132132
test comment-23 {$RESULT eq "\n(1 lines output)"}
133133
134134
###############################################################################
135135
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."
137137
test comment-24 {$RESULT eq " this is a short comment.\n(1 lines output)"}
138138
139139
###############################################################################
140140
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."
142142
test comment-25 {$RESULT eq " this is a short comment.\n(1 lines output)"}
143143
144144
###############################################################################
145145
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."
147147
test comment-26 {$RESULT eq "*PREFIX* this is a short\n comment.\n(2 lines output)"}
148148
149149
###############################################################################
150150
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."
152152
test comment-27 {$RESULT eq "*PREFIX* this is a short\n comment.\n(2 lines output)"}
153153
154154
###############################################################################
155155
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."
157157
test comment-28 {$RESULT eq "this\\sis\\sa\\sshort\\scommen\nt.\n(2 lines output)"}
158158
159159
###############################################################################
160160
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."
162162
test comment-29 {$RESULT eq "this is a short comment.\n(1 lines output)"}
163163
164164
###############################################################################
165165
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."
167167
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)"}
168168
169169
###############################################################################
170170
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..................................................................................*"
172172
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)"}
173173
174174
###############################################################################
175175
176
-fossil test-comment-format --legacy "HH:MM:SS " "....................................................................................*" 78
176
+fossil test-comment-format --width 78 --legacy "HH:MM:SS " "....................................................................................*"
177177
test comment-32 {$RESULT eq "HH:MM:SS .....................................................................\n ...............*\n(2 lines output)"}
178178
179179
###############################################################################
180180
181
-fossil test-comment-format --legacy "HH:MM:SS " ".....................................................................*" 78
181
+fossil test-comment-format --width 78 --legacy "HH:MM:SS " ".....................................................................*"
182182
test comment-33 {$RESULT eq "HH:MM:SS .....................................................................\n *\n(2 lines output)"}
183183
184184
###############################################################################
185185
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."
187187
test comment-34 {$RESULT eq "*TEST* this is a test.\n(1 lines output)"}
188188
189189
###############################################################################
190190
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......................................................................................................................."
192192
test comment-35 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"}
193193
194194
###############################################################################
195195
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......................................................................................................................."
197197
test comment-36 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"}
198198
199199
###############################################################################
200200
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......................................................................................................................."
202202
test comment-37 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"}
203203
204204
###############################################################################
205205
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......................................................................................................................."
207207
test comment-38 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"}
208208
209209
###############################################################################
210210
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"
212212
test comment-39 {$RESULT eq "*TEST* one two three four five six seven eight nine ten\n eleven twelve\n(2 lines output)"}
213213
214214
###############################################################################
215215
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"
217217
test comment-40 {$RESULT eq "*TEST* one two three four five six seven eight nine ten\n eleven twelve\n(2 lines output)"}
218218
219219
###############################################################################
220220
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"
222222
test comment-41 {$RESULT eq "*TEST* one two three four five six seven eight nine ten\n eleven twelve\n(2 lines output)"}
223223
224224
###############################################################################
225225
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"
227227
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)"}
228239
--- 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

Keyboard Shortcuts

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