Fossil

Check-in [7f788bdb]
Login

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

Overview
Comment:Change the built-in "diff" so that it no longer ignores whitespace at the end of lines, as doing so confuses the "patch" command. Ticket [a9f7b23c2e376af5b0]
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 7f788bdb045c8e149fec1ab7f36b9a3faee8e3f8
User & Date: drh 2010-08-21 03:33:06
Context
2010-08-21
04:06
The command-line "diff" does not ignore whitespace at the end of lines and it generates a well-formed patch file that can be fed directly into "patch -p 0". Ticket [a9f7b23c2e376af]. GUI diffs and the merge commands do ignore end-of-line whitespace. check-in: 5ef7435a user: drh tags: trunk
03:33
Change the built-in "diff" so that it no longer ignores whitespace at the end of lines, as doing so confuses the "patch" command. Ticket [a9f7b23c2e376af5b0] check-in: 7f788bdb user: drh tags: trunk
03:27
Fix a potential segfault in the graph generator when check-ins occur with time skew. check-in: 32c9c47c user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/diff.c.

63
64
65
66
67
68
69
70


71
72
73
74
75
76
77
...
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
};

/*
** Return an array of DLine objects containing a pointer to the
** start of each line and a hash of that line.  The lower 
** bits of the hash store the length of each line.
**
** Trailing whitespace is removed from each line.


**
** Return 0 if the file is binary or contains a line that is
** too long.
*/
static DLine *break_into_lines(const char *z, int n, int *pnLine){
  int nLine, i, j, k, x;
  unsigned int h, h2;
................................................................................
  if( a==0 ) fossil_panic("out of memory");
  memset(a, 0, nLine*sizeof(a[0]) );

  /* Fill in the array */
  for(i=0; i<nLine; i++){
    a[i].z = z;
    for(j=0; z[j] && z[j]!='\n'; j++){}
    for(k=j; k>0 && isspace(z[k-1]); k--){}
    for(h=0, x=0; x<k; x++){
      h = h ^ (h<<2) ^ z[x];
    }
    a[i].h = h = (h<<LENGTH_MASK_SZ) | k;;
    h2 = h % nLine;
    a[i].iNext = a[h2].iHash;
    a[h2].iHash = i+1;







|
>
>







 







|







63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
...
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
};

/*
** Return an array of DLine objects containing a pointer to the
** start of each line and a hash of that line.  The lower 
** bits of the hash store the length of each line.
**
** Trailing whitespace is removed from each line.  2010-08-20:  Not any
** more.  If trailing whitespace is ignored, the "patch" command gets
** confused by the diff output.  Ticket [a9f7b23c2e376af5b0e5b]
**
** Return 0 if the file is binary or contains a line that is
** too long.
*/
static DLine *break_into_lines(const char *z, int n, int *pnLine){
  int nLine, i, j, k, x;
  unsigned int h, h2;
................................................................................
  if( a==0 ) fossil_panic("out of memory");
  memset(a, 0, nLine*sizeof(a[0]) );

  /* Fill in the array */
  for(i=0; i<nLine; i++){
    a[i].z = z;
    for(j=0; z[j] && z[j]!='\n'; j++){}
    for(k=j; k>0 && isspace(z[k-1]); k--){break;}
    for(h=0, x=0; x<k; x++){
      h = h ^ (h<<2) ^ z[x];
    }
    a[i].h = h = (h<<LENGTH_MASK_SZ) | k;;
    h2 = h % nLine;
    a[i].iNext = a[h2].iHash;
    a[h2].iHash = i+1;