Fossil

Changes On Branch delta-fix
Login

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

Changes In Branch delta-fix Excluding Merge-Ins

This is equivalent to a diff from 5493cc7bb5 to ec5e2919a7

2024-11-18
17:50
Fix the checksum function in the delta logic. check-in: 4862fc5ed0 user: drh tags: trunk
17:40
Fix the checksum routine in the delta logic so that it works correctly even if the input size is zero. Closed-Leaf check-in: ec5e2919a7 user: drh tags: delta-fix
2024-11-15
14:14
Add the ability to show the difference between two SQLite database files. Closed-Leaf check-in: 27c81f1c22 user: drh tags: sqldiff
13:51
Update the built-in SQLite to the latest 3.48.0 alpha - mostly to get rid of the #line macros in sqlite3.c that were somehow introduced in the previous update. check-in: 5493cc7bb5 user: drh tags: trunk
2024-11-13
11:23
Change the /setup_ulist page to show the most recently changed users first by default, as that seems to be the most common use case. check-in: 7b0a237895 user: drh tags: trunk

Changes to src/delta.c.

223
224
225
226
227
228
229
230
231


232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
















































279
280
281
282
283
284
285
223
224
225
226
227
228
229

230
231
232















































233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287







-

+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







** buffer is not a multiple of 4 bytes length, compute the sum that would
** have occurred if the buffer was padded with zeros to the next multiple
** of four bytes.
*/
static unsigned int checksum(const char *zIn, size_t N){
  static const int byteOrderTest = 1;
  const unsigned char *z = (const unsigned char *)zIn;
  const unsigned char *zEnd = (const unsigned char*)&zIn[N&~3];
  unsigned sum = 0;
  if( N>0 ){
    const unsigned char *zEnd = (const unsigned char*)&zIn[N&~3];
  assert( (z - (const unsigned char*)0)%4==0 );  /* Four-byte alignment */
  if( 0==*(char*)&byteOrderTest ){
    /* This is a big-endian machine */
    while( z<zEnd ){
      sum += *(unsigned*)z;
      z += 4;
    }
  }else{
    /* A little-endian machine */
#if GCC_VERSION>=4003000
    while( z<zEnd ){
      sum += __builtin_bswap32(*(unsigned*)z);
      z += 4;
    }
#elif defined(_MSC_VER) && _MSC_VER>=1300
    while( z<zEnd ){
      sum += _byteswap_ulong(*(unsigned*)z);
      z += 4;
    }
#else
    unsigned sum0 = 0;
    unsigned sum1 = 0;
    unsigned sum2 = 0;
    while(N >= 16){
      sum0 += ((unsigned)z[0] + z[4] + z[8] + z[12]);
      sum1 += ((unsigned)z[1] + z[5] + z[9] + z[13]);
      sum2 += ((unsigned)z[2] + z[6] + z[10]+ z[14]);
      sum  += ((unsigned)z[3] + z[7] + z[11]+ z[15]);
      z += 16;
      N -= 16;
    }
    while(N >= 4){
      sum0 += z[0];
      sum1 += z[1];
      sum2 += z[2];
      sum  += z[3];
      z += 4;
      N -= 4;
    }
    sum += (sum2 << 8) + (sum1 << 16) + (sum0 << 24);
#endif
  }
  switch(N&3){
    case 3:   sum += (z[2] << 8);
    case 2:   sum += (z[1] << 16);
    case 1:   sum += (z[0] << 24);
    default:  ;
    assert( (z - (const unsigned char*)0)%4==0 );  /* Four-byte alignment */
    if( 0==*(char*)&byteOrderTest ){
      /* This is a big-endian machine */
      while( z<zEnd ){
        sum += *(unsigned*)z;
        z += 4;
      }
    }else{
      /* A little-endian machine */
  #if GCC_VERSION>=4003000
      while( z<zEnd ){
        sum += __builtin_bswap32(*(unsigned*)z);
        z += 4;
      }
  #elif defined(_MSC_VER) && _MSC_VER>=1300
      while( z<zEnd ){
        sum += _byteswap_ulong(*(unsigned*)z);
        z += 4;
      }
  #else
      unsigned sum0 = 0;
      unsigned sum1 = 0;
      unsigned sum2 = 0;
      while(N >= 16){
        sum0 += ((unsigned)z[0] + z[4] + z[8] + z[12]);
        sum1 += ((unsigned)z[1] + z[5] + z[9] + z[13]);
        sum2 += ((unsigned)z[2] + z[6] + z[10]+ z[14]);
        sum  += ((unsigned)z[3] + z[7] + z[11]+ z[15]);
        z += 16;
        N -= 16;
      }
      while(N >= 4){
        sum0 += z[0];
        sum1 += z[1];
        sum2 += z[2];
        sum  += z[3];
        z += 4;
        N -= 4;
      }
      sum += (sum2 << 8) + (sum1 << 16) + (sum0 << 24);
  #endif
    }
    switch(N&3){
      case 3:   sum += (z[2] << 8);
      case 2:   sum += (z[1] << 16);
      case 1:   sum += (z[0] << 24);
      default:  ;
    }
  }
  return sum;
}

/*
** Create a new delta.
**