Fossil SCM
Enhanced comments in the diff.c source code file. No code changes.
Commit
a39a992b4e02a92ff85a1173bfa0ff1d32d47383
Parent
0c6e645175072d2…
1 file changed
+8
-4
+8
-4
| --- src/diff.c | ||
| +++ src/diff.c | ||
| @@ -23,11 +23,12 @@ | ||
| 23 | 23 | #include <assert.h> |
| 24 | 24 | |
| 25 | 25 | |
| 26 | 26 | #if INTERFACE |
| 27 | 27 | /* |
| 28 | -** Allowed flag parameters to the text_diff() and html_sbsdiff() functions: | |
| 28 | +** Flag parameters to the text_diff() routine used to control the formatting | |
| 29 | +** of the diff output. | |
| 29 | 30 | */ |
| 30 | 31 | #define DIFF_CONTEXT_MASK ((u64)0x0000ffff) /* Lines of context. Default if 0 */ |
| 31 | 32 | #define DIFF_WIDTH_MASK ((u64)0x00ff0000) /* side-by-side column width */ |
| 32 | 33 | #define DIFF_IGNORE_EOLWS ((u64)0x01000000) /* Ignore end-of-line whitespace */ |
| 33 | 34 | #define DIFF_SIDEBYSIDE ((u64)0x02000000) /* Generate a side-by-side diff */ |
| @@ -52,11 +53,11 @@ | ||
| 52 | 53 | |
| 53 | 54 | #define looks_like_binary(blob) (looks_like_utf8((blob)) == 0) |
| 54 | 55 | #endif /* INTERFACE */ |
| 55 | 56 | |
| 56 | 57 | /* |
| 57 | -** Maximum length of a line in a text file, in bytes. (8192) | |
| 58 | +** Maximum length of a line in a text file, in bytes. (2**13 = 8192 bytes) | |
| 58 | 59 | */ |
| 59 | 60 | #define LENGTH_MASK_SZ 13 |
| 60 | 61 | #define LENGTH_MASK ((1<<LENGTH_MASK_SZ)-1) |
| 61 | 62 | |
| 62 | 63 | /* |
| @@ -116,10 +117,13 @@ | ||
| 116 | 117 | ** more. If trailing whitespace is ignored, the "patch" command gets |
| 117 | 118 | ** confused by the diff output. Ticket [a9f7b23c2e376af5b0e5b] |
| 118 | 119 | ** |
| 119 | 120 | ** Return 0 if the file is binary or contains a line that is |
| 120 | 121 | ** too long. |
| 122 | +** | |
| 123 | +** Profiling show that in most cases this routine consumes the bulk of | |
| 124 | +** the CPU time on a diff. | |
| 121 | 125 | */ |
| 122 | 126 | static DLine *break_into_lines(const char *z, int n, int *pnLine, int ignoreWS){ |
| 123 | 127 | int nLine, i, j, k, x; |
| 124 | 128 | unsigned int h, h2; |
| 125 | 129 | DLine *a; |
| @@ -439,11 +443,11 @@ | ||
| 439 | 443 | blob_append(pOut, "\n", 1); |
| 440 | 444 | } |
| 441 | 445 | |
| 442 | 446 | /* |
| 443 | 447 | ** Add two line numbers to the beginning of an output line for a context |
| 444 | -** diff. One or of the other of the two numbers might be zero, which means | |
| 448 | +** diff. One or the other of the two numbers might be zero, which means | |
| 445 | 449 | ** to leave that number field blank. The "html" parameter means to format |
| 446 | 450 | ** the output for HTML. |
| 447 | 451 | */ |
| 448 | 452 | static void appendDiffLineno(Blob *pOut, int lnA, int lnB, int html){ |
| 449 | 453 | if( html ) blob_append(pOut, "<span class=\"diffln\">", -1); |
| @@ -521,11 +525,11 @@ | ||
| 521 | 525 | na += R[r+i*3]; |
| 522 | 526 | nb += R[r+i*3]; |
| 523 | 527 | } |
| 524 | 528 | |
| 525 | 529 | /* Show the header for this block, or if we are doing a modified |
| 526 | - ** context diff that contains line numbers, show the separate from | |
| 530 | + ** context diff that contains line numbers, show the separator from | |
| 527 | 531 | ** the previous block. |
| 528 | 532 | */ |
| 529 | 533 | nChunk++; |
| 530 | 534 | if( showLn ){ |
| 531 | 535 | if( r==0 ){ |
| 532 | 536 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -23,11 +23,12 @@ | |
| 23 | #include <assert.h> |
| 24 | |
| 25 | |
| 26 | #if INTERFACE |
| 27 | /* |
| 28 | ** Allowed flag parameters to the text_diff() and html_sbsdiff() functions: |
| 29 | */ |
| 30 | #define DIFF_CONTEXT_MASK ((u64)0x0000ffff) /* Lines of context. Default if 0 */ |
| 31 | #define DIFF_WIDTH_MASK ((u64)0x00ff0000) /* side-by-side column width */ |
| 32 | #define DIFF_IGNORE_EOLWS ((u64)0x01000000) /* Ignore end-of-line whitespace */ |
| 33 | #define DIFF_SIDEBYSIDE ((u64)0x02000000) /* Generate a side-by-side diff */ |
| @@ -52,11 +53,11 @@ | |
| 52 | |
| 53 | #define looks_like_binary(blob) (looks_like_utf8((blob)) == 0) |
| 54 | #endif /* INTERFACE */ |
| 55 | |
| 56 | /* |
| 57 | ** Maximum length of a line in a text file, in bytes. (8192) |
| 58 | */ |
| 59 | #define LENGTH_MASK_SZ 13 |
| 60 | #define LENGTH_MASK ((1<<LENGTH_MASK_SZ)-1) |
| 61 | |
| 62 | /* |
| @@ -116,10 +117,13 @@ | |
| 116 | ** more. If trailing whitespace is ignored, the "patch" command gets |
| 117 | ** confused by the diff output. Ticket [a9f7b23c2e376af5b0e5b] |
| 118 | ** |
| 119 | ** Return 0 if the file is binary or contains a line that is |
| 120 | ** too long. |
| 121 | */ |
| 122 | static DLine *break_into_lines(const char *z, int n, int *pnLine, int ignoreWS){ |
| 123 | int nLine, i, j, k, x; |
| 124 | unsigned int h, h2; |
| 125 | DLine *a; |
| @@ -439,11 +443,11 @@ | |
| 439 | blob_append(pOut, "\n", 1); |
| 440 | } |
| 441 | |
| 442 | /* |
| 443 | ** Add two line numbers to the beginning of an output line for a context |
| 444 | ** diff. One or of the other of the two numbers might be zero, which means |
| 445 | ** to leave that number field blank. The "html" parameter means to format |
| 446 | ** the output for HTML. |
| 447 | */ |
| 448 | static void appendDiffLineno(Blob *pOut, int lnA, int lnB, int html){ |
| 449 | if( html ) blob_append(pOut, "<span class=\"diffln\">", -1); |
| @@ -521,11 +525,11 @@ | |
| 521 | na += R[r+i*3]; |
| 522 | nb += R[r+i*3]; |
| 523 | } |
| 524 | |
| 525 | /* Show the header for this block, or if we are doing a modified |
| 526 | ** context diff that contains line numbers, show the separate from |
| 527 | ** the previous block. |
| 528 | */ |
| 529 | nChunk++; |
| 530 | if( showLn ){ |
| 531 | if( r==0 ){ |
| 532 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -23,11 +23,12 @@ | |
| 23 | #include <assert.h> |
| 24 | |
| 25 | |
| 26 | #if INTERFACE |
| 27 | /* |
| 28 | ** Flag parameters to the text_diff() routine used to control the formatting |
| 29 | ** of the diff output. |
| 30 | */ |
| 31 | #define DIFF_CONTEXT_MASK ((u64)0x0000ffff) /* Lines of context. Default if 0 */ |
| 32 | #define DIFF_WIDTH_MASK ((u64)0x00ff0000) /* side-by-side column width */ |
| 33 | #define DIFF_IGNORE_EOLWS ((u64)0x01000000) /* Ignore end-of-line whitespace */ |
| 34 | #define DIFF_SIDEBYSIDE ((u64)0x02000000) /* Generate a side-by-side diff */ |
| @@ -52,11 +53,11 @@ | |
| 53 | |
| 54 | #define looks_like_binary(blob) (looks_like_utf8((blob)) == 0) |
| 55 | #endif /* INTERFACE */ |
| 56 | |
| 57 | /* |
| 58 | ** Maximum length of a line in a text file, in bytes. (2**13 = 8192 bytes) |
| 59 | */ |
| 60 | #define LENGTH_MASK_SZ 13 |
| 61 | #define LENGTH_MASK ((1<<LENGTH_MASK_SZ)-1) |
| 62 | |
| 63 | /* |
| @@ -116,10 +117,13 @@ | |
| 117 | ** more. If trailing whitespace is ignored, the "patch" command gets |
| 118 | ** confused by the diff output. Ticket [a9f7b23c2e376af5b0e5b] |
| 119 | ** |
| 120 | ** Return 0 if the file is binary or contains a line that is |
| 121 | ** too long. |
| 122 | ** |
| 123 | ** Profiling show that in most cases this routine consumes the bulk of |
| 124 | ** the CPU time on a diff. |
| 125 | */ |
| 126 | static DLine *break_into_lines(const char *z, int n, int *pnLine, int ignoreWS){ |
| 127 | int nLine, i, j, k, x; |
| 128 | unsigned int h, h2; |
| 129 | DLine *a; |
| @@ -439,11 +443,11 @@ | |
| 443 | blob_append(pOut, "\n", 1); |
| 444 | } |
| 445 | |
| 446 | /* |
| 447 | ** Add two line numbers to the beginning of an output line for a context |
| 448 | ** diff. One or the other of the two numbers might be zero, which means |
| 449 | ** to leave that number field blank. The "html" parameter means to format |
| 450 | ** the output for HTML. |
| 451 | */ |
| 452 | static void appendDiffLineno(Blob *pOut, int lnA, int lnB, int html){ |
| 453 | if( html ) blob_append(pOut, "<span class=\"diffln\">", -1); |
| @@ -521,11 +525,11 @@ | |
| 525 | na += R[r+i*3]; |
| 526 | nb += R[r+i*3]; |
| 527 | } |
| 528 | |
| 529 | /* Show the header for this block, or if we are doing a modified |
| 530 | ** context diff that contains line numbers, show the separator from |
| 531 | ** the previous block. |
| 532 | */ |
| 533 | nChunk++; |
| 534 | if( showLn ){ |
| 535 | if( r==0 ){ |
| 536 |