Fossil SCM

Implement --strip-trailing-cr option

jan.nijtmans 2014-03-05 22:54 trunk
Commit 4e6cfaf8f85c787e8f7dc84d4a9b326e853388a9
2 files changed +5 +1
+5
--- src/diff.c
+++ src/diff.c
@@ -40,10 +40,11 @@
4040
#define DIFF_LINENO ((u64)0x40000000) /* Show line numbers */
4141
#define DIFF_NOOPT (((u64)0x01)<<32) /* Suppress optimizations (debug) */
4242
#define DIFF_INVERT (((u64)0x02)<<32) /* Invert the diff (debug) */
4343
#define DIFF_CONTEXT_EX (((u64)0x04)<<32) /* Use context even if zero */
4444
#define DIFF_NOTTOOBIG (((u64)0x08)<<32) /* Only display if not too big */
45
+#define DIFF_STRIP_EOLCR (((u64)0x10)<<32) /* Strip trailing CR */
4546
4647
/*
4748
** These error messages are shared in multiple locations. They are defined
4849
** here for consistency.
4950
*/
@@ -168,10 +169,12 @@
168169
k = j;
169170
s = 0;
170171
indent = 0;
171172
if( diffFlags & DIFF_IGNORE_EOLWS ){
172173
while( k>0 && fossil_isspace(z[k-1]) ){ k--; }
174
+ }else if( diffFlags & DIFF_STRIP_EOLCR ){
175
+ if( k>0 && z[k-1]=='\r' ){ k--; }
173176
}
174177
if( diffFlags & DIFF_IGNORE_SOLWS ){
175178
while( s<k && fossil_isspace(z[s]) ){
176179
if( z[s]=='\t' ){
177180
indent = ((indent+9)/8)*8;
@@ -1868,10 +1871,11 @@
18681871
** --ignore-space-at-eol Ignore eol-whitespaces DIFF_IGNORE_EOLWS
18691872
** --ignore-space-at-sol Ignore sol-whitespaces DIFF_IGNORE_SOLWS
18701873
** --linenum|-n Show line numbers DIFF_LINENO
18711874
** --noopt Disable optimization DIFF_NOOPT
18721875
** --side-by-side|-y Side-by-side diff. DIFF_SIDEBYSIDE
1876
+** --strip-trailing-cr Strip trailing CR DIFF_IGNORE_EOLCR
18731877
** --unified Unified diff. ~DIFF_SIDEBYSIDE
18741878
** -w Ignore all whitespaces DIFF_IGNORE_EOLWS|DIFF_IGNORE_SOLWS
18751879
** --width|-W N N character lines. DIFF_WIDTH_MASK
18761880
*/
18771881
u64 diff_options(void){
@@ -1890,10 +1894,11 @@
18901894
diffFlags |= f;
18911895
}
18921896
if( find_option("html",0,0)!=0 ) diffFlags |= DIFF_HTML;
18931897
if( find_option("ignore-space-at-sol",0,0)!=0 ) diffFlags |= DIFF_IGNORE_SOLWS;
18941898
if( find_option("ignore-space-at-eol",0,0)!=0 ) diffFlags |= DIFF_IGNORE_EOLWS;
1899
+ if( find_option("strip-trailing-cr",0,0)!=0 ) diffFlags |= DIFF_STRIP_EOLCR;
18951900
if( find_option("w",0,0)!=0 ) diffFlags |= (DIFF_IGNORE_EOLWS|DIFF_IGNORE_SOLWS);
18961901
if( find_option("linenum","n",0)!=0 ) diffFlags |= DIFF_LINENO;
18971902
if( find_option("noopt",0,0)!=0 ) diffFlags |= DIFF_NOOPT;
18981903
if( find_option("invert",0,0)!=0 ) diffFlags |= DIFF_INVERT;
18991904
if( find_option("brief",0,0)!=0 ) diffFlags |= DIFF_BRIEF;
19001905
--- src/diff.c
+++ src/diff.c
@@ -40,10 +40,11 @@
40 #define DIFF_LINENO ((u64)0x40000000) /* Show line numbers */
41 #define DIFF_NOOPT (((u64)0x01)<<32) /* Suppress optimizations (debug) */
42 #define DIFF_INVERT (((u64)0x02)<<32) /* Invert the diff (debug) */
43 #define DIFF_CONTEXT_EX (((u64)0x04)<<32) /* Use context even if zero */
44 #define DIFF_NOTTOOBIG (((u64)0x08)<<32) /* Only display if not too big */
 
45
46 /*
47 ** These error messages are shared in multiple locations. They are defined
48 ** here for consistency.
49 */
@@ -168,10 +169,12 @@
168 k = j;
169 s = 0;
170 indent = 0;
171 if( diffFlags & DIFF_IGNORE_EOLWS ){
172 while( k>0 && fossil_isspace(z[k-1]) ){ k--; }
 
 
173 }
174 if( diffFlags & DIFF_IGNORE_SOLWS ){
175 while( s<k && fossil_isspace(z[s]) ){
176 if( z[s]=='\t' ){
177 indent = ((indent+9)/8)*8;
@@ -1868,10 +1871,11 @@
1868 ** --ignore-space-at-eol Ignore eol-whitespaces DIFF_IGNORE_EOLWS
1869 ** --ignore-space-at-sol Ignore sol-whitespaces DIFF_IGNORE_SOLWS
1870 ** --linenum|-n Show line numbers DIFF_LINENO
1871 ** --noopt Disable optimization DIFF_NOOPT
1872 ** --side-by-side|-y Side-by-side diff. DIFF_SIDEBYSIDE
 
1873 ** --unified Unified diff. ~DIFF_SIDEBYSIDE
1874 ** -w Ignore all whitespaces DIFF_IGNORE_EOLWS|DIFF_IGNORE_SOLWS
1875 ** --width|-W N N character lines. DIFF_WIDTH_MASK
1876 */
1877 u64 diff_options(void){
@@ -1890,10 +1894,11 @@
1890 diffFlags |= f;
1891 }
1892 if( find_option("html",0,0)!=0 ) diffFlags |= DIFF_HTML;
1893 if( find_option("ignore-space-at-sol",0,0)!=0 ) diffFlags |= DIFF_IGNORE_SOLWS;
1894 if( find_option("ignore-space-at-eol",0,0)!=0 ) diffFlags |= DIFF_IGNORE_EOLWS;
 
1895 if( find_option("w",0,0)!=0 ) diffFlags |= (DIFF_IGNORE_EOLWS|DIFF_IGNORE_SOLWS);
1896 if( find_option("linenum","n",0)!=0 ) diffFlags |= DIFF_LINENO;
1897 if( find_option("noopt",0,0)!=0 ) diffFlags |= DIFF_NOOPT;
1898 if( find_option("invert",0,0)!=0 ) diffFlags |= DIFF_INVERT;
1899 if( find_option("brief",0,0)!=0 ) diffFlags |= DIFF_BRIEF;
1900
--- src/diff.c
+++ src/diff.c
@@ -40,10 +40,11 @@
40 #define DIFF_LINENO ((u64)0x40000000) /* Show line numbers */
41 #define DIFF_NOOPT (((u64)0x01)<<32) /* Suppress optimizations (debug) */
42 #define DIFF_INVERT (((u64)0x02)<<32) /* Invert the diff (debug) */
43 #define DIFF_CONTEXT_EX (((u64)0x04)<<32) /* Use context even if zero */
44 #define DIFF_NOTTOOBIG (((u64)0x08)<<32) /* Only display if not too big */
45 #define DIFF_STRIP_EOLCR (((u64)0x10)<<32) /* Strip trailing CR */
46
47 /*
48 ** These error messages are shared in multiple locations. They are defined
49 ** here for consistency.
50 */
@@ -168,10 +169,12 @@
169 k = j;
170 s = 0;
171 indent = 0;
172 if( diffFlags & DIFF_IGNORE_EOLWS ){
173 while( k>0 && fossil_isspace(z[k-1]) ){ k--; }
174 }else if( diffFlags & DIFF_STRIP_EOLCR ){
175 if( k>0 && z[k-1]=='\r' ){ k--; }
176 }
177 if( diffFlags & DIFF_IGNORE_SOLWS ){
178 while( s<k && fossil_isspace(z[s]) ){
179 if( z[s]=='\t' ){
180 indent = ((indent+9)/8)*8;
@@ -1868,10 +1871,11 @@
1871 ** --ignore-space-at-eol Ignore eol-whitespaces DIFF_IGNORE_EOLWS
1872 ** --ignore-space-at-sol Ignore sol-whitespaces DIFF_IGNORE_SOLWS
1873 ** --linenum|-n Show line numbers DIFF_LINENO
1874 ** --noopt Disable optimization DIFF_NOOPT
1875 ** --side-by-side|-y Side-by-side diff. DIFF_SIDEBYSIDE
1876 ** --strip-trailing-cr Strip trailing CR DIFF_IGNORE_EOLCR
1877 ** --unified Unified diff. ~DIFF_SIDEBYSIDE
1878 ** -w Ignore all whitespaces DIFF_IGNORE_EOLWS|DIFF_IGNORE_SOLWS
1879 ** --width|-W N N character lines. DIFF_WIDTH_MASK
1880 */
1881 u64 diff_options(void){
@@ -1890,10 +1894,11 @@
1894 diffFlags |= f;
1895 }
1896 if( find_option("html",0,0)!=0 ) diffFlags |= DIFF_HTML;
1897 if( find_option("ignore-space-at-sol",0,0)!=0 ) diffFlags |= DIFF_IGNORE_SOLWS;
1898 if( find_option("ignore-space-at-eol",0,0)!=0 ) diffFlags |= DIFF_IGNORE_EOLWS;
1899 if( find_option("strip-trailing-cr",0,0)!=0 ) diffFlags |= DIFF_STRIP_EOLCR;
1900 if( find_option("w",0,0)!=0 ) diffFlags |= (DIFF_IGNORE_EOLWS|DIFF_IGNORE_SOLWS);
1901 if( find_option("linenum","n",0)!=0 ) diffFlags |= DIFF_LINENO;
1902 if( find_option("noopt",0,0)!=0 ) diffFlags |= DIFF_NOOPT;
1903 if( find_option("invert",0,0)!=0 ) diffFlags |= DIFF_INVERT;
1904 if( find_option("brief",0,0)!=0 ) diffFlags |= DIFF_BRIEF;
1905
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -1099,10 +1099,11 @@
10991099
** --from|-r VERSION select VERSION as source for the diff
11001100
** --ignore-space-at-eol Ignore changes to end-of-line whitespace
11011101
** --ignore-space-at-sol Ignore changes to start-of-line whitespace
11021102
** --internal|-i use internal diff logic
11031103
** --side-by-side|-y side-by-side diff
1104
+** --strip-trailing-cr Strip trailing CR
11041105
** --tk Launch a Tcl/Tk GUI for display
11051106
** --to VERSION select VERSION as target for the diff
11061107
** --unified unified diff
11071108
** -v|--verbose output complete text of added or deleted files
11081109
** -w Ignore changes to start-of-line and end-of-line
11091110
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -1099,10 +1099,11 @@
1099 ** --from|-r VERSION select VERSION as source for the diff
1100 ** --ignore-space-at-eol Ignore changes to end-of-line whitespace
1101 ** --ignore-space-at-sol Ignore changes to start-of-line whitespace
1102 ** --internal|-i use internal diff logic
1103 ** --side-by-side|-y side-by-side diff
 
1104 ** --tk Launch a Tcl/Tk GUI for display
1105 ** --to VERSION select VERSION as target for the diff
1106 ** --unified unified diff
1107 ** -v|--verbose output complete text of added or deleted files
1108 ** -w Ignore changes to start-of-line and end-of-line
1109
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -1099,10 +1099,11 @@
1099 ** --from|-r VERSION select VERSION as source for the diff
1100 ** --ignore-space-at-eol Ignore changes to end-of-line whitespace
1101 ** --ignore-space-at-sol Ignore changes to start-of-line whitespace
1102 ** --internal|-i use internal diff logic
1103 ** --side-by-side|-y side-by-side diff
1104 ** --strip-trailing-cr Strip trailing CR
1105 ** --tk Launch a Tcl/Tk GUI for display
1106 ** --to VERSION select VERSION as target for the diff
1107 ** --unified unified diff
1108 ** -v|--verbose output complete text of added or deleted files
1109 ** -w Ignore changes to start-of-line and end-of-line
1110

Keyboard Shortcuts

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