Fossil SCM

Enhanced comments in the diff.c source code file. No code changes.

drh 2012-12-17 14:00 trunk
Commit a39a992b4e02a92ff85a1173bfa0ff1d32d47383
1 file changed +8 -4
+8 -4
--- src/diff.c
+++ src/diff.c
@@ -23,11 +23,12 @@
2323
#include <assert.h>
2424
2525
2626
#if INTERFACE
2727
/*
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.
2930
*/
3031
#define DIFF_CONTEXT_MASK ((u64)0x0000ffff) /* Lines of context. Default if 0 */
3132
#define DIFF_WIDTH_MASK ((u64)0x00ff0000) /* side-by-side column width */
3233
#define DIFF_IGNORE_EOLWS ((u64)0x01000000) /* Ignore end-of-line whitespace */
3334
#define DIFF_SIDEBYSIDE ((u64)0x02000000) /* Generate a side-by-side diff */
@@ -52,11 +53,11 @@
5253
5354
#define looks_like_binary(blob) (looks_like_utf8((blob)) == 0)
5455
#endif /* INTERFACE */
5556
5657
/*
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)
5859
*/
5960
#define LENGTH_MASK_SZ 13
6061
#define LENGTH_MASK ((1<<LENGTH_MASK_SZ)-1)
6162
6263
/*
@@ -116,10 +117,13 @@
116117
** more. If trailing whitespace is ignored, the "patch" command gets
117118
** confused by the diff output. Ticket [a9f7b23c2e376af5b0e5b]
118119
**
119120
** Return 0 if the file is binary or contains a line that is
120121
** too long.
122
+**
123
+** Profiling show that in most cases this routine consumes the bulk of
124
+** the CPU time on a diff.
121125
*/
122126
static DLine *break_into_lines(const char *z, int n, int *pnLine, int ignoreWS){
123127
int nLine, i, j, k, x;
124128
unsigned int h, h2;
125129
DLine *a;
@@ -439,11 +443,11 @@
439443
blob_append(pOut, "\n", 1);
440444
}
441445
442446
/*
443447
** 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
445449
** to leave that number field blank. The "html" parameter means to format
446450
** the output for HTML.
447451
*/
448452
static void appendDiffLineno(Blob *pOut, int lnA, int lnB, int html){
449453
if( html ) blob_append(pOut, "<span class=\"diffln\">", -1);
@@ -521,11 +525,11 @@
521525
na += R[r+i*3];
522526
nb += R[r+i*3];
523527
}
524528
525529
/* 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
527531
** the previous block.
528532
*/
529533
nChunk++;
530534
if( showLn ){
531535
if( r==0 ){
532536
--- 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

Keyboard Shortcuts

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