Fossil SCM
Add an alternative comment printing algorithm, disabled by default, which permits the pre-existing comment formatting to be preserved.
Commit
b6c9d35b1c1ec94e60910bbdf74f787b88cd88e4
Parent
619fa857c9330c1…
13 files changed
+1
-1
+250
-14
+1
-1
+2
-2
+1
-1
+17
+2
-2
+3
-3
+6
-2
+1
-1
+2
-1
+1
-1
+120
-15
+1
-1
| --- src/bisect.c | ||
| +++ src/bisect.c | ||
| @@ -390,11 +390,11 @@ | ||
| 390 | 390 | for(i=0; i<sizeof(aBisectOption)/sizeof(aBisectOption[0]); i++){ |
| 391 | 391 | char *z = mprintf("bisect-%s", aBisectOption[i].zName); |
| 392 | 392 | fossil_print(" %-15s %-6s ", aBisectOption[i].zName, |
| 393 | 393 | db_lget(z, (char*)aBisectOption[i].zDefault)); |
| 394 | 394 | fossil_free(z); |
| 395 | - comment_print(aBisectOption[i].zDesc, 27, -1); | |
| 395 | + comment_print(aBisectOption[i].zDesc, 27, -1, g.comFmtFlags); | |
| 396 | 396 | } |
| 397 | 397 | }else if( g.argc==4 || g.argc==5 ){ |
| 398 | 398 | unsigned int i; |
| 399 | 399 | n = strlen(g.argv[3]); |
| 400 | 400 | for(i=0; i<sizeof(aBisectOption)/sizeof(aBisectOption[0]); i++){ |
| 401 | 401 |
| --- src/bisect.c | |
| +++ src/bisect.c | |
| @@ -390,11 +390,11 @@ | |
| 390 | for(i=0; i<sizeof(aBisectOption)/sizeof(aBisectOption[0]); i++){ |
| 391 | char *z = mprintf("bisect-%s", aBisectOption[i].zName); |
| 392 | fossil_print(" %-15s %-6s ", aBisectOption[i].zName, |
| 393 | db_lget(z, (char*)aBisectOption[i].zDefault)); |
| 394 | fossil_free(z); |
| 395 | comment_print(aBisectOption[i].zDesc, 27, -1); |
| 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, 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 |
+250
-14
| --- src/comformat.c | ||
| +++ src/comformat.c | ||
| @@ -28,10 +28,18 @@ | ||
| 28 | 28 | # if defined(TIOCGWINSZ) |
| 29 | 29 | # include <sys/ioctl.h> |
| 30 | 30 | # endif |
| 31 | 31 | #endif |
| 32 | 32 | |
| 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 | + | |
| 33 | 41 | /* |
| 34 | 42 | ** This is the previous value used by most external callers when they |
| 35 | 43 | ** needed to specify a default maximum line length to be used with the |
| 36 | 44 | ** comment_print() function. |
| 37 | 45 | */ |
| @@ -38,43 +46,164 @@ | ||
| 38 | 46 | #ifndef COMMENT_LEGACY_LINE_LENGTH |
| 39 | 47 | # define COMMENT_LEGACY_LINE_LENGTH (78) |
| 40 | 48 | #endif |
| 41 | 49 | |
| 42 | 50 | /* |
| 43 | -** Given a comment string zText, format that string for printing | |
| 44 | -** on a TTY. Assume that the output cursors is indent spaces from | |
| 45 | -** the left margin and that a single line can contain no more than | |
| 46 | -** lineLength characters. Indent all subsequent lines by indent. | |
| 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 | |
| 61 | +** algorithm, the NUL character is treated the same as a spacing character. | |
| 62 | +*/ | |
| 63 | +static int comment_next_space( | |
| 64 | + const char *zLine, /* [in] The comment line being printed. */ | |
| 65 | + int index /* [in] The current character index being handled. */ | |
| 66 | +){ | |
| 67 | + int nextIndex = index + 1; | |
| 68 | + for(;;){ | |
| 69 | + char c = zLine[nextIndex]; | |
| 70 | + if( c==0 || fossil_isspace(c) ){ | |
| 71 | + return nextIndex; | |
| 72 | + } | |
| 73 | + nextIndex++; | |
| 74 | + } | |
| 75 | + return 0; /* NOT REACHED */ | |
| 76 | +} | |
| 77 | + | |
| 78 | +/* | |
| 79 | +** This function is called when printing a logical comment line to perform | |
| 80 | +** the necessary indenting. | |
| 81 | +*/ | |
| 82 | +static void comment_print_indent( | |
| 83 | + const char *zLine, /* [in] The comment line being printed. */ | |
| 84 | + int indent, /* [in] Number of spaces to indent, zero for none. */ | |
| 85 | + int trimSpace, /* [in] Non-zero to trim leading/trailing spaces. */ | |
| 86 | + int *piIndex /* [in/out] Pointer to first non-space character. */ | |
| 87 | +){ | |
| 88 | + if( indent>0 ){ | |
| 89 | + fossil_print("%*s", indent, ""); | |
| 90 | + if( trimSpace && zLine && piIndex ){ | |
| 91 | + int index = *piIndex; | |
| 92 | + while( fossil_isspace(zLine[index]) ){ index++; } | |
| 93 | + *piIndex = index; | |
| 94 | + } | |
| 95 | + } | |
| 96 | +} | |
| 97 | + | |
| 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); | |
| 115 | + maxChars = lineChars; | |
| 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++; | |
| 126 | + }else if( c=='\t' ){ | |
| 127 | + int nextIndex = comment_next_space(zLine, index); | |
| 128 | + if( nextIndex<=0 || (nextIndex-index)>maxChars ){ | |
| 129 | + break; | |
| 130 | + } | |
| 131 | + charCnt++; | |
| 132 | + if( maxChars<COMMENT_TAB_WIDTH ){ | |
| 133 | + fossil_print(" "); | |
| 134 | + break; | |
| 135 | + } | |
| 136 | + maxChars -= COMMENT_TAB_WIDTH; | |
| 137 | + }else if( wordBreak && fossil_isspace(c) ){ | |
| 138 | + int nextIndex = comment_next_space(zLine, index); | |
| 139 | + if( nextIndex<=0 || (nextIndex-index)>maxChars ){ | |
| 140 | + break; | |
| 141 | + } | |
| 142 | + charCnt++; | |
| 143 | + maxChars--; | |
| 144 | + }else{ | |
| 145 | + charCnt++; | |
| 146 | + maxChars--; | |
| 147 | + } | |
| 148 | + fossil_print("%c", c); | |
| 149 | + if( maxChars==0 ) break; | |
| 150 | + if( c=='\n' ) break; | |
| 151 | + } | |
| 152 | + if( charCnt>0 ){ | |
| 153 | + fossil_print("\n"); | |
| 154 | + lineCnt++; | |
| 155 | + } | |
| 156 | + if( pLineCnt ){ | |
| 157 | + *pLineCnt += lineCnt; | |
| 158 | + } | |
| 159 | + if( pzLine ){ | |
| 160 | + *pzLine = zLine + index; | |
| 161 | + } | |
| 162 | +} | |
| 163 | + | |
| 164 | +/* | |
| 165 | +** This is the legacy comment printing algorithm. It is being retained | |
| 166 | +** for backward compatibility. | |
| 167 | +** | |
| 168 | +** Given a comment string, format that string for printing on a TTY. | |
| 169 | +** Assume that the output cursors is indent spaces from the left margin | |
| 170 | +** and that a single line can contain no more than 'width' characters. | |
| 171 | +** Indent all subsequent lines by 'indent'. | |
| 47 | 172 | ** |
| 48 | -** Return the number of newlines that are output. | |
| 173 | +** Returns the number of new lines emitted. | |
| 49 | 174 | */ |
| 50 | -int comment_print(const char *zText, int indent, int lineLength){ | |
| 51 | - int tlen = lineLength - indent; | |
| 175 | +static int comment_print_legacy( | |
| 176 | + const char *zText, /* The comment text to be printed. */ | |
| 177 | + int indent, /* Number of spaces to indent each non-initial line. */ | |
| 178 | + int width /* Maximum number of characters per line. */ | |
| 179 | +){ | |
| 180 | + int tlen = width - indent; | |
| 52 | 181 | int si, sk, i, k; |
| 53 | 182 | int doIndent = 0; |
| 54 | 183 | char *zBuf; |
| 55 | 184 | char zBuffer[400]; |
| 56 | 185 | int lineCnt = 0; |
| 57 | 186 | |
| 58 | 187 | #if defined(_WIN32) |
| 59 | - if( lineLength<0 ){ | |
| 188 | + if( width<0 ){ | |
| 60 | 189 | CONSOLE_SCREEN_BUFFER_INFO csbi; |
| 61 | 190 | memset(&csbi, 0, sizeof(CONSOLE_SCREEN_BUFFER_INFO)); |
| 62 | 191 | if( GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi) ){ |
| 63 | 192 | tlen = csbi.srWindow.Right - csbi.srWindow.Left - indent; |
| 64 | 193 | } |
| 65 | 194 | } |
| 66 | 195 | #elif defined(TIOCGWINSZ) |
| 67 | - if( lineLength<0 ){ | |
| 196 | + if( width<0 ){ | |
| 68 | 197 | struct winsize w; |
| 69 | 198 | memset(&w, 0, sizeof(struct winsize)); |
| 70 | 199 | if( ioctl(0, TIOCGWINSZ, &w)!=-1 ){ |
| 71 | 200 | tlen = w.ws_col - indent; |
| 72 | 201 | } |
| 73 | 202 | } |
| 74 | 203 | #else |
| 75 | - if( lineLength<0 ){ | |
| 204 | + if( width<0 ){ | |
| 76 | 205 | /* |
| 77 | 206 | ** Fallback to using more-or-less the "legacy semantics" of hard-coding |
| 78 | 207 | ** the maximum line length to a value reasonable for the vast majority |
| 79 | 208 | ** of supported systems. |
| 80 | 209 | */ |
| @@ -130,10 +259,105 @@ | ||
| 130 | 259 | } |
| 131 | 260 | fossil_print("%s\n", zBuf); |
| 132 | 261 | lineCnt++; |
| 133 | 262 | } |
| 134 | 263 | } |
| 264 | + | |
| 265 | +/* | |
| 266 | +** This is the comment printing function. The comment printing algorithm | |
| 267 | +** contained within it attempts to preserve the formatting present within | |
| 268 | +** the comment string itself while honoring line width limitations. There | |
| 269 | +** are several flags that modify the default behavior of this function: | |
| 270 | +** | |
| 271 | +** COMMENT_PRINT_LEGACY: Forces use of the legacy comment printing | |
| 272 | +** algorithm. For backward compatibility, | |
| 273 | +** this is the default. | |
| 274 | +** | |
| 275 | +** COMMENT_PRINT_TRIM_SPACE: Trims leading and trailing spaces where | |
| 276 | +** they do not materially impact formatting | |
| 277 | +** (i.e. at the start of the comment string | |
| 278 | +** -AND- right before each line indentation). | |
| 279 | +** This flag does not apply to the legacy | |
| 280 | +** comment printing algorithm. | |
| 281 | +** | |
| 282 | +** COMMENT_PRINT_WORD_BREAK: Attempts to break lines on word boundaries | |
| 283 | +** while honoring the logical line length. | |
| 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); | |
| 312 | + } | |
| 313 | +#if defined(_WIN32) | |
| 314 | + if( width<0 ){ | |
| 315 | + CONSOLE_SCREEN_BUFFER_INFO csbi; | |
| 316 | + memset(&csbi, 0, sizeof(CONSOLE_SCREEN_BUFFER_INFO)); | |
| 317 | + if( GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi) ){ | |
| 318 | + maxChars = csbi.srWindow.Right - csbi.srWindow.Left - indent; | |
| 319 | + } | |
| 320 | + } | |
| 321 | +#elif defined(TIOCGWINSZ) | |
| 322 | + if( width<0 ){ | |
| 323 | + struct winsize w; | |
| 324 | + memset(&w, 0, sizeof(struct winsize)); | |
| 325 | + if( ioctl(0, TIOCGWINSZ, &w)!=-1 ){ | |
| 326 | + maxChars = w.ws_col - indent; | |
| 327 | + } | |
| 328 | + } | |
| 329 | +#else | |
| 330 | + if( width<0 ){ | |
| 331 | + /* | |
| 332 | + ** Fallback to using more-or-less the "legacy semantics" of hard-coding | |
| 333 | + ** the maximum line length to a value reasonable for the vast majority | |
| 334 | + ** of supported systems. | |
| 335 | + */ | |
| 336 | + maxChars = COMMENT_LEGACY_LINE_LENGTH - indent; | |
| 337 | + } | |
| 338 | +#endif | |
| 339 | + if( zText==0 ) zText = "(NULL)"; | |
| 340 | + if( maxChars<=0 ){ | |
| 341 | + maxChars = strlen(zText); | |
| 342 | + } | |
| 343 | + if( trimSpace ){ | |
| 344 | + while( fossil_isspace(zText[0]) ){ zText++; } | |
| 345 | + } | |
| 346 | + if( zText[0]==0 ){ | |
| 347 | + fossil_print("\n"); | |
| 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 | +} | |
| 135 | 359 | |
| 136 | 360 | /* |
| 137 | 361 | ** |
| 138 | 362 | ** COMMAND: test-comment-format |
| 139 | 363 | ** |
| @@ -142,20 +366,31 @@ | ||
| 142 | 366 | ** Test comment formatting and printing. Use for testing only. |
| 143 | 367 | ** |
| 144 | 368 | ** Options: |
| 145 | 369 | ** --decode Decode the text using the same method used when |
| 146 | 370 | ** handling the value of a C-card from a manifest. |
| 147 | -** --wordbreak This does nothing and is ignored. | |
| 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. | |
| 148 | 374 | */ |
| 149 | 375 | void test_comment_format(void){ |
| 150 | 376 | const char *zPrefix; |
| 151 | 377 | char *zText; |
| 152 | 378 | int indent, width; |
| 153 | 379 | int decode = find_option("decode", 0, 0)!=0; |
| 154 | - find_option("wordbreak", 0, 0); /* NOT USED */ | |
| 380 | + int flags = COMMENT_PRINT_NONE; | |
| 381 | + if( find_option("legacy", 0, 0) ){ | |
| 382 | + flags |= COMMENT_PRINT_LEGACY; | |
| 383 | + } | |
| 384 | + if( find_option("trimspace", 0, 0) ){ | |
| 385 | + flags |= COMMENT_PRINT_TRIM_SPACE; | |
| 386 | + } | |
| 387 | + if( find_option("wordbreak", 0, 0) ){ | |
| 388 | + flags |= COMMENT_PRINT_WORD_BREAK; | |
| 389 | + } | |
| 155 | 390 | if( g.argc!=4 && g.argc!=5 ){ |
| 156 | - usage("PREFIX TEXT ?WIDTH?"); | |
| 391 | + usage("?OPTIONS? PREFIX TEXT ?WIDTH?"); | |
| 157 | 392 | } |
| 158 | 393 | zPrefix = g.argv[2]; |
| 159 | 394 | if( decode ){ |
| 160 | 395 | zText = mprintf("%s", g.argv[3]); |
| 161 | 396 | defossilize(zText); |
| @@ -169,8 +404,9 @@ | ||
| 169 | 404 | width = -1; /* automatic */ |
| 170 | 405 | } |
| 171 | 406 | if( indent>0 ){ |
| 172 | 407 | fossil_print("%s", zPrefix); |
| 173 | 408 | } |
| 174 | - fossil_print("(%d lines output)\n", comment_print(zText, indent, width)); | |
| 409 | + fossil_print("(%d lines output)\n", | |
| 410 | + comment_print(zText, indent, width, flags)); | |
| 175 | 411 | if( zText!=g.argv[3] ) fossil_free(zText); |
| 176 | 412 | } |
| 177 | 413 |
| --- src/comformat.c | |
| +++ src/comformat.c | |
| @@ -28,10 +28,18 @@ | |
| 28 | # if defined(TIOCGWINSZ) |
| 29 | # include <sys/ioctl.h> |
| 30 | # endif |
| 31 | #endif |
| 32 | |
| 33 | /* |
| 34 | ** This is the previous value used by most external callers when they |
| 35 | ** needed to specify a default maximum line length to be used with the |
| 36 | ** comment_print() function. |
| 37 | */ |
| @@ -38,43 +46,164 @@ | |
| 38 | #ifndef COMMENT_LEGACY_LINE_LENGTH |
| 39 | # define COMMENT_LEGACY_LINE_LENGTH (78) |
| 40 | #endif |
| 41 | |
| 42 | /* |
| 43 | ** Given a comment string zText, format that string for printing |
| 44 | ** on a TTY. Assume that the output cursors is indent spaces from |
| 45 | ** the left margin and that a single line can contain no more than |
| 46 | ** lineLength characters. Indent all subsequent lines by indent. |
| 47 | ** |
| 48 | ** Return the number of newlines that are output. |
| 49 | */ |
| 50 | int comment_print(const char *zText, int indent, int lineLength){ |
| 51 | int tlen = lineLength - indent; |
| 52 | int si, sk, i, k; |
| 53 | int doIndent = 0; |
| 54 | char *zBuf; |
| 55 | char zBuffer[400]; |
| 56 | int lineCnt = 0; |
| 57 | |
| 58 | #if defined(_WIN32) |
| 59 | if( lineLength<0 ){ |
| 60 | CONSOLE_SCREEN_BUFFER_INFO csbi; |
| 61 | memset(&csbi, 0, sizeof(CONSOLE_SCREEN_BUFFER_INFO)); |
| 62 | if( GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi) ){ |
| 63 | tlen = csbi.srWindow.Right - csbi.srWindow.Left - indent; |
| 64 | } |
| 65 | } |
| 66 | #elif defined(TIOCGWINSZ) |
| 67 | if( lineLength<0 ){ |
| 68 | struct winsize w; |
| 69 | memset(&w, 0, sizeof(struct winsize)); |
| 70 | if( ioctl(0, TIOCGWINSZ, &w)!=-1 ){ |
| 71 | tlen = w.ws_col - indent; |
| 72 | } |
| 73 | } |
| 74 | #else |
| 75 | if( lineLength<0 ){ |
| 76 | /* |
| 77 | ** Fallback to using more-or-less the "legacy semantics" of hard-coding |
| 78 | ** the maximum line length to a value reasonable for the vast majority |
| 79 | ** of supported systems. |
| 80 | */ |
| @@ -130,10 +259,105 @@ | |
| 130 | } |
| 131 | fossil_print("%s\n", zBuf); |
| 132 | lineCnt++; |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | /* |
| 137 | ** |
| 138 | ** COMMAND: test-comment-format |
| 139 | ** |
| @@ -142,20 +366,31 @@ | |
| 142 | ** Test comment formatting and printing. Use for testing only. |
| 143 | ** |
| 144 | ** Options: |
| 145 | ** --decode Decode the text using the same method used when |
| 146 | ** handling the value of a C-card from a manifest. |
| 147 | ** --wordbreak This does nothing and is ignored. |
| 148 | */ |
| 149 | void test_comment_format(void){ |
| 150 | const char *zPrefix; |
| 151 | char *zText; |
| 152 | int indent, width; |
| 153 | int decode = find_option("decode", 0, 0)!=0; |
| 154 | find_option("wordbreak", 0, 0); /* NOT USED */ |
| 155 | if( g.argc!=4 && g.argc!=5 ){ |
| 156 | usage("PREFIX TEXT ?WIDTH?"); |
| 157 | } |
| 158 | zPrefix = g.argv[2]; |
| 159 | if( decode ){ |
| 160 | zText = mprintf("%s", g.argv[3]); |
| 161 | defossilize(zText); |
| @@ -169,8 +404,9 @@ | |
| 169 | width = -1; /* automatic */ |
| 170 | } |
| 171 | if( indent>0 ){ |
| 172 | fossil_print("%s", zPrefix); |
| 173 | } |
| 174 | fossil_print("(%d lines output)\n", comment_print(zText, indent, width)); |
| 175 | if( zText!=g.argv[3] ) fossil_free(zText); |
| 176 | } |
| 177 |
| --- src/comformat.c | |
| +++ src/comformat.c | |
| @@ -28,10 +28,18 @@ | |
| 28 | # if defined(TIOCGWINSZ) |
| 29 | # include <sys/ioctl.h> |
| 30 | # endif |
| 31 | #endif |
| 32 | |
| 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 |
| 43 | ** needed to specify a default maximum line length to be used with the |
| 44 | ** comment_print() function. |
| 45 | */ |
| @@ -38,43 +46,164 @@ | |
| 46 | #ifndef COMMENT_LEGACY_LINE_LENGTH |
| 47 | # define COMMENT_LEGACY_LINE_LENGTH (78) |
| 48 | #endif |
| 49 | |
| 50 | /* |
| 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 |
| 61 | ** algorithm, the NUL character is treated the same as a spacing character. |
| 62 | */ |
| 63 | static int comment_next_space( |
| 64 | const char *zLine, /* [in] The comment line being printed. */ |
| 65 | int index /* [in] The current character index being handled. */ |
| 66 | ){ |
| 67 | int nextIndex = index + 1; |
| 68 | for(;;){ |
| 69 | char c = zLine[nextIndex]; |
| 70 | if( c==0 || fossil_isspace(c) ){ |
| 71 | return nextIndex; |
| 72 | } |
| 73 | nextIndex++; |
| 74 | } |
| 75 | return 0; /* NOT REACHED */ |
| 76 | } |
| 77 | |
| 78 | /* |
| 79 | ** This function is called when printing a logical comment line to perform |
| 80 | ** the necessary indenting. |
| 81 | */ |
| 82 | static void comment_print_indent( |
| 83 | const char *zLine, /* [in] The comment line being printed. */ |
| 84 | int indent, /* [in] Number of spaces to indent, zero for none. */ |
| 85 | int trimSpace, /* [in] Non-zero to trim leading/trailing spaces. */ |
| 86 | int *piIndex /* [in/out] Pointer to first non-space character. */ |
| 87 | ){ |
| 88 | if( indent>0 ){ |
| 89 | fossil_print("%*s", indent, ""); |
| 90 | if( trimSpace && zLine && piIndex ){ |
| 91 | int index = *piIndex; |
| 92 | while( fossil_isspace(zLine[index]) ){ index++; } |
| 93 | *piIndex = index; |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | |
| 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); |
| 115 | maxChars = lineChars; |
| 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++; |
| 126 | }else if( c=='\t' ){ |
| 127 | int nextIndex = comment_next_space(zLine, index); |
| 128 | if( nextIndex<=0 || (nextIndex-index)>maxChars ){ |
| 129 | break; |
| 130 | } |
| 131 | charCnt++; |
| 132 | if( maxChars<COMMENT_TAB_WIDTH ){ |
| 133 | fossil_print(" "); |
| 134 | break; |
| 135 | } |
| 136 | maxChars -= COMMENT_TAB_WIDTH; |
| 137 | }else if( wordBreak && fossil_isspace(c) ){ |
| 138 | int nextIndex = comment_next_space(zLine, index); |
| 139 | if( nextIndex<=0 || (nextIndex-index)>maxChars ){ |
| 140 | break; |
| 141 | } |
| 142 | charCnt++; |
| 143 | maxChars--; |
| 144 | }else{ |
| 145 | charCnt++; |
| 146 | maxChars--; |
| 147 | } |
| 148 | fossil_print("%c", c); |
| 149 | if( maxChars==0 ) break; |
| 150 | if( c=='\n' ) break; |
| 151 | } |
| 152 | if( charCnt>0 ){ |
| 153 | fossil_print("\n"); |
| 154 | lineCnt++; |
| 155 | } |
| 156 | if( pLineCnt ){ |
| 157 | *pLineCnt += lineCnt; |
| 158 | } |
| 159 | if( pzLine ){ |
| 160 | *pzLine = zLine + index; |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | /* |
| 165 | ** This is the legacy comment printing algorithm. It is being retained |
| 166 | ** for backward compatibility. |
| 167 | ** |
| 168 | ** Given a comment string, format that string for printing on a TTY. |
| 169 | ** Assume that the output cursors is indent spaces from the left margin |
| 170 | ** and that a single line can contain no more than 'width' characters. |
| 171 | ** Indent all subsequent lines by 'indent'. |
| 172 | ** |
| 173 | ** Returns the number of new lines emitted. |
| 174 | */ |
| 175 | static int comment_print_legacy( |
| 176 | const char *zText, /* The comment text to be printed. */ |
| 177 | int indent, /* Number of spaces to indent each non-initial line. */ |
| 178 | int width /* Maximum number of characters per line. */ |
| 179 | ){ |
| 180 | int tlen = width - indent; |
| 181 | int si, sk, i, k; |
| 182 | int doIndent = 0; |
| 183 | char *zBuf; |
| 184 | char zBuffer[400]; |
| 185 | int lineCnt = 0; |
| 186 | |
| 187 | #if defined(_WIN32) |
| 188 | if( width<0 ){ |
| 189 | CONSOLE_SCREEN_BUFFER_INFO csbi; |
| 190 | memset(&csbi, 0, sizeof(CONSOLE_SCREEN_BUFFER_INFO)); |
| 191 | if( GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi) ){ |
| 192 | tlen = csbi.srWindow.Right - csbi.srWindow.Left - indent; |
| 193 | } |
| 194 | } |
| 195 | #elif defined(TIOCGWINSZ) |
| 196 | if( width<0 ){ |
| 197 | struct winsize w; |
| 198 | memset(&w, 0, sizeof(struct winsize)); |
| 199 | if( ioctl(0, TIOCGWINSZ, &w)!=-1 ){ |
| 200 | tlen = w.ws_col - indent; |
| 201 | } |
| 202 | } |
| 203 | #else |
| 204 | if( width<0 ){ |
| 205 | /* |
| 206 | ** Fallback to using more-or-less the "legacy semantics" of hard-coding |
| 207 | ** the maximum line length to a value reasonable for the vast majority |
| 208 | ** of supported systems. |
| 209 | */ |
| @@ -130,10 +259,105 @@ | |
| 259 | } |
| 260 | fossil_print("%s\n", zBuf); |
| 261 | lineCnt++; |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | /* |
| 266 | ** This is the comment printing function. The comment printing algorithm |
| 267 | ** contained within it attempts to preserve the formatting present within |
| 268 | ** the comment string itself while honoring line width limitations. There |
| 269 | ** are several flags that modify the default behavior of this function: |
| 270 | ** |
| 271 | ** COMMENT_PRINT_LEGACY: Forces use of the legacy comment printing |
| 272 | ** algorithm. For backward compatibility, |
| 273 | ** this is the default. |
| 274 | ** |
| 275 | ** COMMENT_PRINT_TRIM_SPACE: Trims leading and trailing spaces where |
| 276 | ** they do not materially impact formatting |
| 277 | ** (i.e. at the start of the comment string |
| 278 | ** -AND- right before each line indentation). |
| 279 | ** This flag does not apply to the legacy |
| 280 | ** comment printing algorithm. |
| 281 | ** |
| 282 | ** COMMENT_PRINT_WORD_BREAK: Attempts to break lines on word boundaries |
| 283 | ** while honoring the logical line length. |
| 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); |
| 312 | } |
| 313 | #if defined(_WIN32) |
| 314 | if( width<0 ){ |
| 315 | CONSOLE_SCREEN_BUFFER_INFO csbi; |
| 316 | memset(&csbi, 0, sizeof(CONSOLE_SCREEN_BUFFER_INFO)); |
| 317 | if( GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi) ){ |
| 318 | maxChars = csbi.srWindow.Right - csbi.srWindow.Left - indent; |
| 319 | } |
| 320 | } |
| 321 | #elif defined(TIOCGWINSZ) |
| 322 | if( width<0 ){ |
| 323 | struct winsize w; |
| 324 | memset(&w, 0, sizeof(struct winsize)); |
| 325 | if( ioctl(0, TIOCGWINSZ, &w)!=-1 ){ |
| 326 | maxChars = w.ws_col - indent; |
| 327 | } |
| 328 | } |
| 329 | #else |
| 330 | if( width<0 ){ |
| 331 | /* |
| 332 | ** Fallback to using more-or-less the "legacy semantics" of hard-coding |
| 333 | ** the maximum line length to a value reasonable for the vast majority |
| 334 | ** of supported systems. |
| 335 | */ |
| 336 | maxChars = COMMENT_LEGACY_LINE_LENGTH - indent; |
| 337 | } |
| 338 | #endif |
| 339 | if( zText==0 ) zText = "(NULL)"; |
| 340 | if( maxChars<=0 ){ |
| 341 | maxChars = strlen(zText); |
| 342 | } |
| 343 | if( trimSpace ){ |
| 344 | while( fossil_isspace(zText[0]) ){ zText++; } |
| 345 | } |
| 346 | if( zText[0]==0 ){ |
| 347 | fossil_print("\n"); |
| 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 | ** |
| @@ -142,20 +366,31 @@ | |
| 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 | */ |
| 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 | } |
| 384 | if( find_option("trimspace", 0, 0) ){ |
| 385 | flags |= COMMENT_PRINT_TRIM_SPACE; |
| 386 | } |
| 387 | if( find_option("wordbreak", 0, 0) ){ |
| 388 | flags |= COMMENT_PRINT_WORD_BREAK; |
| 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); |
| @@ -169,8 +404,9 @@ | |
| 404 | width = -1; /* automatic */ |
| 405 | } |
| 406 | if( indent>0 ){ |
| 407 | fossil_print("%s", zPrefix); |
| 408 | } |
| 409 | fossil_print("(%d lines output)\n", |
| 410 | comment_print(zText, indent, width, flags)); |
| 411 | if( zText!=g.argv[3] ) fossil_free(zText); |
| 412 | } |
| 413 |
+1
-1
| --- src/descendants.c | ||
| +++ src/descendants.c | ||
| @@ -407,11 +407,11 @@ | ||
| 407 | 407 | } |
| 408 | 408 | n++; |
| 409 | 409 | sqlite3_snprintf(sizeof(zLineNo), zLineNo, "(%d)", n); |
| 410 | 410 | fossil_print("%6s ", zLineNo); |
| 411 | 411 | z = mprintf("%s [%S] %s", zDate, zId, zCom); |
| 412 | - comment_print(z, 7, width); | |
| 412 | + comment_print(z, 7, width, g.comFmtFlags); | |
| 413 | 413 | fossil_free(z); |
| 414 | 414 | } |
| 415 | 415 | fossil_free(zLastBr); |
| 416 | 416 | db_finalize(&q); |
| 417 | 417 | } |
| 418 | 418 |
| --- src/descendants.c | |
| +++ src/descendants.c | |
| @@ -407,11 +407,11 @@ | |
| 407 | } |
| 408 | n++; |
| 409 | sqlite3_snprintf(sizeof(zLineNo), zLineNo, "(%d)", n); |
| 410 | fossil_print("%6s ", zLineNo); |
| 411 | z = mprintf("%s [%S] %s", zDate, zId, zCom); |
| 412 | comment_print(z, 7, width); |
| 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, 7, width, g.comFmtFlags); |
| 413 | fossil_free(z); |
| 414 | } |
| 415 | fossil_free(zLastBr); |
| 416 | db_finalize(&q); |
| 417 | } |
| 418 |
+2
-2
| --- src/finfo.c | ||
| +++ src/finfo.c | ||
| @@ -202,20 +202,20 @@ | ||
| 202 | 202 | if( iBrief ){ |
| 203 | 203 | fossil_print("%s ", zDate); |
| 204 | 204 | zOut = sqlite3_mprintf( |
| 205 | 205 | "[%S] %s (user: %s, artifact: [%S], branch: %s)", |
| 206 | 206 | zCiUuid, zCom, zUser, zFileUuid, zBr); |
| 207 | - comment_print(zOut, 11, iWidth); | |
| 207 | + comment_print(zOut, 11, iWidth, g.comFmtFlags); | |
| 208 | 208 | sqlite3_free(zOut); |
| 209 | 209 | }else{ |
| 210 | 210 | blob_reset(&line); |
| 211 | 211 | blob_appendf(&line, "%.10s ", zCiUuid); |
| 212 | 212 | blob_appendf(&line, "%.10s ", zDate); |
| 213 | 213 | blob_appendf(&line, "%8.8s ", zUser); |
| 214 | 214 | blob_appendf(&line, "%8.8s ", zBr); |
| 215 | 215 | blob_appendf(&line,"%-39.39s", zCom ); |
| 216 | - comment_print(blob_str(&line), 0, iWidth); | |
| 216 | + comment_print(blob_str(&line), 0, iWidth, g.comFmtFlags); | |
| 217 | 217 | } |
| 218 | 218 | } |
| 219 | 219 | db_finalize(&q); |
| 220 | 220 | blob_reset(&fname); |
| 221 | 221 | } |
| 222 | 222 |
| --- src/finfo.c | |
| +++ src/finfo.c | |
| @@ -202,20 +202,20 @@ | |
| 202 | if( iBrief ){ |
| 203 | fossil_print("%s ", zDate); |
| 204 | zOut = sqlite3_mprintf( |
| 205 | "[%S] %s (user: %s, artifact: [%S], branch: %s)", |
| 206 | zCiUuid, zCom, zUser, zFileUuid, zBr); |
| 207 | comment_print(zOut, 11, iWidth); |
| 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); |
| 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, 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 |
+1
-1
| --- src/info.c | ||
| +++ src/info.c | ||
| @@ -132,11 +132,11 @@ | ||
| 132 | 132 | fossil_print("tags: %s\n", zTags); |
| 133 | 133 | } |
| 134 | 134 | free(zTags); |
| 135 | 135 | if( zComment ){ |
| 136 | 136 | fossil_print("comment: "); |
| 137 | - comment_print(zComment, 14, -1); | |
| 137 | + comment_print(zComment, 14, -1, g.comFmtFlags); | |
| 138 | 138 | free(zComment); |
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | /* |
| 143 | 143 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -132,11 +132,11 @@ | |
| 132 | fossil_print("tags: %s\n", zTags); |
| 133 | } |
| 134 | free(zTags); |
| 135 | if( zComment ){ |
| 136 | fossil_print("comment: "); |
| 137 | comment_print(zComment, 14, -1); |
| 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, 14, -1, g.comFmtFlags); |
| 138 | free(zComment); |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | /* |
| 143 |
+17
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -176,10 +176,11 @@ | ||
| 176 | 176 | ** SSL client identity */ |
| 177 | 177 | int useLocalauth; /* No login required if from 127.0.0.1 */ |
| 178 | 178 | int noPswd; /* Logged in without password (on 127.0.0.1) */ |
| 179 | 179 | int userUid; /* Integer user id */ |
| 180 | 180 | int isHuman; /* True if access by a human, not a spider or bot */ |
| 181 | + int comFmtFlags; /* Zero or more "COMMENT_PRINT_*" bit flags */ | |
| 181 | 182 | |
| 182 | 183 | /* Information used to populate the RCVFROM table */ |
| 183 | 184 | int rcvid; /* The rcvid. 0 if not yet defined. */ |
| 184 | 185 | char *zIpAddr; /* The remote IP address */ |
| 185 | 186 | char *zNonce; /* The nonce used for login */ |
| @@ -534,10 +535,25 @@ | ||
| 534 | 535 | if( iCode==SQLITE_WARNING ) return; |
| 535 | 536 | #endif |
| 536 | 537 | if( iCode==SQLITE_SCHEMA ) return; |
| 537 | 538 | fossil_warning("%s: %s", sqlite_error_code_name(iCode), zErrmsg); |
| 538 | 539 | } |
| 540 | + | |
| 541 | +/* | |
| 542 | +** This function attempts to find command line options known to contain | |
| 543 | +** bitwise flags and initializes the associated global variables. After | |
| 544 | +** this function executes, all global variables (i.e. in the "g" struct) | |
| 545 | +** containing option-settable bitwise flag fields must be initialized. | |
| 546 | +*/ | |
| 547 | +static void fossil_init_flags_from_options(void){ | |
| 548 | + const char *zValue = find_option("comfmtflags", 0, 1); | |
| 549 | + if( zValue ){ | |
| 550 | + g.comFmtFlags = atoi(zValue); | |
| 551 | + }else{ | |
| 552 | + g.comFmtFlags = COMMENT_PRINT_DEFAULT; | |
| 553 | + } | |
| 554 | +} | |
| 539 | 555 | |
| 540 | 556 | /* |
| 541 | 557 | ** This procedure runs first. |
| 542 | 558 | */ |
| 543 | 559 | #if defined(_WIN32) && !defined(BROKEN_MINGW_CMDLINE) |
| @@ -633,10 +649,11 @@ | ||
| 633 | 649 | #endif |
| 634 | 650 | g.zHttpAuth = 0; |
| 635 | 651 | g.zLogin = find_option("user", "U", 1); |
| 636 | 652 | g.zSSLIdentity = find_option("ssl-identity", 0, 1); |
| 637 | 653 | g.zErrlog = find_option("errorlog", 0, 1); |
| 654 | + fossil_init_flags_from_options(); | |
| 638 | 655 | if( find_option("utc",0,0) ) g.fTimeFormat = 1; |
| 639 | 656 | if( find_option("localtime",0,0) ) g.fTimeFormat = 2; |
| 640 | 657 | if( zChdir && file_chdir(zChdir, 0) ){ |
| 641 | 658 | fossil_fatal("unable to change directories to %s", zChdir); |
| 642 | 659 | } |
| 643 | 660 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -176,10 +176,11 @@ | |
| 176 | ** SSL client identity */ |
| 177 | int useLocalauth; /* No login required if from 127.0.0.1 */ |
| 178 | int noPswd; /* Logged in without password (on 127.0.0.1) */ |
| 179 | int userUid; /* Integer user id */ |
| 180 | int isHuman; /* True if access by a human, not a spider or bot */ |
| 181 | |
| 182 | /* Information used to populate the RCVFROM table */ |
| 183 | int rcvid; /* The rcvid. 0 if not yet defined. */ |
| 184 | char *zIpAddr; /* The remote IP address */ |
| 185 | char *zNonce; /* The nonce used for login */ |
| @@ -534,10 +535,25 @@ | |
| 534 | if( iCode==SQLITE_WARNING ) return; |
| 535 | #endif |
| 536 | if( iCode==SQLITE_SCHEMA ) return; |
| 537 | fossil_warning("%s: %s", sqlite_error_code_name(iCode), zErrmsg); |
| 538 | } |
| 539 | |
| 540 | /* |
| 541 | ** This procedure runs first. |
| 542 | */ |
| 543 | #if defined(_WIN32) && !defined(BROKEN_MINGW_CMDLINE) |
| @@ -633,10 +649,11 @@ | |
| 633 | #endif |
| 634 | g.zHttpAuth = 0; |
| 635 | g.zLogin = find_option("user", "U", 1); |
| 636 | g.zSSLIdentity = find_option("ssl-identity", 0, 1); |
| 637 | g.zErrlog = find_option("errorlog", 0, 1); |
| 638 | if( find_option("utc",0,0) ) g.fTimeFormat = 1; |
| 639 | if( find_option("localtime",0,0) ) g.fTimeFormat = 2; |
| 640 | if( zChdir && file_chdir(zChdir, 0) ){ |
| 641 | fossil_fatal("unable to change directories to %s", zChdir); |
| 642 | } |
| 643 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -176,10 +176,11 @@ | |
| 176 | ** SSL client identity */ |
| 177 | int useLocalauth; /* No login required if from 127.0.0.1 */ |
| 178 | int noPswd; /* Logged in without password (on 127.0.0.1) */ |
| 179 | int userUid; /* Integer user id */ |
| 180 | int isHuman; /* True if access by a human, not a spider or bot */ |
| 181 | int comFmtFlags; /* Zero or more "COMMENT_PRINT_*" bit flags */ |
| 182 | |
| 183 | /* Information used to populate the RCVFROM table */ |
| 184 | int rcvid; /* The rcvid. 0 if not yet defined. */ |
| 185 | char *zIpAddr; /* The remote IP address */ |
| 186 | char *zNonce; /* The nonce used for login */ |
| @@ -534,10 +535,25 @@ | |
| 535 | if( iCode==SQLITE_WARNING ) return; |
| 536 | #endif |
| 537 | if( iCode==SQLITE_SCHEMA ) return; |
| 538 | fossil_warning("%s: %s", sqlite_error_code_name(iCode), zErrmsg); |
| 539 | } |
| 540 | |
| 541 | /* |
| 542 | ** This function attempts to find command line options known to contain |
| 543 | ** bitwise flags and initializes the associated global variables. After |
| 544 | ** this function executes, all global variables (i.e. in the "g" struct) |
| 545 | ** containing option-settable bitwise flag fields must be initialized. |
| 546 | */ |
| 547 | static void fossil_init_flags_from_options(void){ |
| 548 | const char *zValue = find_option("comfmtflags", 0, 1); |
| 549 | if( zValue ){ |
| 550 | g.comFmtFlags = atoi(zValue); |
| 551 | }else{ |
| 552 | g.comFmtFlags = COMMENT_PRINT_DEFAULT; |
| 553 | } |
| 554 | } |
| 555 | |
| 556 | /* |
| 557 | ** This procedure runs first. |
| 558 | */ |
| 559 | #if defined(_WIN32) && !defined(BROKEN_MINGW_CMDLINE) |
| @@ -633,10 +649,11 @@ | |
| 649 | #endif |
| 650 | g.zHttpAuth = 0; |
| 651 | g.zLogin = find_option("user", "U", 1); |
| 652 | g.zSSLIdentity = find_option("ssl-identity", 0, 1); |
| 653 | g.zErrlog = find_option("errorlog", 0, 1); |
| 654 | fossil_init_flags_from_options(); |
| 655 | if( find_option("utc",0,0) ) g.fTimeFormat = 1; |
| 656 | if( find_option("localtime",0,0) ) g.fTimeFormat = 2; |
| 657 | if( zChdir && file_chdir(zChdir, 0) ){ |
| 658 | fossil_fatal("unable to change directories to %s", zChdir); |
| 659 | } |
| 660 |
+2
-2
| --- src/merge.c | ||
| +++ src/merge.c | ||
| @@ -47,11 +47,11 @@ | ||
| 47 | 47 | indent-1, zLabel, |
| 48 | 48 | db_column_text(&q, 3), |
| 49 | 49 | db_column_text(&q, 1), |
| 50 | 50 | db_column_text(&q, 0), |
| 51 | 51 | indent, ""); |
| 52 | - comment_print(zCom, indent, -1); | |
| 52 | + comment_print(zCom, indent, -1, g.comFmtFlags); | |
| 53 | 53 | fossil_free(zCom); |
| 54 | 54 | } |
| 55 | 55 | db_finalize(&q); |
| 56 | 56 | } |
| 57 | 57 | |
| @@ -210,11 +210,11 @@ | ||
| 210 | 210 | ); |
| 211 | 211 | if( db_step(&q)==SQLITE_ROW ){ |
| 212 | 212 | char *zCom = mprintf("Merging fork [%S] at %s by %s: \"%s\"", |
| 213 | 213 | db_column_text(&q, 0), db_column_text(&q, 1), |
| 214 | 214 | db_column_text(&q, 3), db_column_text(&q, 2)); |
| 215 | - comment_print(zCom, 0, -1); | |
| 215 | + comment_print(zCom, 0, -1, g.comFmtFlags); | |
| 216 | 216 | fossil_free(zCom); |
| 217 | 217 | } |
| 218 | 218 | db_finalize(&q); |
| 219 | 219 | }else{ |
| 220 | 220 | usage("?OPTIONS? ?VERSION?"); |
| 221 | 221 |
| --- src/merge.c | |
| +++ src/merge.c | |
| @@ -47,11 +47,11 @@ | |
| 47 | indent-1, zLabel, |
| 48 | db_column_text(&q, 3), |
| 49 | db_column_text(&q, 1), |
| 50 | db_column_text(&q, 0), |
| 51 | indent, ""); |
| 52 | comment_print(zCom, indent, -1); |
| 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); |
| 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, 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 |
+3
-3
| --- src/name.c | ||
| +++ src/name.c | ||
| @@ -582,11 +582,11 @@ | ||
| 582 | 582 | default: zType = "Unknown"; break; |
| 583 | 583 | } |
| 584 | 584 | fossil_print("type: %s by %s on %s\n", zType, db_column_text(&q,2), |
| 585 | 585 | db_column_text(&q, 1)); |
| 586 | 586 | fossil_print("comment: "); |
| 587 | - comment_print(db_column_text(&q,3), 12, -1); | |
| 587 | + comment_print(db_column_text(&q,3), 12, -1, g.comFmtFlags); | |
| 588 | 588 | } |
| 589 | 589 | db_finalize(&q); |
| 590 | 590 | |
| 591 | 591 | /* Check to see if this object is used as a file in a check-in */ |
| 592 | 592 | db_prepare(&q, |
| @@ -604,11 +604,11 @@ | ||
| 604 | 604 | fossil_print(" part of [%S] by %s on %s\n", |
| 605 | 605 | db_column_text(&q, 1), |
| 606 | 606 | db_column_text(&q, 3), |
| 607 | 607 | db_column_text(&q, 2)); |
| 608 | 608 | fossil_print(" "); |
| 609 | - comment_print(db_column_text(&q,4), 12, -1); | |
| 609 | + comment_print(db_column_text(&q,4), 12, -1, g.comFmtFlags); | |
| 610 | 610 | } |
| 611 | 611 | db_finalize(&q); |
| 612 | 612 | |
| 613 | 613 | /* Check to see if this object is used as an attachment */ |
| 614 | 614 | db_prepare(&q, |
| @@ -639,11 +639,11 @@ | ||
| 639 | 639 | db_column_text(&q,7)); |
| 640 | 640 | } |
| 641 | 641 | fossil_print(" by user %s on %s\n", |
| 642 | 642 | db_column_text(&q,2), db_column_text(&q,3)); |
| 643 | 643 | fossil_print(" "); |
| 644 | - comment_print(db_column_text(&q,1), 12, -1); | |
| 644 | + comment_print(db_column_text(&q,1), 12, -1, g.comFmtFlags); | |
| 645 | 645 | } |
| 646 | 646 | db_finalize(&q); |
| 647 | 647 | } |
| 648 | 648 | |
| 649 | 649 | /* |
| 650 | 650 |
| --- src/name.c | |
| +++ src/name.c | |
| @@ -582,11 +582,11 @@ | |
| 582 | default: zType = "Unknown"; break; |
| 583 | } |
| 584 | fossil_print("type: %s by %s on %s\n", zType, db_column_text(&q,2), |
| 585 | db_column_text(&q, 1)); |
| 586 | fossil_print("comment: "); |
| 587 | comment_print(db_column_text(&q,3), 12, -1); |
| 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); |
| 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); |
| 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), 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 |
+6
-2
| --- src/printf.c | ||
| +++ src/printf.c | ||
| @@ -866,12 +866,16 @@ | ||
| 866 | 866 | |
| 867 | 867 | /* |
| 868 | 868 | ** Force the standard output cursor to move to the beginning |
| 869 | 869 | ** of a line, if it is not there already. |
| 870 | 870 | */ |
| 871 | -void fossil_force_newline(void){ | |
| 872 | - if( g.cgiOutput==0 && stdoutAtBOL==0 ) fossil_puts("\n", 0); | |
| 871 | +int fossil_force_newline(void){ | |
| 872 | + if( g.cgiOutput==0 && stdoutAtBOL==0 ){ | |
| 873 | + fossil_puts("\n", 0); | |
| 874 | + return 1; | |
| 875 | + } | |
| 876 | + return 0; | |
| 873 | 877 | } |
| 874 | 878 | |
| 875 | 879 | /* |
| 876 | 880 | ** Indicate that the cursor has moved to the start of a line by means |
| 877 | 881 | ** other than writing to standard output. |
| 878 | 882 |
| --- src/printf.c | |
| +++ src/printf.c | |
| @@ -866,12 +866,16 @@ | |
| 866 | |
| 867 | /* |
| 868 | ** Force the standard output cursor to move to the beginning |
| 869 | ** of a line, if it is not there already. |
| 870 | */ |
| 871 | void fossil_force_newline(void){ |
| 872 | if( g.cgiOutput==0 && stdoutAtBOL==0 ) fossil_puts("\n", 0); |
| 873 | } |
| 874 | |
| 875 | /* |
| 876 | ** Indicate that the cursor has moved to the start of a line by means |
| 877 | ** other than writing to standard output. |
| 878 |
| --- src/printf.c | |
| +++ src/printf.c | |
| @@ -866,12 +866,16 @@ | |
| 866 | |
| 867 | /* |
| 868 | ** Force the standard output cursor to move to the beginning |
| 869 | ** of a line, if it is not there already. |
| 870 | */ |
| 871 | int fossil_force_newline(void){ |
| 872 | if( g.cgiOutput==0 && stdoutAtBOL==0 ){ |
| 873 | fossil_puts("\n", 0); |
| 874 | return 1; |
| 875 | } |
| 876 | return 0; |
| 877 | } |
| 878 | |
| 879 | /* |
| 880 | ** Indicate that the cursor has moved to the start of a line by means |
| 881 | ** other than writing to standard output. |
| 882 |
+1
-1
| --- src/stash.c | ||
| +++ src/stash.c | ||
| @@ -552,11 +552,11 @@ | ||
| 552 | 552 | db_column_text(&q, 3) |
| 553 | 553 | ); |
| 554 | 554 | zCom = db_column_text(&q, 2); |
| 555 | 555 | if( zCom && zCom[0] ){ |
| 556 | 556 | fossil_print(" "); |
| 557 | - comment_print(zCom, 7, width); | |
| 557 | + comment_print(zCom, 7, width, g.comFmtFlags); | |
| 558 | 558 | } |
| 559 | 559 | if( verboseFlag ){ |
| 560 | 560 | db_bind_int(&q2, "$id", stashid); |
| 561 | 561 | while( db_step(&q2)==SQLITE_ROW ){ |
| 562 | 562 | int isAdded = db_column_int(&q2, 0); |
| 563 | 563 |
| --- src/stash.c | |
| +++ src/stash.c | |
| @@ -552,11 +552,11 @@ | |
| 552 | db_column_text(&q, 3) |
| 553 | ); |
| 554 | zCom = db_column_text(&q, 2); |
| 555 | if( zCom && zCom[0] ){ |
| 556 | fossil_print(" "); |
| 557 | comment_print(zCom, 7, width); |
| 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, 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 |
+2
-1
| --- src/timeline.c | ||
| +++ src/timeline.c | ||
| @@ -1602,11 +1602,12 @@ | ||
| 1602 | 1602 | if( fossil_strcmp(zCurrentUuid,zId)==0 ){ |
| 1603 | 1603 | sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*CURRENT* "); |
| 1604 | 1604 | n += strlen(zPrefix); |
| 1605 | 1605 | } |
| 1606 | 1606 | zFree = mprintf("[%S] %s%s", zId, zPrefix, zCom); |
| 1607 | - nLine += comment_print(zFree, 9, width); /* record another X lines */ | |
| 1607 | + /* record another X lines */ | |
| 1608 | + nLine += comment_print(zFree, 9, width, g.comFmtFlags); | |
| 1608 | 1609 | fossil_free(zFree); |
| 1609 | 1610 | |
| 1610 | 1611 | if(verboseFlag){ |
| 1611 | 1612 | if( !fchngQueryInit ){ |
| 1612 | 1613 | db_prepare(&fchngQuery, |
| 1613 | 1614 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -1602,11 +1602,12 @@ | |
| 1602 | if( fossil_strcmp(zCurrentUuid,zId)==0 ){ |
| 1603 | sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*CURRENT* "); |
| 1604 | n += strlen(zPrefix); |
| 1605 | } |
| 1606 | zFree = mprintf("[%S] %s%s", zId, zPrefix, zCom); |
| 1607 | nLine += comment_print(zFree, 9, width); /* record another X lines */ |
| 1608 | fossil_free(zFree); |
| 1609 | |
| 1610 | if(verboseFlag){ |
| 1611 | if( !fchngQueryInit ){ |
| 1612 | db_prepare(&fchngQuery, |
| 1613 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -1602,11 +1602,12 @@ | |
| 1602 | if( fossil_strcmp(zCurrentUuid,zId)==0 ){ |
| 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 |
+1
-1
| --- src/tkt.c | ||
| +++ src/tkt.c | ||
| @@ -1264,11 +1264,11 @@ | ||
| 1264 | 1264 | fossil_print(" Change "); |
| 1265 | 1265 | } |
| 1266 | 1266 | fossil_print("%h: ",z); |
| 1267 | 1267 | if( blob_size(&val)>50 || contains_newline(&val)) { |
| 1268 | 1268 | fossil_print("\n ",blob_str(&val)); |
| 1269 | - comment_print(blob_str(&val),4,-1); | |
| 1269 | + comment_print(blob_str(&val),4,-1,g.comFmtFlags); | |
| 1270 | 1270 | }else{ |
| 1271 | 1271 | fossil_print("%s\n",blob_str(&val)); |
| 1272 | 1272 | } |
| 1273 | 1273 | blob_reset(&val); |
| 1274 | 1274 | } |
| 1275 | 1275 |
| --- src/tkt.c | |
| +++ src/tkt.c | |
| @@ -1264,11 +1264,11 @@ | |
| 1264 | fossil_print(" Change "); |
| 1265 | } |
| 1266 | fossil_print("%h: ",z); |
| 1267 | if( blob_size(&val)>50 || contains_newline(&val)) { |
| 1268 | fossil_print("\n ",blob_str(&val)); |
| 1269 | comment_print(blob_str(&val),4,-1); |
| 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),4,-1,g.comFmtFlags); |
| 1270 | }else{ |
| 1271 | fossil_print("%s\n",blob_str(&val)); |
| 1272 | } |
| 1273 | blob_reset(&val); |
| 1274 | } |
| 1275 |
+120
-15
| --- test/comment.test | ||
| +++ test/comment.test | ||
| @@ -36,17 +36,17 @@ | ||
| 36 | 36 | fossil test-comment-format --decode " " "this is a short comment." 26 |
| 37 | 37 | test comment-4 {$RESULT eq " this is a short comment.\n(1 lines output)"} |
| 38 | 38 | |
| 39 | 39 | ############################################################################### |
| 40 | 40 | |
| 41 | -fossil test-comment-format "*PREFIX* " "this is a short comment." 25 | |
| 42 | -test comment-5 {$RESULT eq "*PREFIX* this is a short\n comment.\n(2 lines output)"} | |
| 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 | 43 | |
| 44 | 44 | ############################################################################### |
| 45 | 45 | |
| 46 | -fossil test-comment-format --decode "*PREFIX* " "this is a short comment." 25 | |
| 47 | -test comment-6 {$RESULT eq "*PREFIX* this is a short\n comment.\n(2 lines output)"} | |
| 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 | 48 | |
| 49 | 49 | ############################################################################### |
| 50 | 50 | |
| 51 | 51 | fossil test-comment-format "" "this\\sis\\sa\\sshort\\scomment." 26 |
| 52 | 52 | test comment-7 {$RESULT eq "this\\sis\\sa\\sshort\\scommen\nt.\n(2 lines output)"} |
| @@ -56,17 +56,17 @@ | ||
| 56 | 56 | fossil test-comment-format --decode "" "this\\sis\\sa\\sshort\\scomment." 26 |
| 57 | 57 | test comment-8 {$RESULT eq "this is a short comment.\n(1 lines output)"} |
| 58 | 58 | |
| 59 | 59 | ############################################################################### |
| 60 | 60 | |
| 61 | -fossil test-comment-format --decode "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\n is working correctly.\n(2 lines output)"} | |
| 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 | 63 | |
| 64 | 64 | ############################################################################### |
| 65 | 65 | |
| 66 | -fossil test-comment-format --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 | |
| 67 | -test comment-10 {$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)"} | |
| 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 | 68 | |
| 69 | 69 | ############################################################################### |
| 70 | 70 | |
| 71 | 71 | fossil test-comment-format "HH:MM:SS " "....................................................................................*" 78 |
| 72 | 72 | test comment-11 {$RESULT eq "HH:MM:SS .....................................................................\n ...............*\n(2 lines output)"} |
| @@ -77,46 +77,151 @@ | ||
| 77 | 77 | test comment-12 {$RESULT eq "HH:MM:SS .....................................................................\n *\n(2 lines output)"} |
| 78 | 78 | |
| 79 | 79 | ############################################################################### |
| 80 | 80 | |
| 81 | 81 | fossil test-comment-format "*TEST* " "this\tis a test." 26 |
| 82 | -test comment-13 {$RESULT eq "*TEST* this is a test.\n(1 lines output)"} | |
| 82 | +test comment-13 {$RESULT eq "*TEST* this\tis a te\n st.\n(2 lines output)"} | |
| 83 | 83 | |
| 84 | 84 | ############################################################################### |
| 85 | 85 | |
| 86 | 86 | fossil test-comment-format "*TEST* " "this is a test......................................................................................................................." 60 |
| 87 | -test comment-14 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"} | |
| 87 | +test comment-14 {$RESULT eq "*TEST* this is a test.......................................\n .....................................................\n ...........................\n(3 lines output)"} | |
| 88 | 88 | |
| 89 | 89 | ############################################################################### |
| 90 | 90 | |
| 91 | 91 | fossil test-comment-format --wordbreak "*TEST* " "this is a test......................................................................................................................." 60 |
| 92 | 92 | test comment-15 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"} |
| 93 | 93 | |
| 94 | 94 | ############################################################################### |
| 95 | 95 | |
| 96 | 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)"} | |
| 97 | +test comment-16 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"} | |
| 98 | 98 | |
| 99 | 99 | ############################################################################### |
| 100 | 100 | |
| 101 | 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)"} | |
| 102 | +test comment-17 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"} | |
| 103 | 103 | |
| 104 | 104 | ############################################################################### |
| 105 | 105 | |
| 106 | 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\n eleven twelve\n(2 lines output)"} | |
| 107 | +test comment-18 {$RESULT eq "*TEST* one two three four five six seven eight nine ten elev\n en twelve\n(2 lines output)"} | |
| 108 | 108 | |
| 109 | 109 | ############################################################################### |
| 110 | 110 | |
| 111 | 111 | fossil test-comment-format --wordbreak "*TEST* " "one two three four five six seven eight nine ten eleven twelve" 60 |
| 112 | 112 | test comment-19 {$RESULT eq "*TEST* one two three four five six seven eight nine ten\n eleven twelve\n(2 lines output)"} |
| 113 | 113 | |
| 114 | 114 | ############################################################################### |
| 115 | 115 | |
| 116 | 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 six seven eight nine ten\n eleven twelve\n(2 lines output)"} | |
| 117 | +test comment-20 {$RESULT eq "*TEST* one two three four five\n six seven eight nine ten\n eleven twelve\n(3 lines output)"} | |
| 118 | 118 | |
| 119 | 119 | ############################################################################### |
| 120 | 120 | |
| 121 | 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 six seven eight nine ten\n eleven twelve\n(2 lines output)"} | |
| 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 "" "" | |
| 127 | +test comment-22 {$RESULT eq "\n(1 lines output)"} | |
| 128 | + | |
| 129 | +############################################################################### | |
| 130 | + | |
| 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)"} | |
| 123 | 228 |
| --- test/comment.test | |
| +++ test/comment.test | |
| @@ -36,17 +36,17 @@ | |
| 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." 25 |
| 42 | test comment-5 {$RESULT eq "*PREFIX* this is a short\n comment.\n(2 lines output)"} |
| 43 | |
| 44 | ############################################################################### |
| 45 | |
| 46 | fossil test-comment-format --decode "*PREFIX* " "this is a short comment." 25 |
| 47 | test comment-6 {$RESULT eq "*PREFIX* this is a short\n comment.\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)"} |
| @@ -56,17 +56,17 @@ | |
| 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 "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\n is working correctly.\n(2 lines output)"} |
| 63 | |
| 64 | ############################################################################### |
| 65 | |
| 66 | fossil test-comment-format --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 |
| 67 | test comment-10 {$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)"} |
| 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)"} |
| @@ -77,46 +77,151 @@ | |
| 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 is a test.\n(1 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\n test.................................................\n .....................................................\n .................\n(4 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\n eleven 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 six seven eight nine ten\n eleven twelve\n(2 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 six seven eight nine ten\n eleven twelve\n(2 lines output)"} |
| 123 |
| --- test/comment.test | |
| +++ test/comment.test | |
| @@ -36,17 +36,17 @@ | |
| 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)"} |
| @@ -56,17 +56,17 @@ | |
| 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)"} |
| @@ -77,46 +77,151 @@ | |
| 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 "" "" |
| 127 | test comment-22 {$RESULT eq "\n(1 lines output)"} |
| 128 | |
| 129 | ############################################################################### |
| 130 | |
| 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 |