Fossil

Check-in [0e0e29ae]
Login

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

Overview
Comment:Detect binary files that look like text but end with a sequence of zeros.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 0e0e29aea0e11dd5546339ea59e954400196a136
User & Date: drh 2016-10-04 02:16:58
Context
2016-10-04
03:55
Return an error instead of silently ignoring invalid input. check-in: 274e537b user: andybradford tags: trunk
02:43
Adopt the diff algorithm changes from trunk. check-in: f9f2d769 user: mistachkin tags: binDiffFix
02:16
Detect binary files that look like text but end with a sequence of zeros. check-in: 0e0e29ae user: drh tags: trunk
02:02
The previous check-in was interpreting any file that did not end in \n as binary. This check-in should fix the problem. check-in: 47d1256c user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/diff.c.

147
148
149
150
151
152
153
154
155

156
157
158
159
160
161
162
  /* Count the number of lines in the input file.  Include the last line
  ** in the count even if it lacks the \n terminator
  */
  for(nLine=0, z2=z; (zNL = strchr(z2,'\n'))!=0; z2=zNL+1, nLine++){}
  if( z2[0]!=0 ){
    nLine++;
    do{ z2++; }while( z2[0] );
    if( n!=(int)(z2-z) ) return 0;
  }


  a = fossil_malloc( sizeof(a[0])*nLine );
  memset(a, 0, sizeof(a[0])*nLine);
  if( nLine==0 ){
    *pnLine = 0;
    return a;
  }







<

>







147
148
149
150
151
152
153

154
155
156
157
158
159
160
161
162
  /* Count the number of lines in the input file.  Include the last line
  ** in the count even if it lacks the \n terminator
  */
  for(nLine=0, z2=z; (zNL = strchr(z2,'\n'))!=0; z2=zNL+1, nLine++){}
  if( z2[0]!=0 ){
    nLine++;
    do{ z2++; }while( z2[0] );

  }
  if( n!=(int)(z2-z) ) return 0;

  a = fossil_malloc( sizeof(a[0])*nLine );
  memset(a, 0, sizeof(a[0])*nLine);
  if( nLine==0 ){
    *pnLine = 0;
    return a;
  }