Fossil

Check-in [2dffb0e0]
Login

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

Overview
Comment: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.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | diff-eolws
Files: files | file ages | folders
SHA1:2dffb0e0262ace15f9a6d70ee80f10abc545d8f3
User & Date: jan.nijtmans 2014-03-03 10:15:38
Context
2014-03-03
10:28
Wrong parameter type: should be 64 bits otherwise the diffFlags parameter cannot hold all possible bits. check-in: d3f69bd4 user: jan.nijtmans tags: diff-eolws
10:15
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. check-in: 2dffb0e0 user: jan.nijtmans tags: diff-eolws
09:31
Rename --ignore-space-at-eol to --ignore-eolws|-w, make it work with "fossil stash diff" as well, and make it the default with "fossil diff --tk".

Remark: renaming probably was a bad idea, and "-w" should correspond with git's "--ignore-all-space". This would suggest implementing a "--ignore-space-at-sol" options as well, even though I doubt anyone would use that. check-in: 31d25923 user: jan.nijtmans tags: diff-eolws

Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/diff.c.

126
127
128
129
130
131
132
133
134
135
136

137
138
139
140
141
142
143
....
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
....
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
....
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
....
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
....
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
**
** Return 0 if the file is binary or contains a line that is
** too long.
**
** Profiling show that in most cases this routine consumes the bulk of
** the CPU time on a diff.
*/
static DLine *break_into_lines(const char *z, int n, int *pnLine, int ignoreWS){
  int nLine, i, j, k, x;
  unsigned int h, h2;
  DLine *a;


  /* Count the number of lines.  Allocate space to hold
  ** the returned array.
  */
  for(i=j=0, nLine=1; i<n; i++, j++){
    int c = z[i];
    if( c==0 ){
................................................................................
  ignoreEolWs = (diffFlags & DIFF_IGNORE_EOLWS)!=0;
  blob_to_utf8_no_bom(pA_Blob, 0);
  blob_to_utf8_no_bom(pB_Blob, 0);

  /* Prepare the input files */
  memset(&c, 0, sizeof(c));
  c.aFrom = break_into_lines(blob_str(pA_Blob), blob_size(pA_Blob),
                             &c.nFrom, ignoreEolWs);
  c.aTo = break_into_lines(blob_str(pB_Blob), blob_size(pB_Blob),
                           &c.nTo, ignoreEolWs);
  if( c.aFrom==0 || c.aTo==0 ){
    fossil_free(c.aFrom);
    fossil_free(c.aTo);
    if( pOut ){
      diff_errmsg(pOut, DIFF_CANNOT_COMPUTE_BINARY, diffFlags);
    }
    return 0;
................................................................................
** Process diff-related command-line options and return an appropriate
** "diffFlags" integer.
**
**   --brief                Show filenames only    DIFF_BRIEF
**   --context|-c N         N lines of context.    DIFF_CONTEXT_MASK
**   --html                 Format for HTML        DIFF_HTML
**   --invert               Invert the diff        DIFF_INVERT
**   --ignore-eolws|-w      Ignore eol-whitespaces DIFF_IGNORE_EOLWS
**   --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
**   --width|-W N           N character lines.     DIFF_WIDTH_MASK
*/
u64 diff_options(void){
................................................................................
  }
  if( (z = find_option("width","W",1))!=0 && (f = atoi(z))>0 ){
    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-eolws","w",0)!=0 ) diffFlags |= DIFF_IGNORE_EOLWS;
  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;
}

................................................................................
** to be annotated.  The annotator takes control of the input Blob and
** will release it when it is finished with it.
*/
static int annotation_start(Annotator *p, Blob *pInput){
  int i;

  memset(p, 0, sizeof(*p));
  p->c.aTo = break_into_lines(blob_str(pInput), blob_size(pInput),&p->c.nTo,1);
  if( p->c.aTo==0 ){
    return 1;
  }
  p->aOrig = fossil_malloc( sizeof(p->aOrig[0])*p->c.nTo );
  for(i=0; i<p->c.nTo; i++){
    p->aOrig[i].z = p->c.aTo[i].z;
    p->aOrig[i].n = p->c.aTo[i].h & LENGTH_MASK;
................................................................................
*/
static int annotation_step(Annotator *p, Blob *pParent, int iVers){
  int i, j;
  int lnTo;

  /* Prepare the parent file to be diffed */
  p->c.aFrom = break_into_lines(blob_str(pParent), blob_size(pParent),
                                &p->c.nFrom, 1);
  if( p->c.aFrom==0 ){
    return 1;
  }

  /* Compute the differences going from pParent to the file being
  ** annotated. */
  diff_all(&p->c);







|



>







 







|

|







 







|







 







|







 







|







 







|







126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
....
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
....
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
....
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
....
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
....
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
**
** Return 0 if the file is binary or contains a line that is
** too long.
**
** Profiling show that in most cases this routine consumes the bulk of
** the CPU time on a diff.
*/
static DLine *break_into_lines(const char *z, int n, int *pnLine, int diffFlags){
  int nLine, i, j, k, x;
  unsigned int h, h2;
  DLine *a;
  int ignoreWS = diffFlags & DIFF_IGNORE_EOLWS;

  /* Count the number of lines.  Allocate space to hold
  ** the returned array.
  */
  for(i=j=0, nLine=1; i<n; i++, j++){
    int c = z[i];
    if( c==0 ){
................................................................................
  ignoreEolWs = (diffFlags & DIFF_IGNORE_EOLWS)!=0;
  blob_to_utf8_no_bom(pA_Blob, 0);
  blob_to_utf8_no_bom(pB_Blob, 0);

  /* Prepare the input files */
  memset(&c, 0, sizeof(c));
  c.aFrom = break_into_lines(blob_str(pA_Blob), blob_size(pA_Blob),
                             &c.nFrom, diffFlags);
  c.aTo = break_into_lines(blob_str(pB_Blob), blob_size(pB_Blob),
                           &c.nTo, diffFlags);
  if( c.aFrom==0 || c.aTo==0 ){
    fossil_free(c.aFrom);
    fossil_free(c.aTo);
    if( pOut ){
      diff_errmsg(pOut, DIFF_CANNOT_COMPUTE_BINARY, diffFlags);
    }
    return 0;
................................................................................
** Process diff-related command-line options and return an appropriate
** "diffFlags" integer.
**
**   --brief                Show filenames only    DIFF_BRIEF
**   --context|-c N         N lines of context.    DIFF_CONTEXT_MASK
**   --html                 Format for HTML        DIFF_HTML
**   --invert               Invert the diff        DIFF_INVERT
**   --ignore-space-at-eol  Ignore eol-whitespaces DIFF_IGNORE_EOLWS
**   --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
**   --width|-W N           N character lines.     DIFF_WIDTH_MASK
*/
u64 diff_options(void){
................................................................................
  }
  if( (z = find_option("width","W",1))!=0 && (f = atoi(z))>0 ){
    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-eol","w",0)!=0 ) diffFlags |= DIFF_IGNORE_EOLWS;
  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;
}

................................................................................
** to be annotated.  The annotator takes control of the input Blob and
** will release it when it is finished with it.
*/
static int annotation_start(Annotator *p, Blob *pInput){
  int i;

  memset(p, 0, sizeof(*p));
  p->c.aTo = break_into_lines(blob_str(pInput), blob_size(pInput),&p->c.nTo,DIFF_IGNORE_EOLWS);
  if( p->c.aTo==0 ){
    return 1;
  }
  p->aOrig = fossil_malloc( sizeof(p->aOrig[0])*p->c.nTo );
  for(i=0; i<p->c.nTo; i++){
    p->aOrig[i].z = p->c.aTo[i].z;
    p->aOrig[i].n = p->c.aTo[i].h & LENGTH_MASK;
................................................................................
*/
static int annotation_step(Annotator *p, Blob *pParent, int iVers){
  int i, j;
  int lnTo;

  /* Prepare the parent file to be diffed */
  p->c.aFrom = break_into_lines(blob_str(pParent), blob_size(pParent),
                                &p->c.nFrom, DIFF_IGNORE_EOLWS);
  if( p->c.aFrom==0 ){
    return 1;
  }

  /* Compute the differences going from pParent to the file being
  ** annotated. */
  diff_all(&p->c);

Changes to src/diffcmd.c.

1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
** Options:
**   --binary PATTERN       Treat files that match the glob PATTERN as binary
**   --branch BRANCH        Show diff of all changes on BRANCH
**   --brief                Show filenames only
**   --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-eolws|-w      Ignore changes to end-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|--width             Width of lines in side-by-side diff







|







1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
** Options:
**   --binary PATTERN       Treat files that match the glob PATTERN as binary
**   --branch BRANCH        Show diff of all changes on BRANCH
**   --brief                Show filenames only
**   --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
**   --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|--width             Width of lines in side-by-side diff