Fossil

Check-in [4e6cfaf8]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Implement --strip-trailing-cr option
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | strip-trailing-cr
Files: files | file ages | folders
SHA1:4e6cfaf8f85c787e8f7dc84d4a9b326e853388a9
User & Date: jan.nijtmans 2014-03-05 22:54:24
Context
2014-03-07
09:01
Rename --ignore-space-at-eol (from Git) to -Z|--ignore-trailing-space (gnu diff). Add --ignore-all-space as well (doesn't behave exactly like GNU's option yet) check-in: d9e79f68 user: jan.nijtmans tags: strip-trailing-cr
2014-03-05
22:54
Implement --strip-trailing-cr option check-in: 4e6cfaf8 user: jan.nijtmans tags: strip-trailing-cr
22:06
Flag DIFF_INLINE was 0 and that should stay so check-in: 466f8de3 user: jan.nijtmans tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/diff.c.

38
39
40
41
42
43
44

45
46
47
48
49
50
51
...
166
167
168
169
170
171
172


173
174
175
176
177
178
179
....
1866
1867
1868
1869
1870
1871
1872

1873
1874
1875
1876
1877
1878
1879
....
1888
1889
1890
1891
1892
1893
1894

1895
1896
1897
1898
1899
1900
1901
#define DIFF_BRIEF        ((u64)0x10000000) /* Show filenames only */
#define DIFF_HTML         ((u64)0x20000000) /* Render for HTML */
#define DIFF_LINENO       ((u64)0x40000000) /* Show line numbers */
#define DIFF_NOOPT        (((u64)0x01)<<32) /* Suppress optimizations (debug) */
#define DIFF_INVERT       (((u64)0x02)<<32) /* Invert the diff (debug) */
#define DIFF_CONTEXT_EX   (((u64)0x04)<<32) /* Use context even if zero */
#define DIFF_NOTTOOBIG    (((u64)0x08)<<32) /* Only display if not too big */


/*
** These error messages are shared in multiple locations.  They are defined
** here for consistency.
*/
#define DIFF_CANNOT_COMPUTE_BINARY \
    "cannot compute difference between binary files\n"
................................................................................
  for(i=0; i<nLine; i++){
    for(j=0; z[j] && z[j]!='\n'; j++){}
    k = j;
    s = 0;
    indent = 0;
    if( diffFlags & DIFF_IGNORE_EOLWS ){
      while( k>0 && fossil_isspace(z[k-1]) ){ k--; }


    }
    if( diffFlags & DIFF_IGNORE_SOLWS ){
      while( s<k && fossil_isspace(z[s]) ){
        if( z[s]=='\t' ){
          indent = ((indent+9)/8)*8;
        }else if( z[s]==' ' ){
          indent++;
................................................................................
**   --html                 Format for HTML        DIFF_HTML
**   --invert               Invert the diff        DIFF_INVERT
**   --ignore-space-at-eol  Ignore eol-whitespaces DIFF_IGNORE_EOLWS
**   --ignore-space-at-sol  Ignore sol-whitespaces DIFF_IGNORE_SOLWS
**   --linenum|-n           Show line numbers      DIFF_LINENO
**   --noopt                Disable optimization   DIFF_NOOPT
**   --side-by-side|-y      Side-by-side diff.     DIFF_SIDEBYSIDE

**   --unified              Unified diff.          ~DIFF_SIDEBYSIDE
**   -w                     Ignore all whitespaces DIFF_IGNORE_EOLWS|DIFF_IGNORE_SOLWS
**   --width|-W N           N character lines.     DIFF_WIDTH_MASK
*/
u64 diff_options(void){
  u64 diffFlags = 0;
  const char *z;
................................................................................
    f *= DIFF_CONTEXT_MASK+1;
    if( f > DIFF_WIDTH_MASK ) f = DIFF_CONTEXT_MASK;
    diffFlags |= f;
  }
  if( find_option("html",0,0)!=0 ) diffFlags |= DIFF_HTML;
  if( find_option("ignore-space-at-sol",0,0)!=0 ) diffFlags |= DIFF_IGNORE_SOLWS;
  if( find_option("ignore-space-at-eol",0,0)!=0 ) diffFlags |= DIFF_IGNORE_EOLWS;

  if( find_option("w",0,0)!=0 ) diffFlags |= (DIFF_IGNORE_EOLWS|DIFF_IGNORE_SOLWS);
  if( find_option("linenum","n",0)!=0 ) diffFlags |= DIFF_LINENO;
  if( find_option("noopt",0,0)!=0 ) diffFlags |= DIFF_NOOPT;
  if( find_option("invert",0,0)!=0 ) diffFlags |= DIFF_INVERT;
  if( find_option("brief",0,0)!=0 ) diffFlags |= DIFF_BRIEF;
  return diffFlags;
}







>







 







>
>







 







>







 







>







38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
...
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
....
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
....
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
#define DIFF_BRIEF        ((u64)0x10000000) /* Show filenames only */
#define DIFF_HTML         ((u64)0x20000000) /* Render for HTML */
#define DIFF_LINENO       ((u64)0x40000000) /* Show line numbers */
#define DIFF_NOOPT        (((u64)0x01)<<32) /* Suppress optimizations (debug) */
#define DIFF_INVERT       (((u64)0x02)<<32) /* Invert the diff (debug) */
#define DIFF_CONTEXT_EX   (((u64)0x04)<<32) /* Use context even if zero */
#define DIFF_NOTTOOBIG    (((u64)0x08)<<32) /* Only display if not too big */
#define DIFF_STRIP_EOLCR  (((u64)0x10)<<32) /* Strip trailing CR */

/*
** These error messages are shared in multiple locations.  They are defined
** here for consistency.
*/
#define DIFF_CANNOT_COMPUTE_BINARY \
    "cannot compute difference between binary files\n"
................................................................................
  for(i=0; i<nLine; i++){
    for(j=0; z[j] && z[j]!='\n'; j++){}
    k = j;
    s = 0;
    indent = 0;
    if( diffFlags & DIFF_IGNORE_EOLWS ){
      while( k>0 && fossil_isspace(z[k-1]) ){ k--; }
    }else if( diffFlags & DIFF_STRIP_EOLCR ){
      if( k>0 && z[k-1]=='\r' ){ k--; }
    }
    if( diffFlags & DIFF_IGNORE_SOLWS ){
      while( s<k && fossil_isspace(z[s]) ){
        if( z[s]=='\t' ){
          indent = ((indent+9)/8)*8;
        }else if( z[s]==' ' ){
          indent++;
................................................................................
**   --html                 Format for HTML        DIFF_HTML
**   --invert               Invert the diff        DIFF_INVERT
**   --ignore-space-at-eol  Ignore eol-whitespaces DIFF_IGNORE_EOLWS
**   --ignore-space-at-sol  Ignore sol-whitespaces DIFF_IGNORE_SOLWS
**   --linenum|-n           Show line numbers      DIFF_LINENO
**   --noopt                Disable optimization   DIFF_NOOPT
**   --side-by-side|-y      Side-by-side diff.     DIFF_SIDEBYSIDE
**   --strip-trailing-cr    Strip trailing CR      DIFF_IGNORE_EOLCR
**   --unified              Unified diff.          ~DIFF_SIDEBYSIDE
**   -w                     Ignore all whitespaces DIFF_IGNORE_EOLWS|DIFF_IGNORE_SOLWS
**   --width|-W N           N character lines.     DIFF_WIDTH_MASK
*/
u64 diff_options(void){
  u64 diffFlags = 0;
  const char *z;
................................................................................
    f *= DIFF_CONTEXT_MASK+1;
    if( f > DIFF_WIDTH_MASK ) f = DIFF_CONTEXT_MASK;
    diffFlags |= f;
  }
  if( find_option("html",0,0)!=0 ) diffFlags |= DIFF_HTML;
  if( find_option("ignore-space-at-sol",0,0)!=0 ) diffFlags |= DIFF_IGNORE_SOLWS;
  if( find_option("ignore-space-at-eol",0,0)!=0 ) diffFlags |= DIFF_IGNORE_EOLWS;
  if( find_option("strip-trailing-cr",0,0)!=0 ) diffFlags |= DIFF_STRIP_EOLCR;
  if( find_option("w",0,0)!=0 ) diffFlags |= (DIFF_IGNORE_EOLWS|DIFF_IGNORE_SOLWS);
  if( find_option("linenum","n",0)!=0 ) diffFlags |= DIFF_LINENO;
  if( find_option("noopt",0,0)!=0 ) diffFlags |= DIFF_NOOPT;
  if( find_option("invert",0,0)!=0 ) diffFlags |= DIFF_INVERT;
  if( find_option("brief",0,0)!=0 ) diffFlags |= DIFF_BRIEF;
  return diffFlags;
}

Changes to src/diffcmd.c.

1097
1098
1099
1100
1101
1102
1103

1104
1105
1106
1107
1108
1109
1110
**   --context|-c N         Use N lines of context
**   --diff-binary BOOL     Include binary files when using external commands
**   --from|-r VERSION      select VERSION as source for the diff
**   --ignore-space-at-eol  Ignore changes to end-of-line whitespace
**   --ignore-space-at-sol  Ignore changes to start-of-line whitespace
**   --internal|-i          use internal diff logic
**   --side-by-side|-y      side-by-side diff

**   --tk                   Launch a Tcl/Tk GUI for display
**   --to VERSION           select VERSION as target for the diff
**   --unified              unified diff
**   -v|--verbose           output complete text of added or deleted files
**   -w                     Ignore changes to start-of-line and end-of-line
**                          whitespace
**   -W|--width             Width of lines in side-by-side diff







>







1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
**   --context|-c N         Use N lines of context
**   --diff-binary BOOL     Include binary files when using external commands
**   --from|-r VERSION      select VERSION as source for the diff
**   --ignore-space-at-eol  Ignore changes to end-of-line whitespace
**   --ignore-space-at-sol  Ignore changes to start-of-line whitespace
**   --internal|-i          use internal diff logic
**   --side-by-side|-y      side-by-side diff
**   --strip-trailing-cr    Strip trailing CR
**   --tk                   Launch a Tcl/Tk GUI for display
**   --to VERSION           select VERSION as target for the diff
**   --unified              unified diff
**   -v|--verbose           output complete text of added or deleted files
**   -w                     Ignore changes to start-of-line and end-of-line
**                          whitespace
**   -W|--width             Width of lines in side-by-side diff