Fossil SCM

Rename --ignore-eolws back to --ignore-space-at-eol. Change last parameter of break_into_lines() to hold multiple flags. This opens the way to implement --ignore-all-space" and "--ignore-space-at-sol" as well.

jan.nijtmans 2014-03-03 10:15 diff-eolws
Commit 2dffb0e0262ace15f9a6d70ee80f10abc545d8f3
2 files changed +8 -7 +1 -1
+8 -7
--- src/diff.c
+++ src/diff.c
@@ -128,14 +128,15 @@
128128
** too long.
129129
**
130130
** Profiling show that in most cases this routine consumes the bulk of
131131
** the CPU time on a diff.
132132
*/
133
-static DLine *break_into_lines(const char *z, int n, int *pnLine, int ignoreWS){
133
+static DLine *break_into_lines(const char *z, int n, int *pnLine, int diffFlags){
134134
int nLine, i, j, k, x;
135135
unsigned int h, h2;
136136
DLine *a;
137
+ int ignoreWS = diffFlags & DIFF_IGNORE_EOLWS;
137138
138139
/* Count the number of lines. Allocate space to hold
139140
** the returned array.
140141
*/
141142
for(i=j=0, nLine=1; i<n; i++, j++){
@@ -1771,13 +1772,13 @@
17711772
blob_to_utf8_no_bom(pB_Blob, 0);
17721773
17731774
/* Prepare the input files */
17741775
memset(&c, 0, sizeof(c));
17751776
c.aFrom = break_into_lines(blob_str(pA_Blob), blob_size(pA_Blob),
1776
- &c.nFrom, ignoreEolWs);
1777
+ &c.nFrom, diffFlags);
17771778
c.aTo = break_into_lines(blob_str(pB_Blob), blob_size(pB_Blob),
1778
- &c.nTo, ignoreEolWs);
1779
+ &c.nTo, diffFlags);
17791780
if( c.aFrom==0 || c.aTo==0 ){
17801781
fossil_free(c.aFrom);
17811782
fossil_free(c.aTo);
17821783
if( pOut ){
17831784
diff_errmsg(pOut, DIFF_CANNOT_COMPUTE_BINARY, diffFlags);
@@ -1838,11 +1839,11 @@
18381839
**
18391840
** --brief Show filenames only DIFF_BRIEF
18401841
** --context|-c N N lines of context. DIFF_CONTEXT_MASK
18411842
** --html Format for HTML DIFF_HTML
18421843
** --invert Invert the diff DIFF_INVERT
1843
-** --ignore-eolws|-w Ignore eol-whitespaces DIFF_IGNORE_EOLWS
1844
+** --ignore-space-at-eol Ignore eol-whitespaces DIFF_IGNORE_EOLWS
18441845
** --linenum|-n Show line numbers DIFF_LINENO
18451846
** --noopt Disable optimization DIFF_NOOPT
18461847
** --side-by-side|-y Side-by-side diff. DIFF_SIDEBYSIDE
18471848
** --unified Unified diff. ~DIFF_SIDEBYSIDE
18481849
** --width|-W N N character lines. DIFF_WIDTH_MASK
@@ -1861,11 +1862,11 @@
18611862
f *= DIFF_CONTEXT_MASK+1;
18621863
if( f > DIFF_WIDTH_MASK ) f = DIFF_CONTEXT_MASK;
18631864
diffFlags |= f;
18641865
}
18651866
if( find_option("html",0,0)!=0 ) diffFlags |= DIFF_HTML;
1866
- if( find_option("ignore-eolws","w",0)!=0 ) diffFlags |= DIFF_IGNORE_EOLWS;
1867
+ if( find_option("ignore-space-at-eol","w",0)!=0 ) diffFlags |= DIFF_IGNORE_EOLWS;
18671868
if( find_option("linenum","n",0)!=0 ) diffFlags |= DIFF_LINENO;
18681869
if( find_option("noopt",0,0)!=0 ) diffFlags |= DIFF_NOOPT;
18691870
if( find_option("invert",0,0)!=0 ) diffFlags |= DIFF_INVERT;
18701871
if( find_option("brief",0,0)!=0 ) diffFlags |= DIFF_BRIEF;
18711872
return diffFlags;
@@ -1968,11 +1969,11 @@
19681969
*/
19691970
static int annotation_start(Annotator *p, Blob *pInput){
19701971
int i;
19711972
19721973
memset(p, 0, sizeof(*p));
1973
- p->c.aTo = break_into_lines(blob_str(pInput), blob_size(pInput),&p->c.nTo,1);
1974
+ p->c.aTo = break_into_lines(blob_str(pInput), blob_size(pInput),&p->c.nTo,DIFF_IGNORE_EOLWS);
19741975
if( p->c.aTo==0 ){
19751976
return 1;
19761977
}
19771978
p->aOrig = fossil_malloc( sizeof(p->aOrig[0])*p->c.nTo );
19781979
for(i=0; i<p->c.nTo; i++){
@@ -1995,11 +1996,11 @@
19951996
int i, j;
19961997
int lnTo;
19971998
19981999
/* Prepare the parent file to be diffed */
19992000
p->c.aFrom = break_into_lines(blob_str(pParent), blob_size(pParent),
2000
- &p->c.nFrom, 1);
2001
+ &p->c.nFrom, DIFF_IGNORE_EOLWS);
20012002
if( p->c.aFrom==0 ){
20022003
return 1;
20032004
}
20042005
20052006
/* Compute the differences going from pParent to the file being
20062007
--- src/diff.c
+++ src/diff.c
@@ -128,14 +128,15 @@
128 ** too long.
129 **
130 ** Profiling show that in most cases this routine consumes the bulk of
131 ** the CPU time on a diff.
132 */
133 static DLine *break_into_lines(const char *z, int n, int *pnLine, int ignoreWS){
134 int nLine, i, j, k, x;
135 unsigned int h, h2;
136 DLine *a;
 
137
138 /* Count the number of lines. Allocate space to hold
139 ** the returned array.
140 */
141 for(i=j=0, nLine=1; i<n; i++, j++){
@@ -1771,13 +1772,13 @@
1771 blob_to_utf8_no_bom(pB_Blob, 0);
1772
1773 /* Prepare the input files */
1774 memset(&c, 0, sizeof(c));
1775 c.aFrom = break_into_lines(blob_str(pA_Blob), blob_size(pA_Blob),
1776 &c.nFrom, ignoreEolWs);
1777 c.aTo = break_into_lines(blob_str(pB_Blob), blob_size(pB_Blob),
1778 &c.nTo, ignoreEolWs);
1779 if( c.aFrom==0 || c.aTo==0 ){
1780 fossil_free(c.aFrom);
1781 fossil_free(c.aTo);
1782 if( pOut ){
1783 diff_errmsg(pOut, DIFF_CANNOT_COMPUTE_BINARY, diffFlags);
@@ -1838,11 +1839,11 @@
1838 **
1839 ** --brief Show filenames only DIFF_BRIEF
1840 ** --context|-c N N lines of context. DIFF_CONTEXT_MASK
1841 ** --html Format for HTML DIFF_HTML
1842 ** --invert Invert the diff DIFF_INVERT
1843 ** --ignore-eolws|-w Ignore eol-whitespaces DIFF_IGNORE_EOLWS
1844 ** --linenum|-n Show line numbers DIFF_LINENO
1845 ** --noopt Disable optimization DIFF_NOOPT
1846 ** --side-by-side|-y Side-by-side diff. DIFF_SIDEBYSIDE
1847 ** --unified Unified diff. ~DIFF_SIDEBYSIDE
1848 ** --width|-W N N character lines. DIFF_WIDTH_MASK
@@ -1861,11 +1862,11 @@
1861 f *= DIFF_CONTEXT_MASK+1;
1862 if( f > DIFF_WIDTH_MASK ) f = DIFF_CONTEXT_MASK;
1863 diffFlags |= f;
1864 }
1865 if( find_option("html",0,0)!=0 ) diffFlags |= DIFF_HTML;
1866 if( find_option("ignore-eolws","w",0)!=0 ) diffFlags |= DIFF_IGNORE_EOLWS;
1867 if( find_option("linenum","n",0)!=0 ) diffFlags |= DIFF_LINENO;
1868 if( find_option("noopt",0,0)!=0 ) diffFlags |= DIFF_NOOPT;
1869 if( find_option("invert",0,0)!=0 ) diffFlags |= DIFF_INVERT;
1870 if( find_option("brief",0,0)!=0 ) diffFlags |= DIFF_BRIEF;
1871 return diffFlags;
@@ -1968,11 +1969,11 @@
1968 */
1969 static int annotation_start(Annotator *p, Blob *pInput){
1970 int i;
1971
1972 memset(p, 0, sizeof(*p));
1973 p->c.aTo = break_into_lines(blob_str(pInput), blob_size(pInput),&p->c.nTo,1);
1974 if( p->c.aTo==0 ){
1975 return 1;
1976 }
1977 p->aOrig = fossil_malloc( sizeof(p->aOrig[0])*p->c.nTo );
1978 for(i=0; i<p->c.nTo; i++){
@@ -1995,11 +1996,11 @@
1995 int i, j;
1996 int lnTo;
1997
1998 /* Prepare the parent file to be diffed */
1999 p->c.aFrom = break_into_lines(blob_str(pParent), blob_size(pParent),
2000 &p->c.nFrom, 1);
2001 if( p->c.aFrom==0 ){
2002 return 1;
2003 }
2004
2005 /* Compute the differences going from pParent to the file being
2006
--- src/diff.c
+++ src/diff.c
@@ -128,14 +128,15 @@
128 ** too long.
129 **
130 ** Profiling show that in most cases this routine consumes the bulk of
131 ** the CPU time on a diff.
132 */
133 static DLine *break_into_lines(const char *z, int n, int *pnLine, int diffFlags){
134 int nLine, i, j, k, x;
135 unsigned int h, h2;
136 DLine *a;
137 int ignoreWS = diffFlags & DIFF_IGNORE_EOLWS;
138
139 /* Count the number of lines. Allocate space to hold
140 ** the returned array.
141 */
142 for(i=j=0, nLine=1; i<n; i++, j++){
@@ -1771,13 +1772,13 @@
1772 blob_to_utf8_no_bom(pB_Blob, 0);
1773
1774 /* Prepare the input files */
1775 memset(&c, 0, sizeof(c));
1776 c.aFrom = break_into_lines(blob_str(pA_Blob), blob_size(pA_Blob),
1777 &c.nFrom, diffFlags);
1778 c.aTo = break_into_lines(blob_str(pB_Blob), blob_size(pB_Blob),
1779 &c.nTo, diffFlags);
1780 if( c.aFrom==0 || c.aTo==0 ){
1781 fossil_free(c.aFrom);
1782 fossil_free(c.aTo);
1783 if( pOut ){
1784 diff_errmsg(pOut, DIFF_CANNOT_COMPUTE_BINARY, diffFlags);
@@ -1838,11 +1839,11 @@
1839 **
1840 ** --brief Show filenames only DIFF_BRIEF
1841 ** --context|-c N N lines of context. DIFF_CONTEXT_MASK
1842 ** --html Format for HTML DIFF_HTML
1843 ** --invert Invert the diff DIFF_INVERT
1844 ** --ignore-space-at-eol Ignore eol-whitespaces DIFF_IGNORE_EOLWS
1845 ** --linenum|-n Show line numbers DIFF_LINENO
1846 ** --noopt Disable optimization DIFF_NOOPT
1847 ** --side-by-side|-y Side-by-side diff. DIFF_SIDEBYSIDE
1848 ** --unified Unified diff. ~DIFF_SIDEBYSIDE
1849 ** --width|-W N N character lines. DIFF_WIDTH_MASK
@@ -1861,11 +1862,11 @@
1862 f *= DIFF_CONTEXT_MASK+1;
1863 if( f > DIFF_WIDTH_MASK ) f = DIFF_CONTEXT_MASK;
1864 diffFlags |= f;
1865 }
1866 if( find_option("html",0,0)!=0 ) diffFlags |= DIFF_HTML;
1867 if( find_option("ignore-space-at-eol","w",0)!=0 ) diffFlags |= DIFF_IGNORE_EOLWS;
1868 if( find_option("linenum","n",0)!=0 ) diffFlags |= DIFF_LINENO;
1869 if( find_option("noopt",0,0)!=0 ) diffFlags |= DIFF_NOOPT;
1870 if( find_option("invert",0,0)!=0 ) diffFlags |= DIFF_INVERT;
1871 if( find_option("brief",0,0)!=0 ) diffFlags |= DIFF_BRIEF;
1872 return diffFlags;
@@ -1968,11 +1969,11 @@
1969 */
1970 static int annotation_start(Annotator *p, Blob *pInput){
1971 int i;
1972
1973 memset(p, 0, sizeof(*p));
1974 p->c.aTo = break_into_lines(blob_str(pInput), blob_size(pInput),&p->c.nTo,DIFF_IGNORE_EOLWS);
1975 if( p->c.aTo==0 ){
1976 return 1;
1977 }
1978 p->aOrig = fossil_malloc( sizeof(p->aOrig[0])*p->c.nTo );
1979 for(i=0; i<p->c.nTo; i++){
@@ -1995,11 +1996,11 @@
1996 int i, j;
1997 int lnTo;
1998
1999 /* Prepare the parent file to be diffed */
2000 p->c.aFrom = break_into_lines(blob_str(pParent), blob_size(pParent),
2001 &p->c.nFrom, DIFF_IGNORE_EOLWS);
2002 if( p->c.aFrom==0 ){
2003 return 1;
2004 }
2005
2006 /* Compute the differences going from pParent to the file being
2007
+1 -1
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -1086,11 +1086,11 @@
10861086
** --branch BRANCH Show diff of all changes on BRANCH
10871087
** --brief Show filenames only
10881088
** --context|-c N Use N lines of context
10891089
** --diff-binary BOOL Include binary files when using external commands
10901090
** --from|-r VERSION select VERSION as source for the diff
1091
-** --ignore-eolws|-w Ignore changes to end-of-line whitespace
1091
+** --ignore-space-at-eol Ignore changes to end-of-line whitespace
10921092
** --internal|-i use internal diff logic
10931093
** --side-by-side|-y side-by-side diff
10941094
** --tk Launch a Tcl/Tk GUI for display
10951095
** --to VERSION select VERSION as target for the diff
10961096
** --unified unified diff
10971097
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -1086,11 +1086,11 @@
1086 ** --branch BRANCH Show diff of all changes on BRANCH
1087 ** --brief Show filenames only
1088 ** --context|-c N Use N lines of context
1089 ** --diff-binary BOOL Include binary files when using external commands
1090 ** --from|-r VERSION select VERSION as source for the diff
1091 ** --ignore-eolws|-w Ignore changes to end-of-line whitespace
1092 ** --internal|-i use internal diff logic
1093 ** --side-by-side|-y side-by-side diff
1094 ** --tk Launch a Tcl/Tk GUI for display
1095 ** --to VERSION select VERSION as target for the diff
1096 ** --unified unified diff
1097
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -1086,11 +1086,11 @@
1086 ** --branch BRANCH Show diff of all changes on BRANCH
1087 ** --brief Show filenames only
1088 ** --context|-c N Use N lines of context
1089 ** --diff-binary BOOL Include binary files when using external commands
1090 ** --from|-r VERSION select VERSION as source for the diff
1091 ** --ignore-space-at-eol Ignore changes to end-of-line whitespace
1092 ** --internal|-i use internal diff logic
1093 ** --side-by-side|-y side-by-side diff
1094 ** --tk Launch a Tcl/Tk GUI for display
1095 ** --to VERSION select VERSION as target for the diff
1096 ** --unified unified diff
1097

Keyboard Shortcuts

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