/ Check-in [564c7340]
Login

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

Overview
Comment:Less dramatic changes to the source-id following an edit. Modify the way that the amalgamation is constructed to give it the opportunity to detect changes and modify the source-id.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 564c7340a3368501c3da885afde52123ed7f558801f6190cbe6173dfe9704b70
User & Date: drh 2017-08-22 21:07:03
Context
2017-08-22
21:23
Update documentation to make it clear that SQLITE_SOURCE_ID and sqlite3_sourceid() might changes if the source code is edited. check-in: e69c0c87 user: drh tags: trunk
21:07
Less dramatic changes to the source-id following an edit. Modify the way that the amalgamation is constructed to give it the opportunity to detect changes and modify the source-id. check-in: 564c7340 user: drh tags: trunk
19:54
Modify the SQLITE_SOURCE_ID if the source code has changed in any way since the previous check-in. check-in: 515d6a83 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/shell.c.

8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033

  setBinaryMode(stdin, 0);
  setvbuf(stderr, 0, _IONBF, 0); /* Make sure stderr is unbuffered */
  stdin_is_interactive = isatty(0);
  stdout_is_console = isatty(1);

#if USE_SYSTEM_SQLITE+0!=1
  if( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)!=0 ){
    utf8_printf(stderr, "SQLite header and source version mismatch\n%s\n%s\n",
            sqlite3_sourceid(), SQLITE_SOURCE_ID);
    exit(1);
  }
#endif
  main_init(&data);
#if !SQLITE_SHELL_IS_UTF8







|







8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033

  setBinaryMode(stdin, 0);
  setvbuf(stderr, 0, _IONBF, 0); /* Make sure stderr is unbuffered */
  stdin_is_interactive = isatty(0);
  stdout_is_console = isatty(1);

#if USE_SYSTEM_SQLITE+0!=1
  if( strncmp(sqlite3_sourceid(),SQLITE_SOURCE_ID,60)!=0 ){
    utf8_printf(stderr, "SQLite header and source version mismatch\n%s\n%s\n",
            sqlite3_sourceid(), SQLITE_SOURCE_ID);
    exit(1);
  }
#endif
  main_init(&data);
#if !SQLITE_SHELL_IS_UTF8

Changes to tool/mksourceid.c.

3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
...
840
841
842
843
844
845
846
847
848
849
850
851
852
** Fossil "manifest" file for a project, and this program will emit on
** standard output the "source id" for for the program.
**
** (1)  The "source id" is the date of check-in together with the 
**      SHA3 hash of the manifest file.
**
** (2)  All individual file hashes in the manifest are verified.  If any
**      source file has changed, the SHA3 hash ends with "-modified".
**
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <ctype.h>
................................................................................
        }
      }
    }
  }
  fclose(in);
  sha3sum_file(zManifest, 256, zHash);
  if( !allValid ){
    printf("%s %.55s-modified\n", zDate, zHash);
  }else{
    printf("%s %s\n", zDate, zHash);
  }
  return 0;
}







|







 







|





3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
...
840
841
842
843
844
845
846
847
848
849
850
851
852
** Fossil "manifest" file for a project, and this program will emit on
** standard output the "source id" for for the program.
**
** (1)  The "source id" is the date of check-in together with the 
**      SHA3 hash of the manifest file.
**
** (2)  All individual file hashes in the manifest are verified.  If any
**      source file has changed, the SHA3 hash ends with "modified".
**
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <ctype.h>
................................................................................
        }
      }
    }
  }
  fclose(in);
  sha3sum_file(zManifest, 256, zHash);
  if( !allValid ){
    printf("%s %.60salt1\n", zDate, zHash);
  }else{
    printf("%s %s\n", zDate, zHash);
  }
  return 0;
}

Changes to tool/mksqlite3c.tcl.

238
239
240
241
242
243
244





245

246
247
248
249
250
251
252
...
392
393
394
395
396
397
398






























399
            if {[lsearch -exact $cdecllist $funcname] >= 0} {
              append line SQLITE_CDECL " "
            } else {
              append line SQLITE_APICALL " "
            }
          }
          append line $funcname $rest





          puts $out $line

        } else {
          puts $out "SQLITE_PRIVATE $line"
        }
      } elseif {[regexp $varpattern $line all varname]} {
          # Add the SQLITE_PRIVATE before variable declarations or
          # definitions for internal use
          regsub {^SQLITE_API } $line {} line
................................................................................
   json1.c
   fts5.c
   stmt.c
} {
  copy_file tsrc/$file
}































close $out







>
>
>
>
>
|
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
...
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
            if {[lsearch -exact $cdecllist $funcname] >= 0} {
              append line SQLITE_CDECL " "
            } else {
              append line SQLITE_APICALL " "
            }
          }
          append line $funcname $rest
          if {$funcname=="sqlite3_sourceid" && !$linemacros} {
            # The sqlite3_sourceid() routine is synthesized at the end of
            # the amalgamation
            puts $out "/* $line */"
          } else {
            puts $out $line
          }
        } else {
          puts $out "SQLITE_PRIVATE $line"
        }
      } elseif {[regexp $varpattern $line all varname]} {
          # Add the SQLITE_PRIVATE before variable declarations or
          # definitions for internal use
          regsub {^SQLITE_API } $line {} line
................................................................................
   json1.c
   fts5.c
   stmt.c
} {
  copy_file tsrc/$file
}

# Synthesize an alternative sqlite3_sourceid() implementation that
# that tries to detects changes in the amalgamation source text
# and modify returns a modified source-id if changes are detected.
#
# The only detection mechanism we have is the __LINE__ macro.  So only
# edits that changes the number of lines of source code are detected.
#
if {!$linemacros} {
  flush $out
  set in2 [open sqlite3.c]
  set cnt 0
  set oldsrcid {}
  while {![eof $in2]} {
    incr cnt
    gets $in2 line
    if {[regexp {^#define SQLITE_SOURCE_ID } $line]} {set oldsrcid $line}
  }
  close $in2
  regsub {[0-9a-flt]{4}"} $oldsrcid {alt2"} oldsrcid
  puts $out \
"#if __LINE__!=[expr {$cnt+0}]
#undef SQLITE_SOURCE_ID
$oldsrcid
#endif
/* Return the source-id for this library */
SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }"
}
puts $out \
"/************************** End of sqlite3.c ******************************/"

close $out