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.
Commit
2dffb0e0262ace15f9a6d70ee80f10abc545d8f3
Parent
31d25923bd1626f…
2 files changed
+8
-7
+1
-1
+8
-7
| --- src/diff.c | ||
| +++ src/diff.c | ||
| @@ -128,14 +128,15 @@ | ||
| 128 | 128 | ** too long. |
| 129 | 129 | ** |
| 130 | 130 | ** Profiling show that in most cases this routine consumes the bulk of |
| 131 | 131 | ** the CPU time on a diff. |
| 132 | 132 | */ |
| 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){ | |
| 134 | 134 | int nLine, i, j, k, x; |
| 135 | 135 | unsigned int h, h2; |
| 136 | 136 | DLine *a; |
| 137 | + int ignoreWS = diffFlags & DIFF_IGNORE_EOLWS; | |
| 137 | 138 | |
| 138 | 139 | /* Count the number of lines. Allocate space to hold |
| 139 | 140 | ** the returned array. |
| 140 | 141 | */ |
| 141 | 142 | for(i=j=0, nLine=1; i<n; i++, j++){ |
| @@ -1771,13 +1772,13 @@ | ||
| 1771 | 1772 | blob_to_utf8_no_bom(pB_Blob, 0); |
| 1772 | 1773 | |
| 1773 | 1774 | /* Prepare the input files */ |
| 1774 | 1775 | memset(&c, 0, sizeof(c)); |
| 1775 | 1776 | c.aFrom = break_into_lines(blob_str(pA_Blob), blob_size(pA_Blob), |
| 1776 | - &c.nFrom, ignoreEolWs); | |
| 1777 | + &c.nFrom, diffFlags); | |
| 1777 | 1778 | c.aTo = break_into_lines(blob_str(pB_Blob), blob_size(pB_Blob), |
| 1778 | - &c.nTo, ignoreEolWs); | |
| 1779 | + &c.nTo, diffFlags); | |
| 1779 | 1780 | if( c.aFrom==0 || c.aTo==0 ){ |
| 1780 | 1781 | fossil_free(c.aFrom); |
| 1781 | 1782 | fossil_free(c.aTo); |
| 1782 | 1783 | if( pOut ){ |
| 1783 | 1784 | diff_errmsg(pOut, DIFF_CANNOT_COMPUTE_BINARY, diffFlags); |
| @@ -1838,11 +1839,11 @@ | ||
| 1838 | 1839 | ** |
| 1839 | 1840 | ** --brief Show filenames only DIFF_BRIEF |
| 1840 | 1841 | ** --context|-c N N lines of context. DIFF_CONTEXT_MASK |
| 1841 | 1842 | ** --html Format for HTML DIFF_HTML |
| 1842 | 1843 | ** --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 | |
| 1844 | 1845 | ** --linenum|-n Show line numbers DIFF_LINENO |
| 1845 | 1846 | ** --noopt Disable optimization DIFF_NOOPT |
| 1846 | 1847 | ** --side-by-side|-y Side-by-side diff. DIFF_SIDEBYSIDE |
| 1847 | 1848 | ** --unified Unified diff. ~DIFF_SIDEBYSIDE |
| 1848 | 1849 | ** --width|-W N N character lines. DIFF_WIDTH_MASK |
| @@ -1861,11 +1862,11 @@ | ||
| 1861 | 1862 | f *= DIFF_CONTEXT_MASK+1; |
| 1862 | 1863 | if( f > DIFF_WIDTH_MASK ) f = DIFF_CONTEXT_MASK; |
| 1863 | 1864 | diffFlags |= f; |
| 1864 | 1865 | } |
| 1865 | 1866 | 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; | |
| 1867 | 1868 | if( find_option("linenum","n",0)!=0 ) diffFlags |= DIFF_LINENO; |
| 1868 | 1869 | if( find_option("noopt",0,0)!=0 ) diffFlags |= DIFF_NOOPT; |
| 1869 | 1870 | if( find_option("invert",0,0)!=0 ) diffFlags |= DIFF_INVERT; |
| 1870 | 1871 | if( find_option("brief",0,0)!=0 ) diffFlags |= DIFF_BRIEF; |
| 1871 | 1872 | return diffFlags; |
| @@ -1968,11 +1969,11 @@ | ||
| 1968 | 1969 | */ |
| 1969 | 1970 | static int annotation_start(Annotator *p, Blob *pInput){ |
| 1970 | 1971 | int i; |
| 1971 | 1972 | |
| 1972 | 1973 | 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); | |
| 1974 | 1975 | if( p->c.aTo==0 ){ |
| 1975 | 1976 | return 1; |
| 1976 | 1977 | } |
| 1977 | 1978 | p->aOrig = fossil_malloc( sizeof(p->aOrig[0])*p->c.nTo ); |
| 1978 | 1979 | for(i=0; i<p->c.nTo; i++){ |
| @@ -1995,11 +1996,11 @@ | ||
| 1995 | 1996 | int i, j; |
| 1996 | 1997 | int lnTo; |
| 1997 | 1998 | |
| 1998 | 1999 | /* Prepare the parent file to be diffed */ |
| 1999 | 2000 | p->c.aFrom = break_into_lines(blob_str(pParent), blob_size(pParent), |
| 2000 | - &p->c.nFrom, 1); | |
| 2001 | + &p->c.nFrom, DIFF_IGNORE_EOLWS); | |
| 2001 | 2002 | if( p->c.aFrom==0 ){ |
| 2002 | 2003 | return 1; |
| 2003 | 2004 | } |
| 2004 | 2005 | |
| 2005 | 2006 | /* Compute the differences going from pParent to the file being |
| 2006 | 2007 |
| --- 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 @@ | ||
| 1086 | 1086 | ** --branch BRANCH Show diff of all changes on BRANCH |
| 1087 | 1087 | ** --brief Show filenames only |
| 1088 | 1088 | ** --context|-c N Use N lines of context |
| 1089 | 1089 | ** --diff-binary BOOL Include binary files when using external commands |
| 1090 | 1090 | ** --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 | |
| 1092 | 1092 | ** --internal|-i use internal diff logic |
| 1093 | 1093 | ** --side-by-side|-y side-by-side diff |
| 1094 | 1094 | ** --tk Launch a Tcl/Tk GUI for display |
| 1095 | 1095 | ** --to VERSION select VERSION as target for the diff |
| 1096 | 1096 | ** --unified unified diff |
| 1097 | 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-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 |