Fossil

Check-in [555c44eb]
Login

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

Overview
Comment:Merge changes from trunk and update msvc_build.bat for entirely automated build using the latest MSVC version.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | msvc_build
Files: files | file ages | folders
SHA1: 555c44eb5d9506e7d6377a567933b000f06dcb3f
User & Date: BM 2013-12-17 09:25:21
Context
2013-12-17
22:10
Improve error handling. Allow Visual Studio version to be manually overridden. Pass extra arguments to NMAKE. Preserve existing environment and current directory. Miscellaneous style fixes. check-in: 8fab3e3f user: mistachkin tags: buildmsvc
09:25
Merge changes from trunk and update msvc_build.bat for entirely automated build using the latest MSVC version. Closed-Leaf check-in: 555c44eb user: BM tags: msvc_build
06:04
Change the minimum length for wiki page names from 3 to 1. check-in: b7ff13a0 user: joel tags: trunk
2013-10-30
09:39
Added .bat for building with latest MSVC version check-in: 4f32dced user: BM tags: msvc_build
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to .fossil-settings/ignore-glob.

     1      1   compat/openssl*
     2      2   compat/tcl*
     3      3   fossil
     4      4   fossil.exe
            5  +win/fossil.exe

Changes to .fossil-settings/keep-glob.

     1      1   compat/openssl*
     2      2   compat/tcl*
     3      3   fossil
     4      4   fossil.exe
            5  +win/fossil.exe

Added Makefile.Cygwin.in.

            1  +#!/usr/bin/make
            2  +#
            3  +# This is the top-level makefile for Fossil when the build is occurring
            4  +# on the Cygwin platform.
            5  +#
            6  +#### The toplevel directory of the source tree.  Fossil can be built
            7  +#    in a directory that is separate from the source tree.  Just change
            8  +#    the following to point from the build directory to the src/ folder.
            9  +#
           10  +SRCDIR = @srcdir@/src
           11  +
           12  +#### The directory into which object code files should be written.
           13  +#    Having a "./" prefix in the value of this variable breaks our use of the
           14  +#    "makeheaders" tool when running make on the MinGW platform, apparently
           15  +#    due to some command line argument manipulation performed automatically
           16  +#    by the shell.
           17  +#
           18  +#
           19  +OBJDIR = bld
           20  +
           21  +#### C Compiler and options for use in building executables that
           22  +#    will run on the platform that is doing the build.  This is used
           23  +#    to compile code-generator programs as part of the build process.
           24  +#    See TCC below for the C compiler for building the finished binary.
           25  +#
           26  +BCC = @CC_FOR_BUILD@
           27  +
           28  +#### The suffix to add to final executable file.  When cross-compiling
           29  +#    to windows, make this ".exe".  Otherwise leave it blank.
           30  +#
           31  +E = @EXEEXT@
           32  +
           33  +TCC = @CC@
           34  +
           35  +#### Tcl shell for use in running the fossil testsuite.  If you do not
           36  +#    care about testing the end result, this can be blank.
           37  +#
           38  +TCLSH = tclsh
           39  +
           40  +LIB = @LDFLAGS@ @EXTRA_LDFLAGS@ @LIBS@
           41  +TCC += @EXTRA_CFLAGS@ @CPPFLAGS@ @CFLAGS@ -DHAVE_AUTOCONFIG_H
           42  +INSTALLDIR =$(DESTDIR)@prefix@/bin
           43  +USE_SYSTEM_SQLITE = @USE_SYSTEM_SQLITE@
           44  +FOSSIL_ENABLE_TCL = @FOSSIL_ENABLE_TCL@
           45  +FOSSIL_ENABLE_TCL_STUBS = @FOSSIL_ENABLE_TCL_STUBS@
           46  +FOSSIL_ENABLE_TCL_PRIVATE_STUBS = @FOSSIL_ENABLE_TCL_PRIVATE_STUBS@
           47  +SQLITE_CFLAGS += -DSQLITE_WIN32_NO_ANSI -DSQLITE_WINNT_MAX_PATH_CHARS=4096
           48  +
           49  +include $(SRCDIR)/main.mk
           50  +
           51  +distclean: clean
           52  +	rm -f autoconfig.h config.log Makefile

Changes to auto.def.

   255    255   if {![cc-check-functions getpassphrase]} {
   256    256       # Haiku needs this
   257    257       cc-check-function-in-lib getpass bsd
   258    258   }
   259    259   cc-check-function-in-lib dlopen dl
   260    260   
   261    261   make-template Makefile.in
          262  +make-template Makefile.Cygwin.in
   262    263   make-config-header autoconfig.h -auto {USE_* FOSSIL_*}

Changes to src/add.c.

   314    314   ** Options:
   315    315   **   --case-sensitive <BOOL> override case-sensitive setting
   316    316   **
   317    317   ** See also: addremove, add
   318    318   */
   319    319   void delete_cmd(void){
   320    320     int i;
   321         -  int vid;
   322    321     Stmt loop;
   323    322   
   324    323     capture_case_sensitive_option();
   325    324     db_must_be_within_tree();
   326         -  vid = db_lget_int("checkout", 0);
   327         -  if( vid==0 ){
   328         -    fossil_fatal("no checkout to remove from");
   329         -  }
   330    325     db_begin_transaction();
   331    326     db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
   332    327                   filename_collation());
   333    328     for(i=2; i<g.argc; i++){
   334    329       Blob treeName;
   335    330       char *zTreeName;
   336    331   
................................................................................
   551    546   /*
   552    547   ** Rename a single file.
   553    548   **
   554    549   ** The original name of the file is zOrig.  The new filename is zNew.
   555    550   */
   556    551   static void mv_one_file(int vid, const char *zOrig, const char *zNew){
   557    552     int x = db_int(-1, "SELECT deleted FROM vfile WHERE pathname=%Q %s",
   558         -		         zNew, filename_collation());
          553  +                         zNew, filename_collation());
   559    554     if( x>=0 ){
   560    555       if( x==0 ){
   561    556         fossil_fatal("cannot rename '%s' to '%s' since another file named '%s'"
   562    557                      " is currently under management", zOrig, zNew, zNew); 
   563    558       }else{
   564    559         fossil_fatal("cannot rename '%s' to '%s' since the delete of '%s' has "
   565    560                      "not yet been committed", zOrig, zNew, zNew);

Changes to src/allrepo.c.

   139    139     char *zQFilename;
   140    140     Blob extra;
   141    141     int useCheckouts = 0;
   142    142     int quiet = 0;
   143    143     int dryRunFlag = 0;
   144    144     int stopOnError = find_option("dontstop",0,0)==0;
   145    145     int rc;
   146         -  Bag outOfDate;
          146  +  int nToDel = 0;
   147    147     
   148    148     dryRunFlag = find_option("dry-run","n",0)!=0;
   149    149     if( !dryRunFlag ){
   150    150       dryRunFlag = find_option("test",0,0)!=0; /* deprecated */
   151    151     }
   152    152   
   153    153     if( g.argc<3 ){
................................................................................
   241    241       fossil_fatal("\"all\" subcommand should be one of: "
   242    242                    "changes clean extra ignore list ls push pull rebuild sync");
   243    243     }
   244    244     verify_all_options();
   245    245     zFossil = quoteFilename(g.nameOfExe);
   246    246     if( useCheckouts ){
   247    247       db_prepare(&q,
   248         -       "SELECT substr(name, 7) COLLATE nocase, max(rowid)"
          248  +       "SELECT DISTINCT substr(name, 7), name COLLATE nocase"
   249    249          "  FROM global_config"
   250    250          " WHERE substr(name, 1, 6)=='ckout:'"
   251         -       " GROUP BY 1 ORDER BY 1"
          251  +       " ORDER BY 1"
   252    252       );
   253    253     }else{
   254    254       db_prepare(&q,
   255         -       "SELECT substr(name, 6) COLLATE nocase, max(rowid)"
          255  +       "SELECT DISTINCT substr(name, 6), name COLLATE nocase"
   256    256          "  FROM global_config"
   257    257          " WHERE substr(name, 1, 5)=='repo:'"
   258         -       " GROUP BY 1 ORDER BY 1"
          258  +       " ORDER BY 1"
   259    259       );
   260    260     }
   261         -  bag_init(&outOfDate);
          261  +  db_multi_exec("CREATE TEMP TABLE todel(x TEXT)");
   262    262     while( db_step(&q)==SQLITE_ROW ){
   263    263       const char *zFilename = db_column_text(&q, 0);
   264         -    int rowid = db_column_int(&q, 1);
   265         -    if( file_access(zFilename, 0) || !file_is_canonical(zFilename) ){
   266         -      bag_insert(&outOfDate, rowid);
   267         -      continue;
   268         -    }
   269         -    if( useCheckouts && file_isdir(zFilename)!=1 ){
   270         -      bag_insert(&outOfDate, rowid);
          264  +    if( file_access(zFilename, 0)
          265  +     || !file_is_canonical(zFilename)
          266  +     || (useCheckouts && file_isdir(zFilename)!=1)
          267  +    ){
          268  +      db_multi_exec("INSERT INTO todel VALUES(%Q)", db_column_text(&q, 1));
          269  +      nToDel++;
   271    270         continue;
   272    271       }
   273    272       if( zCmd[0]=='l' ){
   274    273         fossil_print("%s\n", zFilename);
   275    274         continue;
   276    275       }
   277    276       zQFilename = quoteFilename(zFilename);
................................................................................
   289    288       }
   290    289     }
   291    290     db_finalize(&q);
   292    291     
   293    292     /* If any repositories whose names appear in the ~/.fossil file could not
   294    293     ** be found, remove those names from the ~/.fossil file.
   295    294     */
   296         -  if( bag_count(&outOfDate)>0 ){
   297         -    Blob sql;
   298         -    char *zSep = "(";
   299         -    int rowid;
   300         -    blob_zero(&sql);
   301         -    blob_appendf(&sql, "DELETE FROM global_config WHERE rowid IN ");
   302         -    for(rowid=bag_first(&outOfDate); rowid>0; rowid=bag_next(&outOfDate,rowid)){
   303         -      blob_appendf(&sql, "%s%d", zSep, rowid);
   304         -      zSep = ",";
   305         -    }
   306         -    blob_appendf(&sql, ")");
          295  +  if( nToDel>0 ){
          296  +    const char *zSql = "DELETE FROM global_config WHERE name IN toDel";
   307    297       if( dryRunFlag ){
   308         -      fossil_print("%s\n", blob_str(&sql));
          298  +      fossil_print("%s\n", zSql);
   309    299       }else{
   310         -      db_multi_exec(blob_str(&sql));
          300  +      db_multi_exec(zSql);
   311    301       }
   312         -    blob_reset(&sql);
   313    302     }
   314    303   }

Changes to src/clone.c.

   103    103   **
   104    104   ** By default, your current login name is used to create the default
   105    105   ** admin user. This can be overridden using the -A|--admin-user
   106    106   ** parameter.
   107    107   **
   108    108   ** Options:
   109    109   **    --admin-user|-A USERNAME   Make USERNAME the administrator
          110  +**    --once                     Don't save url.
   110    111   **    --private                  Also clone private branches 
   111    112   **    --ssl-identity=filename    Use the SSL identity if requested by the server
   112    113   **    --ssh-command|-c 'command' Use this SSH command
   113    114   **
   114    115   ** See also: init
   115    116   */
   116    117   void clone_cmd(void){
   117    118     char *zPassword;
   118    119     const char *zDefaultUser;   /* Optional name of the default user */
   119    120     int nErr = 0;
   120    121     int bPrivate = 0;           /* Also clone private branches */
          122  +  int urlFlags = URL_PROMPT_PW | URL_REMEMBER;
   121    123   
   122    124     if( find_option("private",0,0)!=0 ) bPrivate = SYNC_PRIVATE;
          125  +  if( find_option("once",0,0)!=0) urlFlags &= ~URL_REMEMBER;
          126  +  zDefaultUser = find_option("admin-user","A",1);
   123    127     clone_ssh_find_options();
   124    128     url_proxy_options();
   125    129     if( g.argc < 4 ){
   126    130       usage("?OPTIONS? FILE-OR-URL NEW-REPOSITORY");
   127    131     }
   128    132     db_open_config(0);
   129    133     if( file_size(g.argv[3])>0 ){
   130    134       fossil_fatal("file already exists: %s", g.argv[3]);
   131    135     }
   132    136   
   133         -  zDefaultUser = find_option("admin-user","A",1);
   134         -
   135         -  url_parse(g.argv[2], URL_PROMPT_PW|URL_ASK_REMEMBER_PW);
          137  +  url_parse(g.argv[2], urlFlags);
   136    138     if( zDefaultUser==0 && g.urlUser!=0 ) zDefaultUser = g.urlUser;
   137    139     if( g.urlIsFile ){
   138    140       file_copy(g.urlName, g.argv[3]);
   139    141       db_close(1);
   140    142       db_open_repository(g.argv[3]);
   141    143       db_record_repository_filename(g.argv[3]);
   142    144       url_remember();
................................................................................
   154    156       db_open_repository(g.argv[3]);
   155    157       db_begin_transaction();
   156    158       db_record_repository_filename(g.argv[3]);
   157    159       db_initial_setup(0, 0, zDefaultUser, 0);
   158    160       user_select();
   159    161       db_set("content-schema", CONTENT_SCHEMA, 0);
   160    162       db_set("aux-schema", AUX_SCHEMA, 0);
          163  +    db_set("rebuilt", get_version(), 0);
   161    164       url_remember();
   162    165       if( g.zSSLIdentity!=0 ){
   163    166         /* If the --ssl-identity option was specified, store it as a setting */
   164    167         Blob fn;
   165    168         blob_zero(&fn);
   166    169         file_canonical_name(g.zSSLIdentity, &fn, 0);
   167    170         db_set("ssl-identity", blob_str(&fn), 0);

Changes to src/configure.c.

   398    398       @ DELETE FROM reportfmt;
   399    399       @ INSERT INTO reportfmt SELECT * FROM _xfer_reportfmt;
   400    400       @ DROP TABLE _xfer_user;
   401    401       @ DROP TABLE _xfer_reportfmt;
   402    402     ;
   403    403     db_multi_exec(zSQL);
   404    404   }
          405  +
          406  +/*
          407  +** Mask of modified configuration sets
          408  +*/
          409  +static int rebuildMask = 0;
          410  +
          411  +/*
          412  +** Rebuild auxiliary tables as required by configuration changes.
          413  +*/
          414  +void configure_rebuild(void){
          415  +  if( rebuildMask & CONFIGSET_TKT ){
          416  +    ticket_rebuild();
          417  +  }
          418  +  rebuildMask = 0;
          419  +}
   405    420   
   406    421   /*
   407    422   ** Return true if z[] is not a "safe" SQL token.  A safe token is one of:
   408    423   **
   409    424   **   *   A string literal
   410    425   **   *   A blob literal
   411    426   **   *   An integer literal  (no floating point)
................................................................................
   564    579           blob_appendf(&sql, ", %s=%s", azToken[jj], azToken[jj+1]);
   565    580         }
   566    581         blob_appendf(&sql, " WHERE %s=%s AND mtime<%s",
   567    582                      aType[ii].zPrimKey, azToken[1], azToken[0]);
   568    583         db_multi_exec("%s", blob_str(&sql));
   569    584       }
   570    585       blob_reset(&sql);
          586  +    rebuildMask |= thisMask;
   571    587     }else{
   572    588       /* Otherwise, the old format */
   573    589       if( (configure_is_exportable(zName) & groupMask)==0 ) return;
   574    590       if( fossil_strcmp(zName, "logo-image")==0 ){
   575    591         Stmt ins;
   576    592         db_prepare(&ins,
   577    593           "REPLACE INTO config(name, value, mtime) VALUES(:name, :value, now())"
................................................................................
   946    962           db_multi_exec(zRepositorySchemaDefaultReports);
   947    963         }
   948    964       }
   949    965       db_end_transaction(0);
   950    966       fossil_print("Configuration reset to factory defaults.\n");
   951    967       fossil_print("To recover, use:  %s %s import %s\n",
   952    968               g.argv[0], g.argv[1], zBackup);
          969  +    rebuildMask |= mask;
   953    970     }else
   954    971     {
   955    972       fossil_fatal("METHOD should be one of:"
   956    973                    " export import merge pull push reset");
   957    974     }
          975  +  configure_rebuild();
   958    976   }

Changes to src/db.c.

   707    707   
   708    708   /*
   709    709   ** Open a database file.  Return a pointer to the new database
   710    710   ** connection.  An error results in process abort.
   711    711   */
   712    712   LOCAL sqlite3 *db_open(const char *zDbName){
   713    713     int rc;
   714         -  const char *zVfs;
   715    714     sqlite3 *db;
   716    715   
   717    716   #if defined(__CYGWIN__)
   718    717     zDbName = fossil_utf8_to_filename(zDbName);
   719    718   #endif
   720    719     if( g.fSqlTrace ) fossil_trace("-- sqlite3_open: [%s]\n", zDbName);
   721         -  zVfs = fossil_getenv("FOSSIL_VFS");
   722    720     rc = sqlite3_open_v2(
   723    721          zDbName, &db,
   724    722          SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
   725         -       zVfs
          723  +       g.zVfsName
   726    724     );
   727    725     if( rc!=SQLITE_OK ){
   728    726       db_err("[%s]: %s", zDbName, sqlite3_errmsg(db));
   729    727     }
   730    728     sqlite3_busy_timeout(db, 5000);
   731    729     sqlite3_wal_autocheckpoint(db, 1);  /* Set to checkpoint frequently */
   732    730     sqlite3_create_function(db, "now", 0, SQLITE_ANY, 0, db_now_function, 0, 0);
................................................................................
  1338   1336   ){
  1339   1337     char *zDate;
  1340   1338     Blob hash;
  1341   1339     Blob manifest;
  1342   1340   
  1343   1341     db_set("content-schema", CONTENT_SCHEMA, 0);
  1344   1342     db_set("aux-schema", AUX_SCHEMA, 0);
         1343  +  db_set("rebuilt", get_version(), 0);
  1345   1344     if( makeServerCodes ){
  1346   1345       db_multi_exec(
  1347   1346         "INSERT INTO config(name,value,mtime)"
  1348   1347         " VALUES('server-code', lower(hex(randomblob(20))),now());"
  1349   1348         "INSERT INTO config(name,value,mtime)"
  1350   1349         " VALUES('project-code', lower(hex(randomblob(20))),now());"
  1351   1350       );
................................................................................
  1363   1362       /*
  1364   1363       ** Copy all settings from the supplied template repository.
  1365   1364       */
  1366   1365       db_multi_exec(
  1367   1366         "INSERT OR REPLACE INTO config"
  1368   1367         " SELECT name,value,mtime FROM settingSrc.config"
  1369   1368         "  WHERE (name IN %s OR name IN %s)"
  1370         -      "    AND name NOT GLOB 'project-*';",
         1369  +      "    AND name NOT GLOB 'project-*'"
         1370  +      "    AND name NOT GLOB 'short-project-*';",
  1371   1371         configure_inop_rhs(CONFIGSET_ALL),
  1372   1372         db_setting_inop_rhs()
  1373   1373       );
  1374   1374       db_multi_exec(
  1375   1375         "REPLACE INTO reportfmt SELECT * FROM settingSrc.reportfmt;"
  1376   1376       );
  1377   1377   
................................................................................
  1796   1796       ** checked out file */
  1797   1797       z = db_get_do_versionable(zName, z);
  1798   1798     }
  1799   1799     if( z==0 ){
  1800   1800       z = zDefault;
  1801   1801     }
  1802   1802     return z;
         1803  +}
         1804  +char *db_get_mtime(const char *zName, char *zFormat, char *zDefault){
         1805  +  char *z = 0;
         1806  +  if( g.repositoryOpen ){
         1807  +    z = db_text(0, "SELECT mtime FROM config WHERE name=%Q", zName);
         1808  +  }
         1809  +  if( z==0 ){
         1810  +    z = zDefault;
         1811  +  }else if( zFormat!=0 ){
         1812  +    z = db_text(0, "SELECT strftime(%Q,%Q,'unixepoch');", zFormat, z);
         1813  +  }
         1814  +  return z;
  1803   1815   }
  1804   1816   void db_set(const char *zName, const char *zValue, int globalFlag){
  1805   1817     db_begin_transaction();
  1806   1818     if( globalFlag ){
  1807   1819       db_swap_connections();
  1808   1820       db_multi_exec("REPLACE INTO global_config(name,value) VALUES(%Q,%Q)",
  1809   1821                      zName, zValue);
................................................................................
  1980   1992   ** Options:
  1981   1993   **   --keep     Only modify the manifest and manifest.uuid files
  1982   1994   **   --nested   Allow opening a repository inside an opened checkout
  1983   1995   **
  1984   1996   ** See also: close
  1985   1997   */
  1986   1998   void cmd_open(void){
  1987         -  int vid;
  1988   1999     int keepFlag;
  1989   2000     int allowNested;
         2001  +  char **oldArgv;
         2002  +  int oldArgc;
  1990   2003     static char *azNewArgv[] = { 0, "checkout", "--prompt", 0, 0, 0 };
  1991   2004   
  1992   2005     url_proxy_options();
  1993   2006     keepFlag = find_option("keep",0,0)!=0;
  1994   2007     allowNested = find_option("nested",0,0)!=0;
  1995   2008     if( g.argc!=3 && g.argc!=4 ){
  1996   2009       usage("REPOSITORY-FILENAME ?VERSION?");
................................................................................
  2009   2022                      "COMMIT; PRAGMA journal_mode=WAL; BEGIN;",
  2010   2023   #endif
  2011   2024                      (char*)0);
  2012   2025     db_delete_on_failure(LOCALDB_NAME);
  2013   2026     db_open_local(0);
  2014   2027     db_lset("repository", g.argv[2]);
  2015   2028     db_record_repository_filename(g.argv[2]);
  2016         -  vid = db_int(0, "SELECT pid FROM plink y"
  2017         -                  " WHERE NOT EXISTS(SELECT 1 FROM plink x WHERE x.cid=y.pid)");
  2018         -  if( vid==0 ){
  2019         -    db_lset_int("checkout", 1);
         2029  +  db_lset_int("checkout", 0);
         2030  +  oldArgv = g.argv;
         2031  +  oldArgc = g.argc;
         2032  +  azNewArgv[0] = g.argv[0];
         2033  +  g.argv = azNewArgv;
         2034  +  g.argc = 3;
         2035  +  if( oldArgc==4 ){
         2036  +    azNewArgv[g.argc-1] = oldArgv[3];
         2037  +  }else if( !db_exists("SELECT 1 FROM event WHERE type='ci'") ){
         2038  +    azNewArgv[g.argc-1] = "--latest";
  2020   2039     }else{
  2021         -    char **oldArgv = g.argv;
  2022         -    int oldArgc = g.argc;
  2023         -    db_lset_int("checkout", vid);
  2024         -    azNewArgv[0] = g.argv[0];
  2025         -    g.argv = azNewArgv;
  2026         -    g.argc = 3;
  2027         -    if( oldArgc==4 ){
  2028         -      azNewArgv[g.argc-1] = oldArgv[3];
  2029         -    }else{
  2030         -      azNewArgv[g.argc-1] = db_get("main-branch", "trunk");
  2031         -    }
  2032         -    if( keepFlag ){
  2033         -      azNewArgv[g.argc++] = "--keep";
  2034         -    }
  2035         -    checkout_cmd();
  2036         -    g.argc = 2;
  2037         -    info_cmd();
         2040  +    azNewArgv[g.argc-1] = db_get("main-branch", "trunk");
  2038   2041     }
         2042  +  if( keepFlag ){
         2043  +    azNewArgv[g.argc++] = "--keep";
         2044  +  }
         2045  +  checkout_cmd();
         2046  +  g.argc = 2;
         2047  +  info_cmd();
  2039   2048   }
  2040   2049   
  2041   2050   /*
  2042   2051   ** Print the value of a setting named zName
  2043   2052   */
  2044   2053   static void print_setting(
  2045   2054     const struct stControlSettings *ctrlSetting,
................................................................................
  2440   2449     if( g.argc!=3 ) usage("TIMESTAMP");
  2441   2450     sqlite3_open(":memory:", &g.db);
  2442   2451     rDiff = db_double(0.0, "SELECT julianday('now') - julianday(%Q)", g.argv[2]);
  2443   2452     fossil_print("Time differences: %s\n", db_timespan_name(rDiff));
  2444   2453     sqlite3_close(g.db);
  2445   2454     g.db = 0;
  2446   2455   }
         2456  +
         2457  +/*
         2458  +** COMMAND: test-without-rowid
         2459  +** %fossil test-without-rowid FILENAME...
         2460  +**
         2461  +** Change the Fossil repository FILENAME to make use of the WITHOUT ROWID
         2462  +** optimization.  FILENAME can also be the ~/.fossil file or a local
         2463  +** .fslckout or _FOSSIL_ file.
         2464  +**
         2465  +** The purpose of this command is for testing the WITHOUT ROWID capabilities
         2466  +** of SQLite.  There is no big advantage to using WITHOUT ROWID in Fossil.
         2467  +**
         2468  +** Options:
         2469  +**    --dryrun | -n         No changes.  Just print what would happen.
         2470  +*/
         2471  +void test_without_rowid(void){
         2472  +  int i, j;
         2473  +  Stmt q;
         2474  +  Blob allSql;
         2475  +  int dryRun = find_option("dry-run", "n", 0)!=0;
         2476  +  for(i=2; i<g.argc; i++){
         2477  +    db_open_or_attach(g.argv[i], "main", 0);
         2478  +    blob_init(&allSql, "BEGIN;\n", -1);
         2479  +    db_prepare(&q,
         2480  +      "SELECT name, sql FROM main.sqlite_master "
         2481  +      " WHERE type='table' AND sql NOT LIKE '%%WITHOUT ROWID%%'"
         2482  +      "   AND name IN ('global_config','shun','concealed','config',"
         2483  +                    "  'plink','tagxref','backlink','vcache');"
         2484  +    );
         2485  +    while( db_step(&q)==SQLITE_ROW ){
         2486  +      const char *zTName = db_column_text(&q, 0);
         2487  +      const char *zOrigSql = db_column_text(&q, 1);
         2488  +      Blob newSql;
         2489  +      blob_init(&newSql, 0, 0);
         2490  +      for(j=0; zOrigSql[j]; j++){
         2491  +        if( fossil_strnicmp(zOrigSql+j,"unique",6)==0 ){
         2492  +          blob_append(&newSql, zOrigSql, j);
         2493  +          blob_append(&newSql, "PRIMARY KEY", -1);
         2494  +          zOrigSql += j+6;
         2495  +          j = -1;
         2496  +        }
         2497  +      }
         2498  +      blob_append(&newSql, zOrigSql, -1);
         2499  +      blob_appendf(&allSql, 
         2500  +         "ALTER TABLE %s RENAME TO x_%s;\n"
         2501  +         "%s WITHOUT ROWID;\n"
         2502  +         "INSERT INTO %s SELECT * FROM x_%s;\n"
         2503  +         "DROP TABLE x_%s;\n",
         2504  +         zTName, zTName, blob_str(&newSql), zTName, zTName, zTName
         2505  +      );
         2506  +      fossil_print("Converting table %s of %s to WITHOUT ROWID.\n", zTName, g.argv[i]);
         2507  +      blob_reset(&newSql);
         2508  +    }
         2509  +    blob_appendf(&allSql, "COMMIT;\n");
         2510  +    db_finalize(&q);
         2511  +    if( dryRun ){
         2512  +      fossil_print("SQL that would have been evaluated:\n");
         2513  +      fossil_print("-------------------------------------------------------------\n");
         2514  +      fossil_print("%s", blob_str(&allSql));
         2515  +    }else{
         2516  +      db_multi_exec("%s", blob_str(&allSql));
         2517  +    }
         2518  +    blob_reset(&allSql);
         2519  +    db_close(1);
         2520  +  }
         2521  +}

Changes to src/diff.c.

  2121   2121     x2 = c2&0xff;
  2122   2122     c |= (x1*(n-i) + x2*i)/n & 0xff;
  2123   2123     return c;
  2124   2124   }
  2125   2125   
  2126   2126   /*
  2127   2127   ** WEBPAGE: annotate
         2128  +** WEBPAGE: blame
  2128   2129   **
  2129   2130   ** Query parameters:
  2130   2131   **
  2131   2132   **    checkin=ID          The manifest ID at which to start the annotation
  2132   2133   **    filename=FILENAME   The filename.
  2133   2134   **    filevers            Show file versions rather than check-in versions
  2134   2135   **    log=BOOLEAN         Show a log of versions analyzed
................................................................................
  2143   2144     int showLog = 0;       /* True to display the log */
  2144   2145     const char *zFilename; /* Name of file to annotate */
  2145   2146     const char *zCI;       /* The check-in containing zFilename */
  2146   2147     Annotator ann;
  2147   2148     HQuery url;
  2148   2149     struct AnnVers *p;
  2149   2150     unsigned clr1, clr2, clr;
         2151  +  int bBlame = g.zPath[0]=='b';/* True for BLAME output.  False for ANNOTATE. */
  2150   2152   
  2151   2153     /* Gather query parameters */
  2152   2154     showLog = atoi(PD("log","1"));
  2153   2155     login_check_credentials();
  2154   2156     if( !g.perm.Read ){ login_needed(); return; }
  2155   2157     if( exclude_spiders("annotate") ) return;
  2156   2158     mid = name_to_typed_rid(PD("checkin","0"),"ci");
................................................................................
  2249   2251     for(i=0; i<ann.nOrig; i++){
  2250   2252       int iVers = ann.aOrig[i].iVers;
  2251   2253       char *z = (char*)ann.aOrig[i].z;
  2252   2254       int n = ann.aOrig[i].n;
  2253   2255       char zPrefix[300];
  2254   2256       z[n] = 0;
  2255   2257       if( iLimit>ann.nVers && iVers<0 ) iVers = ann.nVers-1;
  2256         -    if( iVers>=0 ){
  2257         -      struct AnnVers *p = ann.aVers+iVers;
  2258         -      char *zLink = xhref("target='infowindow'", "%R/info/%S", p->zMUuid);
  2259         -      sqlite3_snprintf(sizeof(zPrefix), zPrefix,
  2260         -           "<span style='background-color:%s'>"
  2261         -           "%s%.10s</a> %s</span> %4d:",
  2262         -           p->zBgColor, zLink, p->zMUuid, p->zDate, i+1);
  2263         -      fossil_free(zLink);
         2258  +
         2259  +    if( bBlame ){
         2260  +      if( iVers>=0 ){
         2261  +        struct AnnVers *p = ann.aVers+iVers;
         2262  +        char *zLink = xhref("target='infowindow'", "%R/info/%S", p->zMUuid);
         2263  +        sqlite3_snprintf(sizeof(zPrefix), zPrefix,
         2264  +             "<span style='background-color:%s'>"
         2265  +             "%s%.10s</a> %s</span> %13.13s:",
         2266  +             p->zBgColor, zLink, p->zMUuid, p->zDate, p->zUser);
         2267  +        fossil_free(zLink);
         2268  +      }else{
         2269  +        sqlite3_snprintf(sizeof(zPrefix), zPrefix, "%36s", "");
         2270  +      }
  2264   2271       }else{
  2265         -      sqlite3_snprintf(sizeof(zPrefix), zPrefix, "%22s%4d:", "", i+1);
         2272  +      if( iVers>=0 ){
         2273  +        struct AnnVers *p = ann.aVers+iVers;
         2274  +        char *zLink = xhref("target='infowindow'", "%R/info/%S", p->zMUuid);
         2275  +        sqlite3_snprintf(sizeof(zPrefix), zPrefix,
         2276  +             "<span style='background-color:%s'>"
         2277  +             "%s%.10s</a> %s</span> %4d:",
         2278  +             p->zBgColor, zLink, p->zMUuid, p->zDate, i+1);
         2279  +        fossil_free(zLink);
         2280  +      }else{
         2281  +        sqlite3_snprintf(sizeof(zPrefix), zPrefix, "%22s%4d:", "", i+1);
         2282  +      }
  2266   2283       }
  2267   2284       @ %s(zPrefix) %h(z)
  2268   2285   
  2269   2286     }
  2270   2287     @ </pre>
  2271   2288     style_footer();
  2272   2289   }

Changes to src/file.c.

    37     37   # include <direct.h>
    38     38   # include <windows.h>
    39     39   # include <sys/utime.h>
    40     40   #else
    41     41   # include <sys/time.h>
    42     42   #endif
    43     43   
    44         -/*
    45         -** The file status information from the most recent stat() call.
    46         -**
    47         -** Use _stati64 rather than stat on windows, in order to handle files
    48         -** larger than 2GB.
    49         -*/
           44  +#if INTERFACE
           45  +
           46  +#include <dirent.h>
           47  +#if defined(_WIN32)
           48  +# define DIR _WDIR
           49  +# define dirent _wdirent
           50  +# define opendir _wopendir
           51  +# define readdir _wreaddir
           52  +# define closedir _wclosedir
           53  +#endif /* _WIN32 */
           54  +
    50     55   #if defined(_WIN32) && (defined(__MSVCRT__) || defined(_MSC_VER))
    51         -# undef stat
    52         -# define stat _stati64
           56  +struct fossilStat {
           57  +    i64 st_size;
           58  +    i64 st_mtime;
           59  +    int st_mode;
           60  +};
    53     61   #endif
           62  +
           63  +#endif /* INTERFACE */
           64  +
           65  +#if !defined(_WIN32) || !(defined(__MSVCRT__) || defined(_MSC_VER))
           66  +# define fossilStat stat
           67  +#endif
           68  +
    54     69   /*
    55     70   ** On Windows S_ISLNK always returns FALSE.
    56     71   */
    57     72   #if !defined(S_ISLNK)
    58     73   # define S_ISLNK(x) (0)
    59     74   #endif
    60     75   static int fileStatValid = 0;
    61         -static struct stat fileStat;
           76  +static struct fossilStat fileStat;
    62     77   
    63     78   /*
    64     79   ** Fill stat buf with information received from stat() or lstat().
    65     80   ** lstat() is called on Unix if isWd is TRUE and allow-symlinks setting is on.
    66     81   **
    67     82   */
    68         -static int fossil_stat(const char *zFilename, struct stat *buf, int isWd){
    69         -  int rc;
           83  +static int fossil_stat(const char *zFilename, struct fossilStat *buf, int isWd){
    70     84   #if !defined(_WIN32)
           85  +  int rc;
    71     86     char *zMbcs = fossil_utf8_to_filename(zFilename);
    72     87     if( isWd && g.allowSymlinks ){
    73     88       rc = lstat(zMbcs, buf);
    74     89     }else{
    75     90       rc = stat(zMbcs, buf);
    76     91     }
    77         -#else
    78         -  wchar_t *zMbcs = fossil_utf8_to_filename(zFilename);
    79         -  rc = _wstati64(zMbcs, buf);
    80         -#endif
    81     92     fossil_filename_free(zMbcs);
    82     93     return rc;
           94  +#else
           95  +  return win32_stat(zFilename, buf, isWd);
           96  +#endif
    83     97   }
    84     98   
    85     99   /*
    86    100   ** Fill in the fileStat variable for the file named zFilename.
    87    101   ** If zFilename==0, then use the previous value of fileStat if
    88    102   ** there is a previous value.
    89    103   **
................................................................................
   301    315   
   302    316   
   303    317   /*
   304    318   ** Wrapper around the access() system call.
   305    319   */
   306    320   int file_access(const char *zFilename, int flags){
   307    321   #ifdef _WIN32
   308         -  wchar_t *zMbcs = fossil_utf8_to_filename(zFilename);
   309         -  int rc = _waccess(zMbcs, flags);
          322  +  return win32_access(zFilename, flags);
   310    323   #else
   311    324     char *zMbcs = fossil_utf8_to_filename(zFilename);
   312    325     int rc = access(zMbcs, flags);
   313         -#endif
   314    326     fossil_filename_free(zMbcs);
   315    327     return rc;
          328  +#endif
   316    329   }
   317    330   
   318    331   /*
   319    332   ** Wrapper around the chdir() system call.
   320    333   ** If bChroot=1, do a chroot to this dir as well
   321    334   ** (UNIX only)
   322    335   */
   323    336   int file_chdir(const char *zChDir, int bChroot){
   324    337   #ifdef _WIN32
   325         -  wchar_t *zPath = fossil_utf8_to_filename(zChDir);
   326         -  int rc = _wchdir(zPath);
          338  +  return win32_chdir(zChDir, bChroot);
   327    339   #else
   328    340     char *zPath = fossil_utf8_to_filename(zChDir);
   329    341     int rc = chdir(zPath);
   330    342     if( !rc && bChroot ){
   331    343       rc = chroot(zPath);
   332    344       if( !rc ) rc = chdir("/");
   333    345     }
   334         -#endif
   335    346     fossil_filename_free(zPath);
   336    347     return rc;
          348  +#endif
   337    349   }
   338    350   
   339    351   /*
   340    352   ** Find an unused filename similar to zBase with zSuffix appended.
   341    353   **
   342    354   ** Make the name relative to the working directory if relFlag is true.
   343    355   **
................................................................................
   418    430   }
   419    431   
   420    432   /*
   421    433   ** Set the mtime for a file.
   422    434   */
   423    435   void file_set_mtime(const char *zFilename, i64 newMTime){
   424    436   #if !defined(_WIN32)
          437  +  char *zMbcs;
   425    438     struct timeval tv[2];
   426    439     memset(tv, 0, sizeof(tv[0])*2);
   427    440     tv[0].tv_sec = newMTime;
   428    441     tv[1].tv_sec = newMTime;
   429         -  char *zMbcs = fossil_utf8_to_filename(zFilename);
          442  +  zMbcs = fossil_utf8_to_filename(zFilename);
   430    443     utimes(zMbcs, tv);
   431    444   #else
   432    445     struct _utimbuf tb;
   433    446     wchar_t *zMbcs = fossil_utf8_to_filename(zFilename);
   434    447     tb.actime = newMTime;
   435    448     tb.modtime = newMTime;
   436    449     _wutime(zMbcs, &tb);
................................................................................
   721    734   **
   722    735   ** On windows, the name is converted from unicode to UTF8 and all '\\'
   723    736   ** characters are converted to '/'.  No conversions are needed on
   724    737   ** unix.
   725    738   */
   726    739   void file_getcwd(char *zBuf, int nBuf){
   727    740   #ifdef _WIN32
   728         -  char *zPwdUtf8;
   729         -  int nPwd;
   730         -  int i;
   731         -  wchar_t zPwd[2000];
   732         -  if( _wgetcwd(zPwd, sizeof(zPwd)/sizeof(zPwd[0])-1)==0 ){
   733         -    fossil_fatal("cannot find the current working directory.");
   734         -  }
   735         -  zPwdUtf8 = fossil_filename_to_utf8(zPwd);
   736         -  nPwd = strlen(zPwdUtf8);
   737         -  if( nPwd > nBuf-1 ){
   738         -    fossil_fatal("pwd too big: max %d\n", nBuf-1);
   739         -  }
   740         -  for(i=0; zPwdUtf8[i]; i++) if( zPwdUtf8[i]=='\\' ) zPwdUtf8[i] = '/';
   741         -  memcpy(zBuf, zPwdUtf8, nPwd+1);
   742         -  fossil_filename_free(zPwdUtf8);
          741  +  win32_getcwd(zBuf, nBuf);
   743    742   #else
   744    743     if( getcwd(zBuf, nBuf-1)==0 ){
   745    744       if( errno==ERANGE ){
   746    745         fossil_fatal("pwd too big: max %d\n", nBuf-1);
   747    746       }else{
   748    747         fossil_fatal("cannot find current working directory; %s",
   749    748                      strerror(errno));
................................................................................
  1169   1168       blob_read_from_file(&onDisk, zName);
  1170   1169     }
  1171   1170     rc = blob_compare(&onDisk, pContent);
  1172   1171     blob_reset(&onDisk);
  1173   1172     return rc==0;
  1174   1173   }
  1175   1174   
  1176         -/*
  1177         -** Portable unicode implementation of opendir()
  1178         -*/
  1179         -#if INTERFACE
  1180         -
  1181         -#include <dirent.h>
  1182         -#if defined(_WIN32)
  1183         -# define DIR _WDIR
  1184         -# define dirent _wdirent
  1185         -# define opendir _wopendir
  1186         -# define readdir _wreaddir
  1187         -# define closedir _wclosedir
  1188         -#endif /* _WIN32 */
  1189         -
  1190         -#endif /* INTERFACE */
  1191         -
  1192   1175   /*
  1193   1176   ** Return the value of an environment variable as UTF8.
  1194   1177   ** Use fossil_filename_free() to release resources.
  1195   1178   */
  1196   1179   char *fossil_getenv(const char *zName){
  1197   1180   #ifdef _WIN32
  1198   1181     wchar_t *uName = fossil_utf8_to_unicode(zName);

Changes to src/finfo.c.

    47     47   **   -l|--log             select log mode (the default)
    48     48   **   -n|--limit N         display the first N changes. N=0 means no limit.
    49     49   **   --offset P           skip P changes
    50     50   **   -p|--print           select print mode
    51     51   **   -r|--revision R      print the given revision (or ckout, if none is given)
    52     52   **                        to stdout (only in print mode)
    53     53   **   -s|--status          select status mode (print a status indicator for FILE)
    54         -**   -W|--width <num>     With of lines (default 79). Must be >22 or 0.
           54  +**   -W|--width <num>     With of lines (default 79). Must be >22 or 0
           55  +**                        (= no limit, resulting in a single line per entry).
    55     56   **
    56     57   ** See also: artifact, cat, descendants, info, leaves
    57     58   */
    58     59   void finfo_cmd(void){
    59     60     capture_case_sensitive_option();
    60     61     db_must_be_within_tree();
    61     62     if( find_option("status","s",0) ){
................................................................................
   202    203         }else{
   203    204           blob_reset(&line);
   204    205           blob_appendf(&line, "%.10s ", zCiUuid);
   205    206           blob_appendf(&line, "%.10s ", zDate);
   206    207           blob_appendf(&line, "%8.8s ", zUser);
   207    208           blob_appendf(&line, "%8.8s ", zBr);
   208    209           blob_appendf(&line,"%-39.39s", zCom );
   209         -        comment_print(blob_str(&line), 0, 79);
          210  +        comment_print(blob_str(&line), 0, iWidth);
   210    211         }
   211    212       }
   212    213       db_finalize(&q);
   213    214       blob_reset(&fname);
   214    215     }
   215    216   }
   216    217   
................................................................................
   460    461       }
   461    462       hyperlink_to_uuid(zShortCkin);
   462    463       @ %w(zCom) (user:
   463    464       hyperlink_to_user(zUser, zDate, "");
   464    465       @ branch: %h(zBr))
   465    466       if( g.perm.Hyperlink && zUuid ){
   466    467         const char *z = zFilename;
          468  +      @ %z(href("%R/annotate?checkin=%S&filename=%h",zCkin,z))
          469  +      @ [annotate]</a>
          470  +      @ %z(href("%R/blame?checkin=%S&filename=%h",zCkin,z))
          471  +      @ [blame]</a>
          472  +      @ %z(href("%R/timeline?n=200&uf=%S",zUuid))[checkins&nbsp;using]</a>
   467    473         if( fpid ){
   468    474           @ %z(href("%R/fdiff?v1=%S&v2=%S&sbs=1",zPUuid,zUuid))[diff]</a>
   469    475         }
   470         -      @ %z(href("%R/annotate?checkin=%S&filename=%h",zCkin,z))
   471         -      @ [annotate]</a>
   472         -      @ %z(href("%R/timeline?n=200&uf=%S",zUuid))[checkins&nbsp;using]</a>
   473    476       }
   474    477       if( fDebug & FINFO_DEBUG_MLINK ){
   475    478         int srcid = db_int(0, "SELECT srcid FROM delta WHERE rid=%d", frid);
   476    479         int sz = db_int(0, "SELECT length(content) FROM blob WHERE rid=%d", frid);
   477    480         @ <br>fid=%d(frid) pid=%d(fpid) mid=%d(fmid) sz=%d(sz)
   478    481         if( srcid ){
   479    482           @ srcid=%d(srcid)

Changes to src/info.c.

   963    963     if( !zVerbose ){
   964    964       zVerbose = P("detail"); /* deprecated */
   965    965     }
   966    966     verboseFlag = (zVerbose!=0) && !is_false(zVerbose);
   967    967     if( !verboseFlag && sideBySide ) verboseFlag = 1;
   968    968     zFrom = P("from");
   969    969     zTo = P("to");
          970  +  if( sideBySide || verboseFlag ){
          971  +    style_submenu_element("Hide Diff", "hidediff",
          972  +                          "%R/vdiff?from=%T&to=%T&sbs=0",
          973  +                          zFrom, zTo);
          974  +  }
   970    975     if( !sideBySide ){
   971    976       style_submenu_element("Side-by-side Diff", "sbsdiff",
   972    977                             "%R/vdiff?from=%T&to=%T&sbs=1",
   973    978                             zFrom, zTo);
   974    979     }
   975    980     if( sideBySide || !verboseFlag ) {
   976    981       style_submenu_element("Unified Diff", "udiff",
................................................................................
  1126   1131       hyperlink_to_uuid(zVers);
  1127   1132       if( zBr && zBr[0] ){
  1128   1133         @ on branch %z(href("%R/timeline?r=%T",zBr))%h(zBr)</a>
  1129   1134       }
  1130   1135       @ - %!w(zCom) (user:
  1131   1136       hyperlink_to_user(zUser,zDate,")");
  1132   1137       if( g.perm.Hyperlink ){
         1138  +      @ %z(href("%R/finfo?name=%T&ci=%S",zName,zVers))[ancestry]</a>
  1133   1139         @ %z(href("%R/annotate?checkin=%S&filename=%T",zVers,zName))
  1134   1140         @ [annotate]</a>
  1135         -      @ %z(href("%R/finfo?name=%T&ci=%S",zName,zVers))[ancestry]</a>
         1141  +      @ %z(href("%R/blame?checkin=%S&filename=%T",zVers,zName))
         1142  +      @ [blame]</a>
  1136   1143       }
  1137   1144       cnt++;
  1138   1145       if( pDownloadName && blob_size(pDownloadName)==0 ){
  1139   1146         blob_append(pDownloadName, zName, -1);
  1140   1147       }
  1141   1148     }
  1142   1149     if( prevName ){
................................................................................
  1308   1315       content_get(v1, &c1);
  1309   1316       content_get(v2, &c2);
  1310   1317       text_diff(&c1, &c2, pOut, pRe, diffFlags);
  1311   1318       blob_reset(&c1);
  1312   1319       blob_reset(&c2);
  1313   1320       return;
  1314   1321     }
  1315         -  
         1322  +
  1316   1323     sideBySide = !is_false(PD("sbs","1"));
  1317   1324     zV1 = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", v1);
  1318   1325     zV2 = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", v2);
  1319   1326     diffFlags = construct_diff_flags(1, sideBySide) | DIFF_HTML;
  1320   1327   
  1321   1328     style_header("Diff");
  1322   1329     style_submenu_element("Patch", "Patch", "%s/fdiff?v1=%T&v2=%T&patch",
................................................................................
  1658   1665     }
  1659   1666     @ <hr />
  1660   1667     content_get(rid, &content);
  1661   1668     if( renderAsWiki ){
  1662   1669       wiki_convert(&content, 0, 0);
  1663   1670     }else if( renderAsHtml ){
  1664   1671       @ <iframe src="%R/raw/%T(blob_str(&downloadName))?name=%s(zUuid)"
  1665         -    @   width="100%%" frameborder="0" marginwidth="0" marginheight="0" 
  1666         -    @   sandbox="allow-same-origin" 
         1672  +    @   width="100%%" frameborder="0" marginwidth="0" marginheight="0"
         1673  +    @   sandbox="allow-same-origin"
  1667   1674       @   onload="this.height = this.contentDocument.documentElement.scrollHeight;">
  1668   1675       @ </iframe>
  1669   1676     }else{
  1670   1677       style_submenu_element("Hex","Hex", "%s/hexdump?name=%s", g.zTop, zUuid);
  1671   1678       zMime = mimetype_from_content(&content);
  1672   1679       @ <blockquote>
  1673   1680       if( zMime==0 ){
................................................................................
  1761   1768     }
  1762   1769     modPending = moderation_pending(rid);
  1763   1770     if( modPending ){
  1764   1771       @ <span class="modpending">*** Awaiting Moderator Approval ***</span>
  1765   1772     }
  1766   1773     @ <tr><th>Ticket:</th>
  1767   1774     @ <td>%z(href("%R/tktview/%s",zTktName))%s(zTktName)</a>
  1768         -  if(zTktTitle){
         1775  +  if( zTktTitle ){
  1769   1776           @<br>%h(zTktTitle)
  1770   1777     }
  1771   1778     @</td></tr>
  1772   1779     @ <tr><th>Date:</th><td>
  1773   1780     hyperlink_to_date(zDate, "</td></tr>");
  1774   1781     @ <tr><th>User:</th><td>
  1775   1782     hyperlink_to_user(pTktChng->zUser, zDate, "</td></tr>");
................................................................................
  2044   2051     const char *zNewTagFlag;
  2045   2052     const char *zNewTag;
  2046   2053     const char *zNewBrFlag;
  2047   2054     const char *zNewBranch;
  2048   2055     const char *zCloseFlag;
  2049   2056     int fPropagateColor;          /* True if color propagates before edit */
  2050   2057     int fNewPropagateColor;       /* True if color propagates after edit */
         2058  +  int fHasClosed = 0;           /* True if closed tag already set */
  2051   2059     const char *zChngTime = 0;     /* Value of chngtime= query param, if any */
  2052   2060     char *zUuid;
  2053   2061     Blob comment;
         2062  +  char *zBranchName = 0;
  2054   2063     Stmt q;
  2055   2064   
  2056   2065     login_check_credentials();
  2057   2066     if( !g.perm.Write ){ login_needed(); return; }
  2058   2067     rid = name_to_typed_rid(P("r"), "ci");
  2059   2068     zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
  2060   2069     zComment = db_text(0, "SELECT coalesce(ecomment,comment)"
................................................................................
  2135   2144         sqlite3_snprintf(sizeof(zLabel), zLabel, "c%d", tagid);
  2136   2145         if( P(zLabel) ){
  2137   2146           db_multi_exec("REPLACE INTO newtags VALUES(%Q,'-',NULL)", zTag);
  2138   2147         }
  2139   2148       }
  2140   2149       db_finalize(&q);
  2141   2150       if( zCloseFlag[0] ){
  2142         -      db_multi_exec("REPLACE INTO newtags VALUES('closed','+',NULL)");
         2151  +      db_multi_exec("REPLACE INTO newtags VALUES('closed','%s',NULL)",
         2152  +          is_a_leaf(rid)?"+":"*");
  2143   2153       }
  2144   2154       if( zNewTagFlag[0] && zNewTag[0] ){
  2145   2155         db_multi_exec("REPLACE INTO newtags VALUES('sym-%q','+',NULL)", zNewTag);
  2146   2156       }
  2147   2157       if( zNewBrFlag[0] && zNewBranch[0] ){
  2148   2158         db_multi_exec(
  2149   2159           "REPLACE INTO newtags "
................................................................................
  2186   2196       }
  2187   2197       cgi_redirectf("ci?name=%s", zUuid);
  2188   2198     }
  2189   2199     blob_zero(&comment);
  2190   2200     blob_append(&comment, zNewComment, -1);
  2191   2201     zUuid[10] = 0;
  2192   2202     style_header("Edit Check-in [%s]", zUuid);
         2203  +  /*
         2204  +  ** chgcbn/chgbn: Handle change of (checkbox for) branch name in
         2205  +  ** remaining of form.
         2206  +  */
         2207  +  @ <script>
         2208  +  @ function chgcbn(checked, branch){
         2209  +  @   val = gebi('brname').value;
         2210  +  @   if( !val || !checked) val = branch;
         2211  +  @   cidbrid = document.getElementById('cbranch');
         2212  +  @   if( cidbrid ) cidbrid.textContent = val;
         2213  +  @ }
         2214  +  @ function chgbn(val, branch){
         2215  +  @   if( !val ) val = branch;
         2216  +  @   gebi('newbr').checked = (val!=branch);
         2217  +  @   cidbrid = document.getElementById('cbranch');
         2218  +  @   if( cidbrid ) cidbrid.textContent = val;
         2219  +  @ }
         2220  +  @ </script>
  2193   2221     if( P("preview") ){
  2194   2222       Blob suffix;
  2195   2223       int nTag = 0;
  2196   2224       @ <b>Preview:</b>
  2197   2225       @ <blockquote>
  2198   2226       @ <table border=0>
  2199   2227       if( zNewColor && zNewColor[0] ){
................................................................................
  2265   2293   
  2266   2294     @ <tr><th align="right" valign="top">Tags:</th>
  2267   2295     @ <td valign="top">
  2268   2296     @ <label><input type="checkbox" id="newtag" name="newtag"%s(zNewTagFlag) />
  2269   2297     @ Add the following new tag name to this check-in:</label>
  2270   2298     @ <input type="text" style="width:15;" name="tagname" value="%h(zNewTag)"
  2271   2299     @ onkeyup="gebi('newtag').checked=!!this.value" />
         2300  +  zBranchName = db_text(0, "SELECT value FROM tagxref, tag"
         2301  +     " WHERE tagxref.rid=%d AND tagtype>0 AND tagxref.tagid=tag.tagid"
         2302  +     " AND tagxref.tagid=%d", rid, TAG_BRANCH);
  2272   2303     db_prepare(&q,
  2273         -     "SELECT tag.tagid, tagname FROM tagxref, tag"
         2304  +     "SELECT tag.tagid, tagname, tagxref.value FROM tagxref, tag"
  2274   2305        " WHERE tagxref.rid=%d AND tagtype>0 AND tagxref.tagid=tag.tagid"
  2275   2306        " ORDER BY CASE WHEN tagname GLOB 'sym-*' THEN substr(tagname,5)"
  2276   2307        "               ELSE tagname END /*sort*/",
  2277   2308        rid
  2278   2309     );
  2279   2310     while( db_step(&q)==SQLITE_ROW ){
  2280   2311       int tagid = db_column_int(&q, 0);
  2281   2312       const char *zTagName = db_column_text(&q, 1);
         2313  +    int isSpecialTag = fossil_strncmp(zTagName, "sym-", 4)!=0;
  2282   2314       char zLabel[30];
         2315  +
         2316  +    if( tagid == TAG_CLOSED ){
         2317  +      fHasClosed = 1;
         2318  +    }else if( (tagid == TAG_COMMENT) || (tagid == TAG_BRANCH) ){
         2319  +      continue;
         2320  +    }else if( !isSpecialTag && zTagName &&
         2321  +        fossil_strcmp(&zTagName[4], zBranchName)==0){
         2322  +      continue;
         2323  +    }
  2283   2324       sqlite3_snprintf(sizeof(zLabel), zLabel, "c%d", tagid);
  2284   2325       @ <br /><label>
  2285   2326       if( P(zLabel) ){
  2286   2327         @ <input type="checkbox" name="c%d(tagid)" checked="checked" />
  2287   2328       }else{
  2288   2329         @ <input type="checkbox" name="c%d(tagid)" />
  2289   2330       }
  2290         -    if( strncmp(zTagName, "sym-", 4)==0 ){
  2291         -      @ Cancel tag <b>%h(&zTagName[4])</b></label>
         2331  +    if( isSpecialTag ){
         2332  +      @ Cancel special tag <b>%h(zTagName)</b></label>
  2292   2333       }else{
  2293         -      @ Cancel special tag <b>%h(zTagName)</b></label>
         2334  +      @ Cancel tag <b>%h(&zTagName[4])</b></label>
  2294   2335       }
  2295   2336     }
  2296   2337     db_finalize(&q);
  2297   2338     @ </td></tr>
  2298   2339   
         2340  +  if( !zBranchName ){
         2341  +    zBranchName = db_get("main-branch", "trunk");
         2342  +  }
         2343  +  if( !zNewBranch || !zNewBranch[0]){
         2344  +    zNewBranch = zBranchName;
         2345  +  }
  2299   2346     @ <tr><th align="right" valign="top">Branching:</th>
  2300   2347     @ <td valign="top">
  2301         -  @ <label><input id="newbr" type="checkbox" name="newbr"%s(zNewBrFlag) />
         2348  +  @ <label><input id="newbr" type="checkbox" name="newbr"%s(zNewBrFlag)
         2349  +  @ onchange="chgcbn(this.checked,'%h(zBranchName)')" />
  2302   2350     @ Make this check-in the start of a new branch named:</label>
  2303         -  @ <input type="text" style="width:15;" name="brname" value="%h(zNewBranch)"
  2304         -  @ onkeyup="gebi('newbr').checked=!!this.value" />
  2305         -  @ </td></tr>
  2306         -
  2307         -  if( is_a_leaf(rid)
  2308         -   && !db_exists("SELECT 1 FROM tagxref "
  2309         -                 " WHERE tagid=%d AND rid=%d AND tagtype>0",
  2310         -                 TAG_CLOSED, rid)
  2311         -  ){
  2312         -    @ <tr><th align="right" valign="top">Leaf Closure:</th>
  2313         -    @ <td valign="top">
  2314         -    @ <label><input type="checkbox" name="close"%s(zCloseFlag) />
  2315         -    @ Mark this leaf as "closed" so that it no longer appears on the
  2316         -    @ "leaves" page and is no longer labeled as a "<b>Leaf</b>".</label>
  2317         -    @ </td></tr>
         2351  +  @ <input id="brname" type="text" style="width:15;" name="brname"
         2352  +  @ value="%h(zNewBranch)"
         2353  +  @ onkeyup="chgbn(this.value,'%h(zBranchName)')" /></td></tr>
         2354  +  if( !fHasClosed ){
         2355  +    if( is_a_leaf(rid) ){
         2356  +      @ <tr><th align="right" valign="top">Leaf Closure:</th>
         2357  +      @ <td valign="top">
         2358  +      @ <label><input type="checkbox" name="close"%s(zCloseFlag) />
         2359  +      @ Mark this leaf as "closed" so that it no longer appears on the
         2360  +      @ "leaves" page and is no longer labeled as a "<b>Leaf</b>"</label>
         2361  +      @ </td></tr>
         2362  +    }else if( zBranchName ){
         2363  +      @ <tr><th align="right" valign="top">Branch Closure:</th>
         2364  +      @ <td valign="top">
         2365  +      @ <label><input type="checkbox" name="close"%s(zCloseFlag) />
         2366  +      @ Mark branch
         2367  +      @ <span style="font-weight:bold" id="cbranch">%h(zBranchName)</span>
         2368  +      @ as "closed" so that its leafs no longer appear on the "leaves" page
         2369  +      @ and are no longer labeled as a leaf "<b>Leaf</b>"</label>
         2370  +      @ </td></tr>
         2371  +    }
  2318   2372     }
         2373  +  if( zBranchName ) fossil_free(zBranchName);
  2319   2374   
  2320   2375   
  2321   2376     @ <tr><td colspan="2">
  2322   2377     @ <input type="submit" name="preview" value="Preview" />
  2323   2378     @ <input type="submit" name="apply" value="Apply Changes" />
  2324   2379     @ <input type="submit" name="cancel" value="Cancel" />
  2325   2380     @ </td></tr>
  2326   2381     @ </table>
  2327   2382     @ </div></form>
  2328   2383     style_footer();
  2329   2384   }

Changes to src/json.c.

   985    985       FILE * inFile = NULL;
   986    986       char const * jfile = find_option("json-input",NULL,1);
   987    987       if(!jfile || !*jfile){
   988    988         break;
   989    989       }
   990    990       inFile = (0==strcmp("-",jfile))
   991    991         ? stdin
   992         -      : fopen(jfile,"rb");
          992  +      : fossil_fopen(jfile,"rb");
   993    993       if(!inFile){
   994    994         g.json.resultCode = FSL_JSON_E_FILE_OPEN_FAILED;
   995    995         fossil_fatal("Could not open JSON file [%s].",jfile)
   996    996           /* Does not return. */
   997    997           ;
   998    998       }
   999    999       cgi_parse_POST_JSON(inFile, 0);
................................................................................
  1978   1978     SETBUF(jo, "projectCode");
  1979   1979     cson_object_set(jo, "compiler", cson_value_new_string(COMPILER_NAME, strlen(COMPILER_NAME)));
  1980   1980   
  1981   1981     jv2 = cson_value_new_object();
  1982   1982     jo2 = cson_value_get_object(jv2);
  1983   1983     cson_object_set(jo, "sqlite", jv2);
  1984   1984     sqlite3_snprintf(BufLen, zBuf, "%.19s [%.10s] (%s)",
  1985         -                   SQLITE_SOURCE_ID, &SQLITE_SOURCE_ID[20], SQLITE_VERSION);
         1985  +                   sqlite3_sourceid(), &sqlite3_sourceid()[20], sqlite3_libversion());
  1986   1986     SETBUF(jo2, "version");
  1987   1987     zDb = db_name("repository");
  1988   1988     cson_object_set(jo2, "pageCount", cson_value_new_integer((cson_int_t)db_int(0, "PRAGMA %s.page_count", zDb)));
  1989   1989     cson_object_set(jo2, "pageSize", cson_value_new_integer((cson_int_t)db_int(0, "PRAGMA %s.page_size", zDb)));
  1990   1990     cson_object_set(jo2, "freeList", cson_value_new_integer((cson_int_t)db_int(0, "PRAGMA %s.freelist_count", zDb)));
  1991   1991     sqlite3_snprintf(BufLen, zBuf, "%s", db_text(0, "PRAGMA %s.encoding", zDb));
  1992   1992     SETBUF(jo2, "encoding");

Changes to src/json_finfo.c.

    72     72   /*4*/   "   coalesce(event.euser, event.user),"
    73     73   /*5*/   "   coalesce(event.ecomment, event.comment),"
    74     74   /*6*/   " (SELECT uuid FROM blob WHERE rid=mlink.pid),"  /* Parent file uuid */
    75     75   /*7*/   "   event.bgcolor,"
    76     76   /*8*/   " b.size,"
    77     77   /*9*/   " (mlink.pid==0) AS isNew,"
    78     78   /*10*/  " (mlink.fid==0) AS isDel"
    79         -	"  FROM mlink, blob b, event, blob ci, filename"
           79  +        "  FROM mlink, blob b, event, blob ci, filename"
    80     80           " WHERE filename.name=%Q"
    81     81           "   AND mlink.fnid=filename.fnid"
    82     82           "   AND b.rid=mlink.fid"
    83     83           "   AND event.objid=mlink.mid"
    84     84           "   AND event.objid=ci.rid",
    85     85           zFilename
    86     86                  );

Changes to src/json_timeline.c.

   143    143   ** both are specified, which one takes precedence is unspecified.
   144    144   */
   145    145   static char json_timeline_add_tag_branch_clause(Blob *pSql,
   146    146                                                   cson_object * pPayload){
   147    147     char const * zTag = NULL;
   148    148     char const * zBranch = NULL;
   149    149     char const * zMiOnly = NULL;
          150  +  char const * zUnhide = NULL;
   150    151     int tagid = 0;
   151    152     if(! g.perm.Read ){
   152    153       return 0;
   153    154     }
   154    155     zTag = json_find_option_cstr("tag",NULL,NULL);
   155    156     if(!zTag || !*zTag){
   156    157       zBranch = json_find_option_cstr("branch",NULL,NULL);
   157    158       if(!zBranch || !*zBranch){
   158    159         return 0;
   159    160       }
   160    161       zTag = zBranch;
   161    162       zMiOnly = json_find_option_cstr("mionly",NULL,NULL);
   162    163     }
          164  +  zUnhide = json_find_option_cstr("unhide",NULL,NULL);
   163    165     tagid = db_int(0, "SELECT tagid FROM tag WHERE tagname='sym-%q'",
   164    166                    zTag);
   165    167     if(tagid<=0){
   166    168       return -1;
   167    169     }
   168    170     if(pPayload){
   169    171       cson_object_set( pPayload, zBranch ? "branch" : "tag", json_new_string(zTag) );
   170    172     }
   171    173     blob_appendf(pSql,
   172    174                  " AND ("
   173    175                  " EXISTS(SELECT 1 FROM tagxref"
   174    176                  "        WHERE tagid=%d AND tagtype>0 AND rid=blob.rid)",
   175    177                  tagid);
          178  +  if(!zUnhide){
          179  +    blob_appendf(pSql,
          180  +               " AND NOT EXISTS(SELECT 1 FROM plink JOIN tagxref ON rid=blob.rid"
          181  +               "    WHERE tagid=%d AND tagtype>0 AND rid=blob.rid)",
          182  +               TAG_HIDDEN);
          183  +  }
   176    184     if(zBranch){
   177    185       /* from "r" flag code in page_timeline().*/
   178    186       blob_appendf(pSql,
   179    187                    " OR EXISTS(SELECT 1 FROM plink JOIN tagxref ON rid=cid"
   180    188                    "    WHERE tagid=%d AND tagtype>0 AND pid=blob.rid)",
   181    189                    tagid);
          190  +    if( !zUnhide ){
          191  +      blob_appendf(pSql,
          192  +                 " AND NOT EXISTS(SELECT 1 FROM plink JOIN tagxref ON rid=cid"
          193  +                 "    WHERE tagid=%d AND tagtype>0 AND pid=blob.rid)",
          194  +                 TAG_HIDDEN);
          195  +    }
   182    196       if( zMiOnly==0 ){
   183    197         blob_appendf(pSql,
   184    198                    " OR EXISTS(SELECT 1 FROM plink JOIN tagxref ON rid=pid"
   185    199                    "    WHERE tagid=%d AND tagtype>0 AND cid=blob.rid)",
   186    200                    tagid);
          201  +      if( !zUnhide ){
          202  +        blob_appendf(pSql,
          203  +                 " AND NOT EXISTS(SELECT 1 FROM plink JOIN tagxref ON rid=pid"
          204  +                 "    WHERE tagid=%d AND tagtype>0 AND cid=blob.rid)",
          205  +                 TAG_HIDDEN);
          206  +      }
   187    207       }
   188    208     }
   189    209     blob_append(pSql," ) ",3);
   190    210     return 1;
   191    211   }
   192    212   /*
   193    213   ** Helper for the timeline family of functions.  Possibly appends 1

Changes to src/login.c.

   396    396       if( strncmp("http", zAgent+i,4)==0 ) return 0;
   397    397     }
   398    398     if( strncmp(zAgent, "Mozilla/", 8)==0 ){
   399    399       if( atoi(&zAgent[8])<4 ) return 0;  /* Many bots advertise as Mozilla/3 */
   400    400       if( strglob("*Firefox/[1-9]*", zAgent) ) return 1;
   401    401       if( strglob("*Chrome/[1-9]*", zAgent) ) return 1;
   402    402       if( strglob("*(compatible;?MSIE?[1789]*", zAgent) ) return 1;
          403  +    if( strglob("*Trident/[1-9]*;?rv:[1-9]*", zAgent) ) return 1; /* IE11+ */
   403    404       if( strglob("*AppleWebKit/[1-9]*(KHTML*", zAgent) ) return 1;
   404    405       return 0;
   405    406     }
   406    407     if( strncmp(zAgent, "Opera/", 6)==0 ) return 1;
   407    408     if( strncmp(zAgent, "Safari/", 7)==0 ) return 1;
   408    409     if( strncmp(zAgent, "Lynx/", 5)==0 ) return 1;
   409    410     if( strncmp(zAgent, "NetSurf/", 8)==0 ) return 1;
................................................................................
   472    473     char *zErrMsg = "";
   473    474     int uid;                     /* User id logged in user */
   474    475     char *zSha1Pw;
   475    476     const char *zIpAddr;         /* IP address of requestor */
   476    477   
   477    478     login_check_credentials();
   478    479     sqlite3_create_function(g.db, "constant_time_cmp", 2, SQLITE_UTF8, 0,
   479         -		  constant_time_cmp_function, 0, 0);
          480  +                  constant_time_cmp_function, 0, 0);
   480    481     zUsername = P("u");
   481    482     zPasswd = P("p");
   482    483     anonFlag = P("anon")!=0;
   483    484     if( P("out")!=0 ){
   484    485       login_clear_login_data();
   485    486       redirect_to_g();
   486    487     }
................................................................................
   693    694   
   694    695     zOtherRepo = db_text(0, 
   695    696          "SELECT value FROM config WHERE name='peer-repo-%q'",
   696    697          zCode
   697    698     );
   698    699     if( zOtherRepo==0 ) return 0;  /* No such peer repository */
   699    700   
   700         -  rc = sqlite3_open(zOtherRepo, &pOther);
          701  +  rc = sqlite3_open_v2(
          702  +       zOtherRepo, &pOther,
          703  +       SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
          704  +       g.zVfsName
          705  +  );
   701    706     if( rc==SQLITE_OK ){
   702    707       sqlite3_create_function(pOther,"now",0,SQLITE_ANY,0,db_now_function,0,0);
   703    708       sqlite3_create_function(pOther, "constant_time_cmp", 2, SQLITE_UTF8, 0,
   704         -		  constant_time_cmp_function, 0, 0);
          709  +                  constant_time_cmp_function, 0, 0);
   705    710       sqlite3_busy_timeout(pOther, 5000);
   706    711       zSQL = mprintf(
   707    712         "SELECT cexpire FROM user"
   708    713         " WHERE login=%Q"
   709    714         "   AND ipaddr=%Q"
   710    715         "   AND length(cap)>0"
   711    716         "   AND length(pw)>0"
................................................................................
   776    781   void login_check_credentials(void){
   777    782     int uid = 0;                  /* User id */
   778    783     const char *zCookie;          /* Text of the login cookie */
   779    784     const char *zIpAddr;          /* Raw IP address of the requestor */
   780    785     char *zRemoteAddr;            /* Abbreviated IP address of the requestor */
   781    786     const char *zCap = 0;         /* Capability string */
   782    787     const char *zPublicPages = 0; /* GLOB patterns of public pages */
          788  +  const char *zLogin = 0;       /* Login user for credentials */
   783    789   
   784    790     /* Only run this check once.  */
   785    791     if( g.userUid!=0 ) return;
   786    792   
   787    793     sqlite3_create_function(g.db, "constant_time_cmp", 2, SQLITE_UTF8, 0,
   788         -		  constant_time_cmp_function, 0, 0);
          794  +                  constant_time_cmp_function, 0, 0);
   789    795   
   790    796     /* If the HTTP connection is coming over 127.0.0.1 and if
   791    797     ** local login is disabled and if we are using HTTP and not HTTPS, 
   792    798     ** then there is no need to check user credentials.
   793    799     **
   794    800     ** This feature allows the "fossil ui" command to give the user
   795    801     ** full access rights without having to log in.
................................................................................
   797    803     zRemoteAddr = ipPrefix(zIpAddr = PD("REMOTE_ADDR","nil"));
   798    804     if( ( fossil_strcmp(zIpAddr, "127.0.0.1")==0 ||
   799    805           g.fSshClient & CGI_SSH_CLIENT )
   800    806      && g.useLocalauth
   801    807      && db_get_int("localauth",0)==0
   802    808      && P("HTTPS")==0
   803    809     ){
   804         -    uid = db_int(0, "SELECT uid FROM user WHERE cap LIKE '%%s%%'");
          810  +    if( g.localOpen ) zLogin = db_lget("default-user",0);
          811  +    if( zLogin!=0 ){
          812  +      uid = db_int(0, "SELECT uid FROM user WHERE login=%Q", zLogin);
          813  +    }else{
          814  +      uid = db_int(0, "SELECT uid FROM user WHERE cap LIKE '%%s%%'");
          815  +    }
   805    816       g.zLogin = db_text("?", "SELECT login FROM user WHERE uid=%d", uid);
   806    817       zCap = "sx";
   807    818       g.noPswd = 1;
   808    819       g.isHuman = 1;
   809    820       sqlite3_snprintf(sizeof(g.zCsrfToken), g.zCsrfToken, "localhost");
   810    821     }
   811    822   
................................................................................
  1364   1375         const char *zLabel = db_column_text(&q, 0);
  1365   1376         db_multi_exec(
  1366   1377            "DELETE FROM config WHERE name GLOB 'peer-*-%q'",
  1367   1378            &zLabel[10]
  1368   1379         );
  1369   1380         continue;
  1370   1381       }
  1371         -    rc = sqlite3_open_v2(zRepoName, &pPeer, SQLITE_OPEN_READWRITE, 0);
         1382  +    rc = sqlite3_open_v2(
         1383  +         zRepoName, &pPeer,
         1384  +         SQLITE_OPEN_READWRITE,
         1385  +         g.zVfsName
         1386  +    );
  1372   1387       if( rc!=SQLITE_OK ){
  1373   1388         blob_appendf(&err, "%s%s: %s%s", zPrefix, zRepoName,
  1374   1389                      sqlite3_errmsg(pPeer), zSuffix);
  1375   1390         nErr++;
  1376   1391         sqlite3_close(pPeer);
  1377   1392         continue;
  1378   1393       }
................................................................................
  1451   1466     }
  1452   1467   
  1453   1468     /* Make sure the other repository is a valid Fossil database */
  1454   1469     if( file_size(zRepo)<0 ){
  1455   1470       *pzErrMsg = mprintf("repository file \"%s\" does not exist", zRepo);
  1456   1471       return;
  1457   1472     }
  1458         -  rc = sqlite3_open(zRepo, &pOther);
         1473  +  rc = sqlite3_open_v2(
         1474  +       zRepo, &pOther,
         1475  +       SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
         1476  +       g.zVfsName
         1477  +  );
  1459   1478     if( rc!=SQLITE_OK ){
  1460   1479       *pzErrMsg = mprintf(sqlite3_errmsg(pOther));
  1461   1480     }else{
  1462   1481       rc = sqlite3_exec(pOther, "SELECT count(*) FROM user", 0, 0, pzErrMsg);
  1463   1482     }
  1464   1483     sqlite3_close(pOther);
  1465   1484     if( rc ) return;

Changes to src/main.c.

   117    117   ** All global variables are in this structure.
   118    118   */
   119    119   struct Global {
   120    120     int argc; char **argv;  /* Command-line arguments to the program */
   121    121     char *nameOfExe;        /* Full path of executable. */
   122    122     const char *zErrlog;    /* Log errors to this file, if not NULL */
   123    123     int isConst;            /* True if the output is unchanging */
          124  +  const char *zVfsName;   /* The VFS to use for database connections */
   124    125     sqlite3 *db;            /* The connection to the databases */
   125    126     sqlite3 *dbConfig;      /* Separate connection for global_config table */
   126    127     int useAttach;          /* True if global_config is attached to repository */
   127    128     const char *zConfigDbName;/* Path of the config database. NULL if not open */
   128    129     sqlite3_int64 now;      /* Seconds since 1970 */
   129    130     int repositoryOpen;     /* True if the main repository database is open */
   130    131     char *zRepositoryName;  /* Name of the repository database */
................................................................................
   549    550   #endif
   550    551   int main(int argc, char **argv)
   551    552   #endif
   552    553   {
   553    554     const char *zCmdName = "unknown";
   554    555     int idx;
   555    556     int rc;
          557  +  sqlite3_config(SQLITE_CONFIG_SINGLETHREAD);
   556    558     sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
   557    559     memset(&g, 0, sizeof(g));
   558    560     g.now = time(0);
   559    561     g.httpHeader = empty_blob;
   560    562   #ifdef FOSSIL_ENABLE_JSON
   561    563   #if defined(NDEBUG)
   562    564     g.json.errorDetailParanoia = 2 /* FIXME: make configurable
................................................................................
   573    575     expand_args_option(argc, argv);
   574    576   #ifdef FOSSIL_ENABLE_TCL
   575    577     memset(&g.tcl, 0, sizeof(TclContext));
   576    578     g.tcl.argc = g.argc;
   577    579     g.tcl.argv = copy_args(g.argc, g.argv); /* save full arguments */
   578    580   #endif
   579    581     g.mainTimerId = fossil_timer_start();
          582  +  g.zVfsName = find_option("vfs",0,1);
          583  +  if( g.zVfsName==0 ){
          584  +    g.zVfsName = fossil_getenv("FOSSIL_VFS");
          585  +#if defined(__CYGWIN__)
          586  +    if( g.zVfsName==0 && sqlite3_libversion_number()>=3008001 ){
          587  +      g.zVfsName = "win32-longpath";
          588  +    }
          589  +#endif
          590  +  }
          591  +  if( g.zVfsName ){
          592  +    sqlite3_vfs *pVfs = sqlite3_vfs_find(g.zVfsName);
          593  +    if( pVfs ){
          594  +      sqlite3_vfs_register(pVfs, 1);
          595  +    }else{
          596  +      fossil_fatal("no such VFS: \"%s\"", g.zVfsName);
          597  +    }
          598  +  }
   580    599     if( fossil_getenv("GATEWAY_INTERFACE")!=0 && !find_option("nocgi", 0, 0)){
   581    600       zCmdName = "cgi";
   582    601       g.isHTTP = 1;
   583    602     }else if( g.argc<2 ){
   584    603       fossil_print(
   585    604          "Usage: %s COMMAND ...\n"
   586    605          "   or: %s help           -- for a list of common commands\n"
................................................................................
   802    821     }
   803    822     assert(nCmd && "page list is empty?");
   804    823     multi_column_list(aCmd, nCmd);
   805    824   }
   806    825   
   807    826   
   808    827   
          828  +/*
          829  +** This function returns a human readable version string.
          830  +*/
          831  +const char *get_version(){
          832  +  static const char version[] = RELEASE_VERSION " " MANIFEST_VERSION " "
          833  +                                MANIFEST_DATE " UTC";
          834  +  return version;
          835  +}
   809    836   
   810    837   /*
   811    838   ** COMMAND: version
   812    839   **
   813    840   ** Usage: %fossil version ?-verbose|-v?
   814    841   **
   815    842   ** Print the source code version number for the fossil executable.
   816    843   ** If the verbose option is specified, additional details will
   817    844   ** be output about what optional features this binary was compiled
   818    845   ** with
   819    846   */
   820    847   void version_cmd(void){
   821         -  fossil_print("This is fossil version " RELEASE_VERSION " "
   822         -               MANIFEST_VERSION " " MANIFEST_DATE " UTC\n");
          848  +  fossil_print("This is fossil version %s\n", get_version());
   823    849     if(!find_option("verbose","v",0)){
   824    850       return;
   825    851     }else{
   826    852   #if defined(FOSSIL_ENABLE_TCL)
   827    853       int rc;
   828    854       const char *zRc;
   829    855   #endif
   830    856       fossil_print("Compiled on %s %s using %s (%d-bit)\n",
   831    857                    __DATE__, __TIME__, COMPILER_NAME, sizeof(void*)*8);
   832         -    fossil_print("SQLite %s %.30s\n", SQLITE_VERSION, SQLITE_SOURCE_ID);
          858  +    fossil_print("SQLite %s %.30s\n", sqlite3_libversion(), sqlite3_sourceid());
   833    859       fossil_print("Schema version %s\n", AUX_SCHEMA);
   834    860       fossil_print("zlib %s, loaded %s\n", ZLIB_VERSION, zlibVersion());
   835    861   #if defined(FOSSIL_ENABLE_SSL)
   836    862       fossil_print("SSL (%s)\n", OPENSSL_VERSION_TEXT);
   837    863   #endif
   838    864   #if defined(FOSSIL_ENABLE_TCL)
   839    865       Th_FossilInit(TH_INIT_DEFAULT | TH_INIT_FORCE_TCL);

Changes to src/main.mk.

   112    112     $(SRCDIR)/user.c \
   113    113     $(SRCDIR)/utf8.c \
   114    114     $(SRCDIR)/util.c \
   115    115     $(SRCDIR)/verify.c \
   116    116     $(SRCDIR)/vfile.c \
   117    117     $(SRCDIR)/wiki.c \
   118    118     $(SRCDIR)/wikiformat.c \
          119  +  $(SRCDIR)/winfile.c \
   119    120     $(SRCDIR)/winhttp.c \
   120    121     $(SRCDIR)/wysiwyg.c \
   121    122     $(SRCDIR)/xfer.c \
   122    123     $(SRCDIR)/xfersetup.c \
   123    124     $(SRCDIR)/zip.c
   124    125   
   125    126   TRANS_SRC = \
................................................................................
   221    222     $(OBJDIR)/user_.c \
   222    223     $(OBJDIR)/utf8_.c \
   223    224     $(OBJDIR)/util_.c \
   224    225     $(OBJDIR)/verify_.c \
   225    226     $(OBJDIR)/vfile_.c \
   226    227     $(OBJDIR)/wiki_.c \
   227    228     $(OBJDIR)/wikiformat_.c \
          229  +  $(OBJDIR)/winfile_.c \
   228    230     $(OBJDIR)/winhttp_.c \
   229    231     $(OBJDIR)/wysiwyg_.c \
   230    232     $(OBJDIR)/xfer_.c \
   231    233     $(OBJDIR)/xfersetup_.c \
   232    234     $(OBJDIR)/zip_.c
   233    235   
   234    236   OBJ = \
................................................................................
   330    332    $(OBJDIR)/user.o \
   331    333    $(OBJDIR)/utf8.o \
   332    334    $(OBJDIR)/util.o \
   333    335    $(OBJDIR)/verify.o \
   334    336    $(OBJDIR)/vfile.o \
   335    337    $(OBJDIR)/wiki.o \
   336    338    $(OBJDIR)/wikiformat.o \
          339  + $(OBJDIR)/winfile.o \
   337    340    $(OBJDIR)/winhttp.o \
   338    341    $(OBJDIR)/wysiwyg.o \
   339    342    $(OBJDIR)/xfer.o \
   340    343    $(OBJDIR)/xfersetup.o \
   341    344    $(OBJDIR)/zip.o
   342    345   
   343    346   APPNAME = fossil$(E)
................................................................................
   369    372   # build is done from, i.e. the checkout belongs to. Do not sync/push
   370    373   # the repository after running the tests.
   371    374   test:	$(OBJDIR) $(APPNAME)
   372    375   	$(TCLSH) $(SRCDIR)/../test/tester.tcl $(APPNAME)
   373    376   
   374    377   $(OBJDIR)/VERSION.h:	$(SRCDIR)/../manifest.uuid $(SRCDIR)/../manifest $(SRCDIR)/../VERSION $(OBJDIR)/mkversion
   375    378   	$(OBJDIR)/mkversion $(SRCDIR)/../manifest.uuid  $(SRCDIR)/../manifest  $(SRCDIR)/../VERSION >$(OBJDIR)/VERSION.h
          379  +
          380  +# Setup the options used to compile the included SQLite library.
          381  +SQLITE_OPTIONS = -DSQLITE_OMIT_LOAD_EXTENSION=1 \
          382  +                 -DSQLITE_THREADSAFE=0 \
          383  +                 -DSQLITE_DEFAULT_FILE_FORMAT=4 \
          384  +                 -DSQLITE_OMIT_DEPRECATED \
          385  +                 -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
          386  +                 -Dlocaltime=fossil_localtime \
          387  +                 -DSQLITE_ENABLE_LOCKING_STYLE=0
          388  +
          389  +# Setup the options used to compile the included SQLite shell.
          390  +SHELL_OPTIONS = -Dmain=sqlite3_shell \
          391  +                -DSQLITE_OMIT_LOAD_EXTENSION=1 \
          392  +                -Dsqlite3_strglob=strglob
   376    393   
   377    394   # The USE_SYSTEM_SQLITE variable may be undefined, set to 0, or set
   378    395   # to 1. If it is set to 1, then there is no need to build or link
   379    396   # the sqlite3.o object. Instead, the system sqlite will be linked
   380    397   # using -lsqlite3.
   381    398   SQLITE3_OBJ.1 = 
   382    399   SQLITE3_OBJ.0 = $(OBJDIR)/sqlite3.o
................................................................................
   403    420   clean:	
   404    421   	rm -rf $(OBJDIR)/* $(APPNAME)
   405    422   
   406    423   
   407    424   $(OBJDIR)/page_index.h: $(TRANS_SRC) $(OBJDIR)/mkindex
   408    425   	$(OBJDIR)/mkindex $(TRANS_SRC) >$@
   409    426   $(OBJDIR)/headers:	$(OBJDIR)/page_index.h $(OBJDIR)/makeheaders $(OBJDIR)/VERSION.h
   410         -	$(OBJDIR)/makeheaders  $(OBJDIR)/add_.c:$(OBJDIR)/add.h $(OBJDIR)/allrepo_.c:$(OBJDIR)/allrepo.h $(OBJDIR)/attach_.c:$(OBJDIR)/attach.h $(OBJDIR)/bag_.c:$(OBJDIR)/bag.h $(OBJDIR)/bisect_.c:$(OBJDIR)/bisect.h $(OBJDIR)/blob_.c:$(OBJDIR)/blob.h $(OBJDIR)/branch_.c:$(OBJDIR)/branch.h $(OBJDIR)/browse_.c:$(OBJDIR)/browse.h $(OBJDIR)/captcha_.c:$(OBJDIR)/captcha.h $(OBJDIR)/cgi_.c:$(OBJDIR)/cgi.h $(OBJDIR)/checkin_.c:$(OBJDIR)/checkin.h $(OBJDIR)/checkout_.c:$(OBJDIR)/checkout.h $(OBJDIR)/clearsign_.c:$(OBJDIR)/clearsign.h $(OBJDIR)/clone_.c:$(OBJDIR)/clone.h $(OBJDIR)/comformat_.c:$(OBJDIR)/comformat.h $(OBJDIR)/configure_.c:$(OBJDIR)/configure.h $(OBJDIR)/content_.c:$(OBJDIR)/content.h $(OBJDIR)/db_.c:$(OBJDIR)/db.h $(OBJDIR)/delta_.c:$(OBJDIR)/delta.h $(OBJDIR)/deltacmd_.c:$(OBJDIR)/deltacmd.h $(OBJDIR)/descendants_.c:$(OBJDIR)/descendants.h $(OBJDIR)/diff_.c:$(OBJDIR)/diff.h $(OBJDIR)/diffcmd_.c:$(OBJDIR)/diffcmd.h $(OBJDIR)/doc_.c:$(OBJDIR)/doc.h $(OBJDIR)/encode_.c:$(OBJDIR)/encode.h $(OBJDIR)/event_.c:$(OBJDIR)/event.h $(OBJDIR)/export_.c:$(OBJDIR)/export.h $(OBJDIR)/file_.c:$(OBJDIR)/file.h $(OBJDIR)/finfo_.c:$(OBJDIR)/finfo.h $(OBJDIR)/glob_.c:$(OBJDIR)/glob.h $(OBJDIR)/graph_.c:$(OBJDIR)/graph.h $(OBJDIR)/gzip_.c:$(OBJDIR)/gzip.h $(OBJDIR)/http_.c:$(OBJDIR)/http.h $(OBJDIR)/http_socket_.c:$(OBJDIR)/http_socket.h $(OBJDIR)/http_ssl_.c:$(OBJDIR)/http_ssl.h $(OBJDIR)/http_transport_.c:$(OBJDIR)/http_transport.h $(OBJDIR)/import_.c:$(OBJDIR)/import.h $(OBJDIR)/info_.c:$(OBJDIR)/info.h $(OBJDIR)/json_.c:$(OBJDIR)/json.h $(OBJDIR)/json_artifact_.c:$(OBJDIR)/json_artifact.h $(OBJDIR)/json_branch_.c:$(OBJDIR)/json_branch.h $(OBJDIR)/json_config_.c:$(OBJDIR)/json_config.h $(OBJDIR)/json_diff_.c:$(OBJDIR)/json_diff.h $(OBJDIR)/json_dir_.c:$(OBJDIR)/json_dir.h $(OBJDIR)/json_finfo_.c:$(OBJDIR)/json_finfo.h $(OBJDIR)/json_login_.c:$(OBJDIR)/json_login.h $(OBJDIR)/json_query_.c:$(OBJDIR)/json_query.h $(OBJDIR)/json_report_.c:$(OBJDIR)/json_report.h $(OBJDIR)/json_status_.c:$(OBJDIR)/json_status.h $(OBJDIR)/json_tag_.c:$(OBJDIR)/json_tag.h $(OBJDIR)/json_timeline_.c:$(OBJDIR)/json_timeline.h $(OBJDIR)/json_user_.c:$(OBJDIR)/json_user.h $(OBJDIR)/json_wiki_.c:$(OBJDIR)/json_wiki.h $(OBJDIR)/leaf_.c:$(OBJDIR)/leaf.h $(OBJDIR)/login_.c:$(OBJDIR)/login.h $(OBJDIR)/lookslike_.c:$(OBJDIR)/lookslike.h $(OBJDIR)/main_.c:$(OBJDIR)/main.h $(OBJDIR)/manifest_.c:$(OBJDIR)/manifest.h $(OBJDIR)/markdown_.c:$(OBJDIR)/markdown.h $(OBJDIR)/markdown_html_.c:$(OBJDIR)/markdown_html.h $(OBJDIR)/md5_.c:$(OBJDIR)/md5.h $(OBJDIR)/merge_.c:$(OBJDIR)/merge.h $(OBJDIR)/merge3_.c:$(OBJDIR)/merge3.h $(OBJDIR)/moderate_.c:$(OBJDIR)/moderate.h $(OBJDIR)/name_.c:$(OBJDIR)/name.h $(OBJDIR)/path_.c:$(OBJDIR)/path.h $(OBJDIR)/pivot_.c:$(OBJDIR)/pivot.h $(OBJDIR)/popen_.c:$(OBJDIR)/popen.h $(OBJDIR)/pqueue_.c:$(OBJDIR)/pqueue.h $(OBJDIR)/printf_.c:$(OBJDIR)/printf.h $(OBJDIR)/rebuild_.c:$(OBJDIR)/rebuild.h $(OBJDIR)/regexp_.c:$(OBJDIR)/regexp.h $(OBJDIR)/report_.c:$(OBJDIR)/report.h $(OBJDIR)/rss_.c:$(OBJDIR)/rss.h $(OBJDIR)/schema_.c:$(OBJDIR)/schema.h $(OBJDIR)/search_.c:$(OBJDIR)/search.h $(OBJDIR)/setup_.c:$(OBJDIR)/setup.h $(OBJDIR)/sha1_.c:$(OBJDIR)/sha1.h $(OBJDIR)/shun_.c:$(OBJDIR)/shun.h $(OBJDIR)/skins_.c:$(OBJDIR)/skins.h $(OBJDIR)/sqlcmd_.c:$(OBJDIR)/sqlcmd.h $(OBJDIR)/stash_.c:$(OBJDIR)/stash.h $(OBJDIR)/stat_.c:$(OBJDIR)/stat.h $(OBJDIR)/style_.c:$(OBJDIR)/style.h $(OBJDIR)/sync_.c:$(OBJDIR)/sync.h $(OBJDIR)/tag_.c:$(OBJDIR)/tag.h $(OBJDIR)/tar_.c:$(OBJDIR)/tar.h $(OBJDIR)/th_main_.c:$(OBJDIR)/th_main.h $(OBJDIR)/timeline_.c:$(OBJDIR)/timeline.h $(OBJDIR)/tkt_.c:$(OBJDIR)/tkt.h $(OBJDIR)/tktsetup_.c:$(OBJDIR)/tktsetup.h $(OBJDIR)/undo_.c:$(OBJDIR)/undo.h $(OBJDIR)/unicode_.c:$(OBJDIR)/unicode.h $(OBJDIR)/update_.c:$(OBJDIR)/update.h $(OBJDIR)/url_.c:$(OBJDIR)/url.h $(OBJDIR)/user_.c:$(OBJDIR)/user.h $(OBJDIR)/utf8_.c:$(OBJDIR)/utf8.h $(OBJDIR)/util_.c:$(OBJDIR)/util.h $(OBJDIR)/verify_.c:$(OBJDIR)/verify.h $(OBJDIR)/vfile_.c:$(OBJDIR)/vfile.h $(OBJDIR)/wiki_.c:$(OBJDIR)/wiki.h $(OBJDIR)/wikiformat_.c:$(OBJDIR)/wikiformat.h $(OBJDIR)/winhttp_.c:$(OBJDIR)/winhttp.h $(OBJDIR)/wysiwyg_.c:$(OBJDIR)/wysiwyg.h $(OBJDIR)/xfer_.c:$(OBJDIR)/xfer.h $(OBJDIR)/xfersetup_.c:$(OBJDIR)/xfersetup.h $(OBJDIR)/zip_.c:$(OBJDIR)/zip.h $(SRCDIR)/sqlite3.h $(SRCDIR)/th.h $(OBJDIR)/VERSION.h
          427  +	$(OBJDIR)/makeheaders  $(OBJDIR)/add_.c:$(OBJDIR)/add.h $(OBJDIR)/allrepo_.c:$(OBJDIR)/allrepo.h $(OBJDIR)/attach_.c:$(OBJDIR)/attach.h $(OBJDIR)/bag_.c:$(OBJDIR)/bag.h $(OBJDIR)/bisect_.c:$(OBJDIR)/bisect.h $(OBJDIR)/blob_.c:$(OBJDIR)/blob.h $(OBJDIR)/branch_.c:$(OBJDIR)/branch.h $(OBJDIR)/browse_.c:$(OBJDIR)/browse.h $(OBJDIR)/captcha_.c:$(OBJDIR)/captcha.h $(OBJDIR)/cgi_.c:$(OBJDIR)/cgi.h $(OBJDIR)/checkin_.c:$(OBJDIR)/checkin.h $(OBJDIR)/checkout_.c:$(OBJDIR)/checkout.h $(OBJDIR)/clearsign_.c:$(OBJDIR)/clearsign.h $(OBJDIR)/clone_.c:$(OBJDIR)/clone.h $(OBJDIR)/comformat_.c:$(OBJDIR)/comformat.h $(OBJDIR)/configure_.c:$(OBJDIR)/configure.h $(OBJDIR)/content_.c:$(OBJDIR)/content.h $(OBJDIR)/db_.c:$(OBJDIR)/db.h $(OBJDIR)/delta_.c:$(OBJDIR)/delta.h $(OBJDIR)/deltacmd_.c:$(OBJDIR)/deltacmd.h $(OBJDIR)/descendants_.c:$(OBJDIR)/descendants.h $(OBJDIR)/diff_.c:$(OBJDIR)/diff.h $(OBJDIR)/diffcmd_.c:$(OBJDIR)/diffcmd.h $(OBJDIR)/doc_.c:$(OBJDIR)/doc.h $(OBJDIR)/encode_.c:$(OBJDIR)/encode.h $(OBJDIR)/event_.c:$(OBJDIR)/event.h $(OBJDIR)/export_.c:$(OBJDIR)/export.h $(OBJDIR)/file_.c:$(OBJDIR)/file.h $(OBJDIR)/finfo_.c:$(OBJDIR)/finfo.h $(OBJDIR)/glob_.c:$(OBJDIR)/glob.h $(OBJDIR)/graph_.c:$(OBJDIR)/graph.h $(OBJDIR)/gzip_.c:$(OBJDIR)/gzip.h $(OBJDIR)/http_.c:$(OBJDIR)/http.h $(OBJDIR)/http_socket_.c:$(OBJDIR)/http_socket.h $(OBJDIR)/http_ssl_.c:$(OBJDIR)/http_ssl.h $(OBJDIR)/http_transport_.c:$(OBJDIR)/http_transport.h $(OBJDIR)/import_.c:$(OBJDIR)/import.h $(OBJDIR)/info_.c:$(OBJDIR)/info.h $(OBJDIR)/json_.c:$(OBJDIR)/json.h $(OBJDIR)/json_artifact_.c:$(OBJDIR)/json_artifact.h $(OBJDIR)/json_branch_.c:$(OBJDIR)/json_branch.h $(OBJDIR)/json_config_.c:$(OBJDIR)/json_config.h $(OBJDIR)/json_diff_.c:$(OBJDIR)/json_diff.h $(OBJDIR)/json_dir_.c:$(OBJDIR)/json_dir.h $(OBJDIR)/json_finfo_.c:$(OBJDIR)/json_finfo.h $(OBJDIR)/json_login_.c:$(OBJDIR)/json_login.h $(OBJDIR)/json_query_.c:$(OBJDIR)/json_query.h $(OBJDIR)/json_report_.c:$(OBJDIR)/json_report.h $(OBJDIR)/json_status_.c:$(OBJDIR)/json_status.h $(OBJDIR)/json_tag_.c:$(OBJDIR)/json_tag.h $(OBJDIR)/json_timeline_.c:$(OBJDIR)/json_timeline.h $(OBJDIR)/json_user_.c:$(OBJDIR)/json_user.h $(OBJDIR)/json_wiki_.c:$(OBJDIR)/json_wiki.h $(OBJDIR)/leaf_.c:$(OBJDIR)/leaf.h $(OBJDIR)/login_.c:$(OBJDIR)/login.h $(OBJDIR)/lookslike_.c:$(OBJDIR)/lookslike.h $(OBJDIR)/main_.c:$(OBJDIR)/main.h $(OBJDIR)/manifest_.c:$(OBJDIR)/manifest.h $(OBJDIR)/markdown_.c:$(OBJDIR)/markdown.h $(OBJDIR)/markdown_html_.c:$(OBJDIR)/markdown_html.h $(OBJDIR)/md5_.c:$(OBJDIR)/md5.h $(OBJDIR)/merge_.c:$(OBJDIR)/merge.h $(OBJDIR)/merge3_.c:$(OBJDIR)/merge3.h $(OBJDIR)/moderate_.c:$(OBJDIR)/moderate.h $(OBJDIR)/name_.c:$(OBJDIR)/name.h $(OBJDIR)/path_.c:$(OBJDIR)/path.h $(OBJDIR)/pivot_.c:$(OBJDIR)/pivot.h $(OBJDIR)/popen_.c:$(OBJDIR)/popen.h $(OBJDIR)/pqueue_.c:$(OBJDIR)/pqueue.h $(OBJDIR)/printf_.c:$(OBJDIR)/printf.h $(OBJDIR)/rebuild_.c:$(OBJDIR)/rebuild.h $(OBJDIR)/regexp_.c:$(OBJDIR)/regexp.h $(OBJDIR)/report_.c:$(OBJDIR)/report.h $(OBJDIR)/rss_.c:$(OBJDIR)/rss.h $(OBJDIR)/schema_.c:$(OBJDIR)/schema.h $(OBJDIR)/search_.c:$(OBJDIR)/search.h $(OBJDIR)/setup_.c:$(OBJDIR)/setup.h $(OBJDIR)/sha1_.c:$(OBJDIR)/sha1.h $(OBJDIR)/shun_.c:$(OBJDIR)/shun.h $(OBJDIR)/skins_.c:$(OBJDIR)/skins.h $(OBJDIR)/sqlcmd_.c:$(OBJDIR)/sqlcmd.h $(OBJDIR)/stash_.c:$(OBJDIR)/stash.h $(OBJDIR)/stat_.c:$(OBJDIR)/stat.h $(OBJDIR)/style_.c:$(OBJDIR)/style.h $(OBJDIR)/sync_.c:$(OBJDIR)/sync.h $(OBJDIR)/tag_.c:$(OBJDIR)/tag.h $(OBJDIR)/tar_.c:$(OBJDIR)/tar.h $(OBJDIR)/th_main_.c:$(OBJDIR)/th_main.h $(OBJDIR)/timeline_.c:$(OBJDIR)/timeline.h $(OBJDIR)/tkt_.c:$(OBJDIR)/tkt.h $(OBJDIR)/tktsetup_.c:$(OBJDIR)/tktsetup.h $(OBJDIR)/undo_.c:$(OBJDIR)/undo.h $(OBJDIR)/unicode_.c:$(OBJDIR)/unicode.h $(OBJDIR)/update_.c:$(OBJDIR)/update.h $(OBJDIR)/url_.c:$(OBJDIR)/url.h $(OBJDIR)/user_.c:$(OBJDIR)/user.h $(OBJDIR)/utf8_.c:$(OBJDIR)/utf8.h $(OBJDIR)/util_.c:$(OBJDIR)/util.h $(OBJDIR)/verify_.c:$(OBJDIR)/verify.h $(OBJDIR)/vfile_.c:$(OBJDIR)/vfile.h $(OBJDIR)/wiki_.c:$(OBJDIR)/wiki.h $(OBJDIR)/wikiformat_.c:$(OBJDIR)/wikiformat.h $(OBJDIR)/winfile_.c:$(OBJDIR)/winfile.h $(OBJDIR)/winhttp_.c:$(OBJDIR)/winhttp.h $(OBJDIR)/wysiwyg_.c:$(OBJDIR)/wysiwyg.h $(OBJDIR)/xfer_.c:$(OBJDIR)/xfer.h $(OBJDIR)/xfersetup_.c:$(OBJDIR)/xfersetup.h $(OBJDIR)/zip_.c:$(OBJDIR)/zip.h $(SRCDIR)/sqlite3.h $(SRCDIR)/th.h $(OBJDIR)/VERSION.h
   411    428   	touch $(OBJDIR)/headers
   412    429   $(OBJDIR)/headers: Makefile
   413    430   $(OBJDIR)/json.o $(OBJDIR)/json_artifact.o $(OBJDIR)/json_branch.o $(OBJDIR)/json_config.o $(OBJDIR)/json_diff.o $(OBJDIR)/json_dir.o $(OBJDIR)/json_finfo.o $(OBJDIR)/json_login.o $(OBJDIR)/json_query.o $(OBJDIR)/json_report.o $(OBJDIR)/json_status.o $(OBJDIR)/json_tag.o $(OBJDIR)/json_timeline.o $(OBJDIR)/json_user.o $(OBJDIR)/json_wiki.o : $(SRCDIR)/json_detail.h
   414    431   Makefile:
   415    432   $(OBJDIR)/add_.c:	$(SRCDIR)/add.c $(OBJDIR)/translate
   416    433   	$(OBJDIR)/translate $(SRCDIR)/add.c >$(OBJDIR)/add_.c
   417    434   
................................................................................
  1122   1139   $(OBJDIR)/wikiformat_.c:	$(SRCDIR)/wikiformat.c $(OBJDIR)/translate
  1123   1140   	$(OBJDIR)/translate $(SRCDIR)/wikiformat.c >$(OBJDIR)/wikiformat_.c
  1124   1141   
  1125   1142   $(OBJDIR)/wikiformat.o:	$(OBJDIR)/wikiformat_.c $(OBJDIR)/wikiformat.h  $(SRCDIR)/config.h
  1126   1143   	$(XTCC) -o $(OBJDIR)/wikiformat.o -c $(OBJDIR)/wikiformat_.c
  1127   1144   
  1128   1145   $(OBJDIR)/wikiformat.h:	$(OBJDIR)/headers
         1146  +$(OBJDIR)/winfile_.c:	$(SRCDIR)/winfile.c $(OBJDIR)/translate
         1147  +	$(OBJDIR)/translate $(SRCDIR)/winfile.c >$(OBJDIR)/winfile_.c
         1148  +
         1149  +$(OBJDIR)/winfile.o:	$(OBJDIR)/winfile_.c $(OBJDIR)/winfile.h  $(SRCDIR)/config.h
         1150  +	$(XTCC) -o $(OBJDIR)/winfile.o -c $(OBJDIR)/winfile_.c
         1151  +
         1152  +$(OBJDIR)/winfile.h:	$(OBJDIR)/headers
  1129   1153   $(OBJDIR)/winhttp_.c:	$(SRCDIR)/winhttp.c $(OBJDIR)/translate
  1130   1154   	$(OBJDIR)/translate $(SRCDIR)/winhttp.c >$(OBJDIR)/winhttp_.c
  1131   1155   
  1132   1156   $(OBJDIR)/winhttp.o:	$(OBJDIR)/winhttp_.c $(OBJDIR)/winhttp.h  $(SRCDIR)/config.h
  1133   1157   	$(XTCC) -o $(OBJDIR)/winhttp.o -c $(OBJDIR)/winhttp_.c
  1134   1158   
  1135   1159   $(OBJDIR)/winhttp.h:	$(OBJDIR)/headers
................................................................................
  1158   1182   	$(OBJDIR)/translate $(SRCDIR)/zip.c >$(OBJDIR)/zip_.c
  1159   1183   
  1160   1184   $(OBJDIR)/zip.o:	$(OBJDIR)/zip_.c $(OBJDIR)/zip.h  $(SRCDIR)/config.h
  1161   1185   	$(XTCC) -o $(OBJDIR)/zip.o -c $(OBJDIR)/zip_.c
  1162   1186   
  1163   1187   $(OBJDIR)/zip.h:	$(OBJDIR)/headers
  1164   1188   $(OBJDIR)/sqlite3.o:	$(SRCDIR)/sqlite3.c
  1165         -	$(XTCC) -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_STAT3 -Dlocaltime=fossil_localtime -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_WIN32_NO_ANSI -c $(SRCDIR)/sqlite3.c -o $(OBJDIR)/sqlite3.o
         1189  +	$(XTCC) $(SQLITE_OPTIONS) $(SQLITE_CFLAGS) -c $(SRCDIR)/sqlite3.c -o $(OBJDIR)/sqlite3.o
  1166   1190   
  1167   1191   $(OBJDIR)/shell.o:	$(SRCDIR)/shell.c $(SRCDIR)/sqlite3.h
  1168         -	$(XTCC) -Dmain=sqlite3_shell -DSQLITE_OMIT_LOAD_EXTENSION=1 -Dsqlite3_strglob=strglob -c $(SRCDIR)/shell.c -o $(OBJDIR)/shell.o
         1192  +	$(XTCC) $(SHELL_OPTIONS) $(SHELL_CFLAGS) -c $(SRCDIR)/shell.c -o $(OBJDIR)/shell.o
  1169   1193   
  1170   1194   $(OBJDIR)/th.o:	$(SRCDIR)/th.c
  1171   1195   	$(XTCC) -c $(SRCDIR)/th.c -o $(OBJDIR)/th.o
  1172   1196   
  1173   1197   $(OBJDIR)/th_lang.o:	$(SRCDIR)/th_lang.c
  1174   1198   	$(XTCC) -c $(SRCDIR)/th_lang.c -o $(OBJDIR)/th_lang.o
  1175   1199   

Changes to src/makemake.tcl.

   115    115     user
   116    116     utf8
   117    117     util
   118    118     verify
   119    119     vfile
   120    120     wiki
   121    121     wikiformat
          122  +  winfile
   122    123     winhttp
   123    124     wysiwyg
   124    125     xfer
   125    126     xfersetup
   126    127     zip
   127    128     http_ssl
   128    129   }
          130  +
          131  +# Options used to compile the included SQLite library.
          132  +#
          133  +set SQLITE_OPTIONS {
          134  +  -DSQLITE_OMIT_LOAD_EXTENSION=1
          135  +  -DSQLITE_THREADSAFE=0
          136  +  -DSQLITE_DEFAULT_FILE_FORMAT=4
          137  +  -DSQLITE_OMIT_DEPRECATED
          138  +  -DSQLITE_ENABLE_EXPLAIN_COMMENTS
          139  +  -Dlocaltime=fossil_localtime
          140  +  -DSQLITE_ENABLE_LOCKING_STYLE=0
          141  +}
          142  +#lappend SQLITE_OPTIONS -DSQLITE_ENABLE_FTS3=1
          143  +#lappend SQLITE_OPTIONS -DSQLITE_ENABLE_STAT4
          144  +#lappend SQLITE_OPTIONS -DSQLITE_WIN32_NO_ANSI
          145  +#lappend SQLITE_OPTIONS -DSQLITE_WINNT_MAX_PATH_CHARS=4096
          146  +
          147  +# Options used to compile the included SQLite shell.
          148  +#
          149  +set SHELL_OPTIONS {
          150  +  -Dmain=sqlite3_shell
          151  +  -DSQLITE_OMIT_LOAD_EXTENSION=1
          152  +  -Dsqlite3_strglob=strglob
          153  +}
          154  +
          155  +# Options used to compile the included SQLite shell on Windows.
          156  +#
          157  +set SHELL_WIN32_OPTIONS $SHELL_OPTIONS
          158  +lappend SHELL_WIN32_OPTIONS -Dgetenv=fossil_getenv
          159  +lappend SHELL_WIN32_OPTIONS -Dfopen=fossil_fopen
   129    160   
   130    161   # Name of the final application
   131    162   #
   132    163   set name fossil
   133    164   
   134    165   # The "writeln" command sends output to the target makefile.
   135    166   #
................................................................................
   184    215   foreach s [lsort $src] {
   185    216     writeln -nonewline " \\\n \$(OBJDIR)/$s.o"
   186    217   }
   187    218   writeln "\n"
   188    219   writeln "APPNAME = $name\$(E)"
   189    220   writeln "\n"
   190    221   
   191         -writeln {
          222  +writeln [string map [list \
          223  +    <<<SQLITE_OPTIONS>>> [join $SQLITE_OPTIONS " \\\n                 "] \
          224  +    <<<SHELL_OPTIONS>>> [join $SHELL_OPTIONS " \\\n                "]] {
   192    225   all:	$(OBJDIR) $(APPNAME)
   193    226   
   194    227   install:	$(APPNAME)
   195    228   	mkdir -p $(INSTALLDIR)
   196    229   	mv $(APPNAME) $(INSTALLDIR)
   197    230   
   198    231   $(OBJDIR):
................................................................................
   216    249   test:	$(OBJDIR) $(APPNAME)
   217    250   	$(TCLSH) $(SRCDIR)/../test/tester.tcl $(APPNAME)
   218    251   
   219    252   $(OBJDIR)/VERSION.h:	$(SRCDIR)/../manifest.uuid $(SRCDIR)/../manifest $(SRCDIR)/../VERSION $(OBJDIR)/mkversion
   220    253   	$(OBJDIR)/mkversion $(SRCDIR)/../manifest.uuid \
   221    254   		$(SRCDIR)/../manifest \
   222    255   		$(SRCDIR)/../VERSION >$(OBJDIR)/VERSION.h
          256  +
          257  +# Setup the options used to compile the included SQLite library.
          258  +SQLITE_OPTIONS = <<<SQLITE_OPTIONS>>>
          259  +
          260  +# Setup the options used to compile the included SQLite shell.
          261  +SHELL_OPTIONS = <<<SHELL_OPTIONS>>>
   223    262   
   224    263   # The USE_SYSTEM_SQLITE variable may be undefined, set to 0, or set
   225    264   # to 1. If it is set to 1, then there is no need to build or link
   226    265   # the sqlite3.o object. Instead, the system sqlite will be linked
   227    266   # using -lsqlite3.
   228    267   SQLITE3_OBJ.1 = 
   229    268   SQLITE3_OBJ.0 = $(OBJDIR)/sqlite3.o
................................................................................
   252    291   #
   253    292   $(SRCDIR)/../manifest:	
   254    293   	# noop
   255    294   
   256    295   clean:	
   257    296   	rm -rf $(OBJDIR)/* $(APPNAME)
   258    297   
   259         -}
          298  +}]
   260    299   
   261    300   set mhargs {}
   262    301   foreach s [lsort $src] {
   263    302     append mhargs " \$(OBJDIR)/${s}_.c:\$(OBJDIR)/$s.h"
   264    303     set extra_h($s) {}
   265    304   }
   266    305   append mhargs " \$(SRCDIR)/sqlite3.h"
................................................................................
   281    320     writeln "\$(OBJDIR)/${s}_.c:\t\$(SRCDIR)/$s.c \$(OBJDIR)/translate"
   282    321     writeln "\t\$(OBJDIR)/translate \$(SRCDIR)/$s.c >\$(OBJDIR)/${s}_.c\n"
   283    322     writeln "\$(OBJDIR)/$s.o:\t\$(OBJDIR)/${s}_.c \$(OBJDIR)/$s.h $extra_h($s) \$(SRCDIR)/config.h"
   284    323     writeln "\t\$(XTCC) -o \$(OBJDIR)/$s.o -c \$(OBJDIR)/${s}_.c\n"
   285    324     writeln "\$(OBJDIR)/$s.h:\t\$(OBJDIR)/headers"
   286    325   }
   287    326   
   288         -
   289    327   writeln "\$(OBJDIR)/sqlite3.o:\t\$(SRCDIR)/sqlite3.c"
   290         -set opt {-DSQLITE_OMIT_LOAD_EXTENSION=1}
   291         -append opt " -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4"
   292         -#append opt " -DSQLITE_ENABLE_FTS3=1"
   293         -append opt " -DSQLITE_ENABLE_STAT3"
   294         -append opt " -Dlocaltime=fossil_localtime"
   295         -append opt " -DSQLITE_ENABLE_LOCKING_STYLE=0"
   296         -append opt " -DSQLITE_WIN32_NO_ANSI"
   297         -set SQLITE_OPTIONS $opt
   298         -writeln "\t\$(XTCC) $opt -c \$(SRCDIR)/sqlite3.c -o \$(OBJDIR)/sqlite3.o\n"
          328  +writeln "\t\$(XTCC) \$(SQLITE_OPTIONS) \$(SQLITE_CFLAGS) -c \$(SRCDIR)/sqlite3.c -o \$(OBJDIR)/sqlite3.o\n"
   299    329   
   300    330   writeln "\$(OBJDIR)/shell.o:\t\$(SRCDIR)/shell.c \$(SRCDIR)/sqlite3.h"
   301         -set opt {-Dmain=sqlite3_shell}
   302         -append opt " -DSQLITE_OMIT_LOAD_EXTENSION=1"
   303         -append opt " -Dsqlite3_strglob=strglob"
   304         -writeln "\t\$(XTCC) $opt -c \$(SRCDIR)/shell.c -o \$(OBJDIR)/shell.o\n"
          331  +writeln "\t\$(XTCC) \$(SHELL_OPTIONS) \$(SHELL_CFLAGS) -c \$(SRCDIR)/shell.c -o \$(OBJDIR)/shell.o\n"
   305    332   
   306    333   writeln "\$(OBJDIR)/th.o:\t\$(SRCDIR)/th.c"
   307    334   writeln "\t\$(XTCC) -c \$(SRCDIR)/th.c -o \$(OBJDIR)/th.o\n"
   308    335   
   309    336   writeln "\$(OBJDIR)/th_lang.o:\t\$(SRCDIR)/th_lang.c"
   310    337   writeln "\t\$(XTCC) -c \$(SRCDIR)/th_lang.c -o \$(OBJDIR)/th_lang.o\n"
   311    338   
   312    339   writeln "\$(OBJDIR)/th_tcl.o:\t\$(SRCDIR)/th_tcl.c"
   313    340   writeln "\t\$(XTCC) -c \$(SRCDIR)/th_tcl.c -o \$(OBJDIR)/th_tcl.o\n"
   314    341   
   315         -set opt {}
   316    342   writeln {
   317    343   $(OBJDIR)/cson_amalgamation.o: $(SRCDIR)/cson_amalgamation.c
   318    344   	$(XTCC) -c $(SRCDIR)/cson_amalgamation.c -o $(OBJDIR)/cson_amalgamation.o
   319    345   
   320    346   #
   321    347   # The list of all the targets that do not correspond to real files. This stops
   322    348   # 'make' from getting confused when someone makes an error in a rule.
................................................................................
   644    670   writeln {
   645    671   all:	$(OBJDIR) $(APPNAME)
   646    672   
   647    673   $(OBJDIR)/fossil.o:	$(SRCDIR)/../win/fossil.rc $(OBJDIR)/VERSION.h
   648    674   ifdef USE_WINDOWS
   649    675   	$(CP) $(subst /,\,$(SRCDIR)\..\win\fossil.rc) $(subst /,\,$(OBJDIR))
   650    676   	$(CP) $(subst /,\,$(SRCDIR)\..\win\fossil.ico) $(subst /,\,$(OBJDIR))
          677  +	$(CP) $(subst /,\,$(SRCDIR)\..\win\fossil.exe.manifest) $(subst /,\,$(OBJDIR))
   651    678   else
   652    679   	$(CP) $(SRCDIR)/../win/fossil.rc $(OBJDIR)
   653    680   	$(CP) $(SRCDIR)/../win/fossil.ico $(OBJDIR)
          681  +	$(CP) $(SRCDIR)/../win/fossil.exe.manifest $(OBJDIR)
   654    682   endif
   655    683   	$(RCC) $(OBJDIR)/fossil.rc -o $(OBJDIR)/fossil.o
   656    684   
   657    685   install:	$(OBJDIR) $(APPNAME)
   658    686   ifdef USE_WINDOWS
   659    687   	$(MKDIR) $(subst /,\,$(INSTALLDIR))
   660    688   	$(MV) $(subst /,\,$(APPNAME)) $(subst /,\,$(INSTALLDIR))
................................................................................
   766    794     writeln "\$(OBJDIR)/${s}_.c:\t\$(SRCDIR)/$s.c \$(OBJDIR)/translate"
   767    795     writeln "\t\$(TRANSLATE) \$(SRCDIR)/$s.c >\$(OBJDIR)/${s}_.c\n"
   768    796     writeln "\$(OBJDIR)/$s.o:\t\$(OBJDIR)/${s}_.c \$(OBJDIR)/$s.h $extra_h($s) \$(SRCDIR)/config.h"
   769    797     writeln "\t\$(XTCC) -o \$(OBJDIR)/$s.o -c \$(OBJDIR)/${s}_.c\n"
   770    798     writeln "\$(OBJDIR)/${s}.h:\t\$(OBJDIR)/headers\n"
   771    799   }
   772    800   
          801  +set MINGW_SQLITE_OPTIONS $SQLITE_OPTIONS
          802  +lappend MINGW_SQLITE_OPTIONS -D_HAVE_SQLITE_CONFIG_H
          803  +lappend MINGW_SQLITE_OPTIONS -DSQLITE_USE_MALLOC_H
          804  +lappend MINGW_SQLITE_OPTIONS -DSQLITE_USE_MSIZE
          805  +
          806  +set j " \\\n                 "
          807  +writeln "SQLITE_OPTIONS = [join $MINGW_SQLITE_OPTIONS $j]\n"
          808  +set j " \\\n                "
          809  +writeln "SHELL_OPTIONS = [join $SHELL_WIN32_OPTIONS $j]\n"
   773    810   
   774    811   writeln "\$(OBJDIR)/sqlite3.o:\t\$(SRCDIR)/sqlite3.c"
   775         -set opt $SQLITE_OPTIONS
   776         -append opt " -D_HAVE_SQLITE_CONFIG_H"
   777         -writeln "\t\$(XTCC) $opt -c \$(SRCDIR)/sqlite3.c -o \$(OBJDIR)/sqlite3.o\n"
          812  +writeln "\t\$(XTCC) \$(SQLITE_OPTIONS) \$(SQLITE_CFLAGS) -c \$(SRCDIR)/sqlite3.c -o \$(OBJDIR)/sqlite3.o\n"
   778    813   
   779         -set opt {}
   780    814   writeln "\$(OBJDIR)/cson_amalgamation.o:\t\$(SRCDIR)/cson_amalgamation.c"
   781         -writeln "\t\$(XTCC) $opt -c \$(SRCDIR)/cson_amalgamation.c -o \$(OBJDIR)/cson_amalgamation.o\n"
          815  +writeln "\t\$(XTCC) -c \$(SRCDIR)/cson_amalgamation.c -o \$(OBJDIR)/cson_amalgamation.o\n"
   782    816   writeln "\$(OBJDIR)/json.o \$(OBJDIR)/json_artifact.o \$(OBJDIR)/json_branch.o \$(OBJDIR)/json_config.o \$(OBJDIR)/json_diff.o \$(OBJDIR)/json_dir.o \$(OBJDIR)/jsos_finfo.o \$(OBJDIR)/json_login.o \$(OBJDIR)/json_query.o \$(OBJDIR)/json_report.o \$(OBJDIR)/json_status.o \$(OBJDIR)/json_tag.o \$(OBJDIR)/json_timeline.o \$(OBJDIR)/json_user.o \$(OBJDIR)/json_wiki.o : \$(SRCDIR)/json_detail.h\n"
   783    817   
   784    818   writeln "\$(OBJDIR)/shell.o:\t\$(SRCDIR)/shell.c \$(SRCDIR)/sqlite3.h"
   785         -set opt {-Dmain=sqlite3_shell}
   786         -append opt " -DSQLITE_OMIT_LOAD_EXTENSION=1"
   787         -writeln "\t\$(XTCC) $opt -c \$(SRCDIR)/shell.c -o \$(OBJDIR)/shell.o\n"
          819  +writeln "\t\$(XTCC) \$(SHELL_OPTIONS) \$(SHELL_CFLAGS) -c \$(SRCDIR)/shell.c -o \$(OBJDIR)/shell.o\n"
   788    820   
   789    821   writeln "\$(OBJDIR)/th.o:\t\$(SRCDIR)/th.c"
   790    822   writeln "\t\$(XTCC) -c \$(SRCDIR)/th.c -o \$(OBJDIR)/th.o\n"
   791    823   
   792    824   writeln "\$(OBJDIR)/th_lang.o:\t\$(SRCDIR)/th_lang.c"
   793    825   writeln "\t\$(XTCC) -c \$(SRCDIR)/th_lang.c -o \$(OBJDIR)/th_lang.o\n"
   794    826   
................................................................................
   833    865   SSL    =
   834    866   
   835    867   CFLAGS = -o
   836    868   BCC    = $(DMDIR)\bin\dmc $(CFLAGS)
   837    869   TCC    = $(DMDIR)\bin\dmc $(CFLAGS) $(DMCDEF) $(SSL) $(INCL)
   838    870   LIBS   = $(DMDIR)\extra\lib\ zlib wsock32 advapi32
   839    871   }
   840         -writeln "SQLITE_OPTIONS = $SQLITE_OPTIONS\n"
          872  +writeln "SQLITE_OPTIONS = [join $SQLITE_OPTIONS { }]\n"
          873  +writeln "SHELL_OPTIONS = [join $SHELL_WIN32_OPTIONS { }]\n"
   841    874   writeln -nonewline "SRC   = "
   842    875   foreach s [lsort $src] {
   843    876     writeln -nonewline "${s}_.c "
   844    877   }
   845    878   writeln "\n"
   846    879   writeln -nonewline "OBJ   = "
   847    880   foreach s [lsort $src] {
................................................................................
   886    919   mkindex$E: $(SRCDIR)\mkindex.c
   887    920   	$(BCC) -o$@ $**
   888    921   
   889    922   version$E: $B\src\mkversion.c
   890    923   	$(BCC) -o$@ $**
   891    924   
   892    925   $(OBJDIR)\shell$O : $(SRCDIR)\shell.c
   893         -	$(TCC) -o$@ -c -Dmain=sqlite3_shell $(SQLITE_OPTIONS) $**
          926  +	$(TCC) -o$@ -c $(SHELL_OPTIONS) $(SQLITE_OPTIONS) $(SHELL_CFLAGS) $**
   894    927   
   895    928   $(OBJDIR)\sqlite3$O : $(SRCDIR)\sqlite3.c
   896         -	$(TCC) -o$@ -c $(SQLITE_OPTIONS) $**
          929  +	$(TCC) -o$@ -c $(SQLITE_OPTIONS) $(SQLITE_CFLAGS) $**
   897    930   
   898    931   $(OBJDIR)\th$O : $(SRCDIR)\th.c
   899    932   	$(TCC) -o$@ -c $**
   900    933   
   901    934   $(OBJDIR)\th_lang$O : $(SRCDIR)\th_lang.c
   902    935   	$(TCC) -o$@ -c $**
   903    936   
................................................................................
  1025   1058   !ifdef FOSSIL_ENABLE_SSL
  1026   1059   TCC       = $(TCC) -DFOSSIL_ENABLE_SSL=1
  1027   1060   RCC       = $(RCC) -DFOSSIL_ENABLE_SSL=1
  1028   1061   LIBS      = $(LIBS) $(SSLLIB)
  1029   1062   LIBDIR    = $(LIBDIR) -LIBPATH:$(SSLLIBDIR)
  1030   1063   !endif
  1031   1064   }
  1032         -regsub -all {[-]D} $SQLITE_OPTIONS {/D} MSC_SQLITE_OPTIONS
         1065  +regsub -all {[-]D} [join $SQLITE_OPTIONS { }] {/D} MSC_SQLITE_OPTIONS
  1033   1066   set j " \\\n                 "
  1034   1067   writeln "SQLITE_OPTIONS = [join $MSC_SQLITE_OPTIONS $j]\n"
         1068  +
         1069  +regsub -all {[-]D} [join $SHELL_WIN32_OPTIONS { }] {/D} MSC_SHELL_OPTIONS
         1070  +set j " \\\n                "
         1071  +writeln "SHELL_OPTIONS = [join $MSC_SHELL_OPTIONS $j]\n"
         1072  +
  1035   1073   writeln -nonewline "SRC   = "
  1036   1074   set i 0
  1037   1075   foreach s [lsort $src] {
  1038   1076     if {$i > 0} {
  1039   1077       writeln " \\"
  1040   1078       writeln -nonewline "        "
  1041   1079     }
................................................................................
  1089   1127   mkindex$E: $(SRCDIR)\mkindex.c
  1090   1128   	$(BCC) $**
  1091   1129   
  1092   1130   mkversion$E: $B\src\mkversion.c
  1093   1131   	$(BCC) $**
  1094   1132   
  1095   1133   $(OX)\shell$O : $(SRCDIR)\shell.c
  1096         -	$(TCC) /Fo$@ /Dmain=sqlite3_shell $(SQLITE_OPTIONS) -c $(SRCDIR)\shell.c
         1134  +	$(TCC) /Fo$@ $(SHELL_OPTIONS) $(SQLITE_OPTIONS) $(SHELL_CFLAGS) -c $(SRCDIR)\shell.c
  1097   1135   
  1098   1136   $(OX)\sqlite3$O : $(SRCDIR)\sqlite3.c
  1099         -	$(TCC) /Fo$@ -c $(SQLITE_OPTIONS) $**
         1137  +	$(TCC) /Fo$@ -c $(SQLITE_OPTIONS) $(SQLITE_CFLAGS) $**
  1100   1138   
  1101   1139   $(OX)\th$O : $(SRCDIR)\th.c
  1102   1140   	$(TCC) /Fo$@ -c $**
  1103   1141   
  1104   1142   $(OX)\th_lang$O : $(SRCDIR)\th_lang.c
  1105   1143   	$(TCC) /Fo$@ -c $**
  1106   1144   
................................................................................
  1114   1152   
  1115   1153   clean:
  1116   1154   	-del $(OX)\*.obj
  1117   1155   	-del *.obj
  1118   1156   	-del *_.c
  1119   1157   	-del *.h
  1120   1158   	-del *.map
  1121         -	-del *.manifest
  1122   1159   	-del headers
  1123   1160   	-del linkopts
  1124   1161   	-del *.res
  1125   1162   
  1126   1163   realclean: clean
  1127   1164   	-del $(APPNAME)
  1128   1165   	-del translate$E
................................................................................
  1182   1219   ##############################################################################
  1183   1220   # Begin win/Makefile.PellesCGMake output
  1184   1221   #
  1185   1222   puts "building ../win/Makefile.PellesCGMake"
  1186   1223   set output_file [open ../win/Makefile.PellesCGMake w]
  1187   1224   fconfigure $output_file -translation binary
  1188   1225   
  1189         -writeln {#
         1226  +writeln [string map [list \
         1227  +    <<<SQLITE_OPTIONS>>> [join $SQLITE_OPTIONS { }] \
         1228  +    <<<SHELL_OPTIONS>>> [join $SHELL_WIN32_OPTIONS { }]] {#
  1190   1229   ##############################################################################
  1191   1230   # WARNING: DO NOT EDIT, AUTOMATICALLY GENERATED FILE (SEE "src/makemake.tcl")
  1192   1231   ##############################################################################
  1193   1232   #
  1194   1233   # This file is automatically generated.  Instead of editing this
  1195   1234   # file, edit "makemake.tcl" then run "tclsh makemake.tcl"
  1196   1235   # to regenerate this file.
................................................................................
  1269   1308   UTILS_OBJ=$(UTILS:.exe=.obj)
  1270   1309   UTILS_SRC=$(foreach uf,$(UTILS),$(SRCDIR)$(uf:.exe=.c))
  1271   1310   
  1272   1311   # define the sqlite files, which need special flags on compile
  1273   1312   SQLITESRC=sqlite3.c
  1274   1313   ORIGSQLITESRC=$(foreach sf,$(SQLITESRC),$(SRCDIR)$(sf))
  1275   1314   SQLITEOBJ=$(foreach sf,$(SQLITESRC),$(sf:.c=.obj))
  1276         -SQLITEDEFINES=-DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -Dlocaltime=fossil_localtime -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_WIN32_NO_ANSI
         1315  +SQLITEDEFINES=<<<SQLITE_OPTIONS>>>
  1277   1316   
  1278   1317   # define the sqlite shell files, which need special flags on compile
  1279   1318   SQLITESHELLSRC=shell.c
  1280   1319   ORIGSQLITESHELLSRC=$(foreach sf,$(SQLITESHELLSRC),$(SRCDIR)$(sf))
  1281   1320   SQLITESHELLOBJ=$(foreach sf,$(SQLITESHELLSRC),$(sf:.c=.obj))
  1282         -SQLITESHELLDEFINES=-Dmain=sqlite3_shell -DSQLITE_OMIT_LOAD_EXTENSION=1 -Dsqlite3_strglob=strglob
         1321  +SQLITESHELLDEFINES=<<<SHELL_OPTIONS>>>
  1283   1322   
  1284   1323   # define the th scripting files, which need special flags on compile
  1285   1324   THSRC=th.c th_lang.c
  1286   1325   ORIGTHSRC=$(foreach sf,$(THSRC),$(SRCDIR)$(sf))
  1287   1326   THOBJ=$(foreach sf,$(THSRC),$(sf:.c=.obj))
  1288   1327   
  1289   1328   # define the zlib files, needed by this compile
................................................................................
  1372   1411   	del /F $(TRANSLATEDSRC)
  1373   1412   	del /F *.h headers
  1374   1413   	del /F $(RESOURCE)
  1375   1414   
  1376   1415   .PHONY: clobber
  1377   1416   clobber: clean
  1378   1417   	del /F *.exe
  1379         -}
         1418  +}]

Changes to src/md5.c.

   162    162   }
   163    163   
   164    164   /*
   165    165    * Start MD5 accumulation.  Set bit count to 0 and buffer to mysterious
   166    166    * initialization constants.
   167    167    */
   168    168   static void MD5Init(MD5Context *ctx){
   169         -	ctx->isInit = 1;
          169  +        ctx->isInit = 1;
   170    170           ctx->buf[0] = 0x67452301;
   171    171           ctx->buf[1] = 0xefcdab89;
   172    172           ctx->buf[2] = 0x98badcfe;
   173    173           ctx->buf[3] = 0x10325476;
   174    174           ctx->bits[0] = 0;
   175    175           ctx->bits[1] = 0;
   176    176   }

Changes to src/printf.c.

   920    920     const char *z;
   921    921     int i;
   922    922     va_list ap;
   923    923     static const char *azEnv[] = { "HTTP_HOST", "HTTP_USER_AGENT",
   924    924         "PATH_INFO", "QUERY_STRING", "REMOTE_ADDR", "REQUEST_METHOD",
   925    925         "REQUEST_URI", "SCRIPT_NAME" };
   926    926     if( g.zErrlog==0 ) return;
   927         -  out = fopen(g.zErrlog, "a");
          927  +  out = fossil_fopen(g.zErrlog, "a");
   928    928     if( out==0 ) return;
   929    929     now = time(0);
   930    930     pNow = gmtime(&now);
   931    931     fprintf(out, "------------- %04d-%02d-%02d %02d:%02d:%02d UTC ------------\n",
   932    932             pNow->tm_year+1900, pNow->tm_mon+1, pNow->tm_mday+1,
   933    933             pNow->tm_hour, pNow->tm_min, pNow->tm_sec);
   934    934     va_start(ap, zFormat);
   935    935     vfprintf(out, zFormat, ap);
   936    936     fprintf(out, "\n");
   937    937     va_end(ap);
   938    938     for(i=0; i<sizeof(azEnv)/sizeof(azEnv[0]); i++){
   939         -    if( (z = getenv(azEnv[i]))!=0 || (z = P(azEnv[i]))!=0 ){
          939  +    char *p;
          940  +    if( (p = fossil_getenv(azEnv[i]))!=0 ){
          941  +      fprintf(out, "%s=%s\n", azEnv[i], p);
          942  +      fossil_filename_free(p);
          943  +    }else if( (z = P(azEnv[i]))!=0 ){
   940    944         fprintf(out, "%s=%s\n", azEnv[i], z);
   941    945       }
   942    946     }
   943    947     fclose(out);
   944    948   }
   945    949   
   946    950   /*

Changes to src/rebuild.c.

   579    579     }
   580    580     db_begin_transaction();
   581    581     ttyOutput = 1;
   582    582     errCnt = rebuild_db(randomizeFlag, 1, doClustering);
   583    583     reconstruct_private_table();
   584    584     db_multi_exec(
   585    585       "REPLACE INTO config(name,value,mtime) VALUES('content-schema','%s',now());"
   586         -    "REPLACE INTO config(name,value,mtime) VALUES('aux-schema','%s',now());",
   587         -    CONTENT_SCHEMA, AUX_SCHEMA
          586  +    "REPLACE INTO config(name,value,mtime) VALUES('aux-schema','%s',now());"
          587  +    "REPLACE INTO config(name,value,mtime) VALUES('rebuilt','%s',now());",
          588  +    CONTENT_SCHEMA, AUX_SCHEMA, get_version()
   588    589     );
   589    590     if( errCnt && !forceFlag ){
   590    591       fossil_print(
   591    592         "%d errors. Rolling back changes. Use --force to force a commit.\n",
   592    593         errCnt
   593    594       );
   594    595       db_end_transaction(1);
................................................................................
   605    606       db_open_repository(g.zRepositoryName);
   606    607       if( newPagesize ){
   607    608         db_multi_exec("PRAGMA page_size=%d", newPagesize);
   608    609         runVacuum = 1;
   609    610       }
   610    611       if( runDeanalyze ){
   611    612         db_multi_exec("DROP TABLE IF EXISTS sqlite_stat1;"
   612         -                    "DROP TABLE IF EXISTS sqlite_stat3;");
          613  +                    "DROP TABLE IF EXISTS sqlite_stat3;"
          614  +                    "DROP TABLE IF EXISTS sqlite_stat4;");
   613    615       }
   614    616       if( runAnalyze ){
   615    617         fossil_print("Analyzing the database... "); fflush(stdout);
   616    618         db_multi_exec("ANALYZE;");
   617    619         fossil_print("done\n");
   618    620       }
   619    621       if( runVacuum ){

Changes to src/report.c.

   181    181            "mlink",
   182    182            "plink",
   183    183            "event",
   184    184            "tag",
   185    185            "tagxref",
   186    186         };
   187    187         int i;
          188  +      if( fossil_strncmp(zArg1, "fx_", 3)==0 ){
          189  +        break;
          190  +      }
   188    191         for(i=0; i<sizeof(azAllowed)/sizeof(azAllowed[0]); i++){
   189    192           if( fossil_stricmp(zArg1, azAllowed[i])==0 ) break;
   190    193         }
   191    194         if( i>=sizeof(azAllowed)/sizeof(azAllowed[0]) ){
   192    195           *(char**)pError = mprintf("access to table \"%s\" is restricted",zArg1);
   193    196           rc = SQLITE_DENY;
   194    197         }else if( !g.perm.RdAddr && strncmp(zArg2, "private_", 8)==0 ){

Changes to src/schema.c.

   433    433   ** Predefined tagid values
   434    434   */
   435    435   #if INTERFACE
   436    436   # define TAG_BGCOLOR    1     /* Set the background color for display */
   437    437   # define TAG_COMMENT    2     /* The check-in comment */
   438    438   # define TAG_USER       3     /* User who made a checking */
   439    439   # define TAG_DATE       4     /* The date of a check-in */
   440         -# define TAG_HIDDEN     5     /* Do not display or sync */
   441         -# define TAG_PRIVATE    6     /* Display but do not sync */
          440  +# define TAG_HIDDEN     5     /* Do not display in timeline */
          441  +# define TAG_PRIVATE    6     /* Do not sync */
   442    442   # define TAG_CLUSTER    7     /* A cluster */
   443    443   # define TAG_BRANCH     8     /* Value is name of the current branch */
   444    444   # define TAG_CLOSED     9     /* Do not display this check-in as a leaf */
   445    445   # define TAG_PARENT     10    /* Change to parentage on a checkin */
   446    446   #endif
   447    447   #if EXPORT_INTERFACE
   448    448   # define MAX_INT_TAG    16    /* The largest pre-assigned tag id */

Changes to src/setup.c.

  1209   1209     @ in a separate box (using CSS class "timelineDate") whenever the date changes.
  1210   1210     @ With the "YYYY-MM-DD&nbsp;HH:MM" and "YYMMDD ..." formats, the complete date
  1211   1211     @ and time is shown on every timeline entry (using the CSS class "timelineTime").</p>
  1212   1212   
  1213   1213     @ <hr />
  1214   1214     onoff_attribute("Show version differences by default",
  1215   1215                     "show-version-diffs", "vdiff", 0, 0);
  1216         -  @ <p>On the version-information pages linked from the timeline can either
         1216  +  @ <p>The version-information pages linked from the timeline can either
  1217   1217     @ show complete diffs of all file changes, or can just list the names of
  1218   1218     @ the files that have changed.  Users can get to either page by
  1219   1219     @ clicking.  This setting selects the default.</p>
  1220   1220   
  1221   1221     @ <hr />
  1222   1222     entry_attribute("Max timeline comment length", 6,
  1223   1223                     "timeline-max-comment", "tmc", "0", 0);

Changes to src/sha1.c.

   159    159     const unsigned char *data,
   160    160     unsigned int len
   161    161   ){
   162    162       unsigned int i, j;
   163    163   
   164    164       j = context->count[0];
   165    165       if ((context->count[0] += len << 3) < j)
   166         -	context->count[1] += (len>>29)+1;
          166  +        context->count[1] += (len>>29)+1;
   167    167       j = (j >> 3) & 63;
   168    168       if ((j + len) > 63) {
   169         -	(void)memcpy(&context->buffer[j], data, (i = 64-j));
   170         -	SHA1Transform(context->state, context->buffer);
   171         -	for ( ; i + 63 < len; i += 64)
   172         -	    SHA1Transform(context->state, &data[i]);
   173         -	j = 0;
          169  +        (void)memcpy(&context->buffer[j], data, (i = 64-j));
          170  +        SHA1Transform(context->state, context->buffer);
          171  +        for ( ; i + 63 < len; i += 64)
          172  +            SHA1Transform(context->state, &data[i]);
          173  +        j = 0;
   174    174       } else {
   175         -	i = 0;
          175  +        i = 0;
   176    176       }
   177    177       (void)memcpy(&context->buffer[j], &data[i], len - i);
   178    178   }
   179    179   
   180    180   
   181    181   /*
   182    182    * Add padding and return the message digest.
   183    183    */
   184    184   static void SHA1Final(SHA1Context *context, unsigned char digest[20]){
   185    185       unsigned int i;
   186    186       unsigned char finalcount[8];
   187    187   
   188    188       for (i = 0; i < 8; i++) {
   189         -	finalcount[i] = (unsigned char)((context->count[(i >= 4 ? 0 : 1)]
   190         -	 >> ((3-(i & 3)) * 8) ) & 255);	 /* Endian independent */
          189  +        finalcount[i] = (unsigned char)((context->count[(i >= 4 ? 0 : 1)]
          190  +         >> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */
   191    191       }
   192    192       SHA1Update(context, (const unsigned char *)"\200", 1);
   193    193       while ((context->count[0] & 504) != 448)
   194         -	SHA1Update(context, (const unsigned char *)"\0", 1);
          194  +        SHA1Update(context, (const unsigned char *)"\0", 1);
   195    195       SHA1Update(context, finalcount, 8);  /* Should cause a SHA1Transform() */
   196    196   
   197    197       if (digest) {
   198         -	for (i = 0; i < 20; i++)
   199         -	    digest[i] = (unsigned char)
   200         -		((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
          198  +        for (i = 0; i < 20; i++)
          199  +            digest[i] = (unsigned char)
          200  +                ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
   201    201       }
   202    202   }
   203    203   
   204    204   
   205    205   /*
   206    206   ** Convert a digest into base-16.  digest should be declared as
   207    207   ** "unsigned char digest[20]" in the calling function.  The SHA1

Changes to src/shell.c.

    82     82   /* Windows CE (arm-wince-mingw32ce-gcc) does not provide isatty()
    83     83    * thus we always assume that we have a console. That can be
    84     84    * overridden with the -batch command line option.
    85     85    */
    86     86   #define isatty(x) 1
    87     87   #endif
    88     88   
    89         -/* True if the timer is enabled */
    90         -static int enableTimer = 0;
    91         -
    92     89   /* ctype macros that work with signed characters */
    93     90   #define IsSpace(X)  isspace((unsigned char)X)
    94     91   #define IsDigit(X)  isdigit((unsigned char)X)
    95     92   #define ToLower(X)  (char)tolower((unsigned char)X)
    96     93   
           94  +
           95  +/* True if the timer is enabled */
           96  +static int enableTimer = 0;
           97  +
           98  +/* Return the current wall-clock time */
           99  +static sqlite3_int64 timeOfDay(void){
          100  +  static sqlite3_vfs *clockVfs = 0;
          101  +  sqlite3_int64 t;
          102  +  if( clockVfs==0 ) clockVfs = sqlite3_vfs_find(0);
          103  +  if( clockVfs->iVersion>=1 && clockVfs->xCurrentTimeInt64!=0 ){
          104  +    clockVfs->xCurrentTimeInt64(clockVfs, &t);
          105  +  }else{
          106  +    double r;
          107  +    clockVfs->xCurrentTime(clockVfs, &r);
          108  +    t = (sqlite3_int64)(r*86400000.0);
          109  +  }
          110  +  return t;
          111  +}
          112  +
    97    113   #if !defined(_WIN32) && !defined(WIN32) && !defined(_WRS_KERNEL) \
    98    114    && !defined(__minux)
    99    115   #include <sys/time.h>
   100    116   #include <sys/resource.h>
   101    117   
   102    118   /* Saved resource information for the beginning of an operation */
   103         -static struct rusage sBegin;
          119  +static struct rusage sBegin;  /* CPU time at start */
          120  +static sqlite3_int64 iBegin;  /* Wall-clock time at start */
   104    121   
   105    122   /*
   106    123   ** Begin timing an operation
   107    124   */
   108    125   static void beginTimer(void){
   109    126     if( enableTimer ){
   110    127       getrusage(RUSAGE_SELF, &sBegin);
          128  +    iBegin = timeOfDay();
   111    129     }
   112    130   }
   113    131   
   114    132   /* Return the difference of two time_structs in seconds */
   115    133   static double timeDiff(struct timeval *pStart, struct timeval *pEnd){
   116    134     return (pEnd->tv_usec - pStart->tv_usec)*0.000001 + 
   117    135            (double)(pEnd->tv_sec - pStart->tv_sec);
................................................................................
   119    137   
   120    138   /*
   121    139   ** Print the timing results.
   122    140   */
   123    141   static void endTimer(void){
   124    142     if( enableTimer ){
   125    143       struct rusage sEnd;
          144  +    sqlite3_int64 iEnd = timeOfDay();
   126    145       getrusage(RUSAGE_SELF, &sEnd);
   127         -    printf("CPU Time: user %f sys %f\n",
          146  +    printf("Run Time: real %.3f user %f sys %f\n",
          147  +       (iEnd - iBegin)*0.001,
   128    148          timeDiff(&sBegin.ru_utime, &sEnd.ru_utime),
   129    149          timeDiff(&sBegin.ru_stime, &sEnd.ru_stime));
   130    150     }
   131    151   }
   132    152   
   133    153   #define BEGIN_TIMER beginTimer()
   134    154   #define END_TIMER endTimer()
................................................................................
   138    158   
   139    159   #include <windows.h>
   140    160   
   141    161   /* Saved resource information for the beginning of an operation */
   142    162   static HANDLE hProcess;
   143    163   static FILETIME ftKernelBegin;
   144    164   static FILETIME ftUserBegin;
          165  +static sqlite3_int64 ftWallBegin;
   145    166   typedef BOOL (WINAPI *GETPROCTIMES)(HANDLE, LPFILETIME, LPFILETIME, LPFILETIME, LPFILETIME);
   146    167   static GETPROCTIMES getProcessTimesAddr = NULL;
   147    168   
   148    169   /*
   149    170   ** Check to see if we have timer support.  Return 1 if necessary
   150    171   ** support found (or found previously).
   151    172   */
................................................................................
   175    196   /*
   176    197   ** Begin timing an operation
   177    198   */
   178    199   static void beginTimer(void){
   179    200     if( enableTimer && getProcessTimesAddr ){
   180    201       FILETIME ftCreation, ftExit;
   181    202       getProcessTimesAddr(hProcess, &ftCreation, &ftExit, &ftKernelBegin, &ftUserBegin);
          203  +    ftWallBegin = timeOfDay();
   182    204     }
   183    205   }
   184    206   
   185    207   /* Return the difference of two FILETIME structs in seconds */
   186    208   static double timeDiff(FILETIME *pStart, FILETIME *pEnd){
   187    209     sqlite_int64 i64Start = *((sqlite_int64 *) pStart);
   188    210     sqlite_int64 i64End = *((sqlite_int64 *) pEnd);
................................................................................
   191    213   
   192    214   /*
   193    215   ** Print the timing results.
   194    216   */
   195    217   static void endTimer(void){
   196    218     if( enableTimer && getProcessTimesAddr){
   197    219       FILETIME ftCreation, ftExit, ftKernelEnd, ftUserEnd;
          220  +    sqlite3_int64 ftWallEnd = timeOfDay();
   198    221       getProcessTimesAddr(hProcess, &ftCreation, &ftExit, &ftKernelEnd, &ftUserEnd);
   199         -    printf("CPU Time: user %f sys %f\n",
          222  +    printf("Run Time: real %.3f user %f sys %f\n",
          223  +       (ftWallEnd - ftWallBegin)*0.001,
   200    224          timeDiff(&ftUserBegin, &ftUserEnd),
   201    225          timeDiff(&ftKernelBegin, &ftKernelEnd));
   202    226     }
   203    227   }
   204    228   
   205    229   #define BEGIN_TIMER beginTimer()
   206    230   #define END_TIMER endTimer()
................................................................................
   432    456     char nullvalue[20];    /* The text to print when a NULL comes back from
   433    457                            ** the database */
   434    458     struct previous_mode_data explainPrev;
   435    459                            /* Holds the mode information just before
   436    460                            ** .explain ON */
   437    461     char outfile[FILENAME_MAX]; /* Filename for *out */
   438    462     const char *zDbFilename;    /* name of the database file */
          463  +  char *zFreeOnClose;         /* Filename to free when closing */
   439    464     const char *zVfs;           /* Name of VFS to use */
   440    465     sqlite3_stmt *pStmt;   /* Current statement if any. */
   441    466     FILE *pLog;            /* Write log output here */
          467  +  int *aiIndent;         /* Array of indents used in MODE_Explain */
          468  +  int nIndent;           /* Size of array aiIndent[] */
          469  +  int iIndent;           /* Index of current op in aiIndent[] */
   442    470   };
   443    471   
   444    472   /*
   445    473   ** These are the allowed modes.
   446    474   */
   447    475   #define MODE_Line     0  /* One column per line.  Blank line between records */
   448    476   #define MODE_Column   1  /* One record per line in neat columns */
................................................................................
   736    764         for(i=0; i<nArg; i++){
   737    765           int w;
   738    766           if( i<ArraySize(p->actualWidth) ){
   739    767              w = p->actualWidth[i];
   740    768           }else{
   741    769              w = 10;
   742    770           }
   743         -        if( p->mode==MODE_Explain && azArg[i] && 
   744         -           strlen30(azArg[i])>w ){
          771  +        if( p->mode==MODE_Explain && azArg[i] && strlen30(azArg[i])>w ){
   745    772             w = strlen30(azArg[i]);
          773  +        }
          774  +        if( i==1 && p->aiIndent && p->pStmt ){
          775  +          if( p->iIndent<p->nIndent ){
          776  +            fprintf(p->out, "%*.s", p->aiIndent[p->iIndent], "");
          777  +          }
          778  +          p->iIndent++;
   746    779           }
   747    780           if( w<0 ){
   748    781             fprintf(p->out,"%*.*s%s",-w,-w,
   749    782                 azArg[i] ? azArg[i] : p->nullvalue, i==nArg-1 ? "\n": "  ");
   750    783           }else{
   751    784             fprintf(p->out,"%-*.*s%s",w,w,
   752    785                 azArg[i] ? azArg[i] : p->nullvalue, i==nArg-1 ? "\n": "  ");
................................................................................
  1111   1144       fprintf(pArg->out, "Autoindex Inserts:                   %d\n", iCur);
  1112   1145       iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_VM_STEP, bReset);
  1113   1146       fprintf(pArg->out, "Virtual Machine Steps:               %d\n", iCur);
  1114   1147     }
  1115   1148   
  1116   1149     return 0;
  1117   1150   }
         1151  +
         1152  +/*
         1153  +** Parameter azArray points to a zero-terminated array of strings. zStr
         1154  +** points to a single nul-terminated string. Return non-zero if zStr
         1155  +** is equal, according to strcmp(), to any of the strings in the array.
         1156  +** Otherwise, return zero.
         1157  +*/
         1158  +static int str_in_array(const char *zStr, const char **azArray){
         1159  +  int i;
         1160  +  for(i=0; azArray[i]; i++){
         1161  +    if( 0==strcmp(zStr, azArray[i]) ) return 1;
         1162  +  }
         1163  +  return 0;
         1164  +}
         1165  +
         1166  +/*
         1167  +** If compiled statement pSql appears to be an EXPLAIN statement, allocate
         1168  +** and populate the callback_data.aiIndent[] array with the number of
         1169  +** spaces each opcode should be indented before it is output. 
         1170  +**
         1171  +** The indenting rules are:
         1172  +**
         1173  +**     * For each "Next", "Prev", "VNext" or "VPrev" instruction, indent
         1174  +**       all opcodes that occur between the p2 jump destination and the opcode
         1175  +**       itself by 2 spaces.
         1176  +**
         1177  +**     * For each "Goto", if the jump destination is earlier in the program
         1178  +**       and ends on one of:
         1179  +**          Yield  SeekGt  SeekLt  RowSetRead
         1180  +**       then indent all opcodes between the earlier instruction
         1181  +**       and "Goto" by 2 spaces.
         1182  +*/
         1183  +static void explain_data_prepare(struct callback_data *p, sqlite3_stmt *pSql){
         1184  +  const char *zSql;               /* The text of the SQL statement */
         1185  +  const char *z;                  /* Used to check if this is an EXPLAIN */
         1186  +  int *abYield = 0;               /* True if op is an OP_Yield */
         1187  +  int nAlloc = 0;                 /* Allocated size of p->aiIndent[], abYield */
         1188  +  int iOp;                        /* Index of operation in p->aiIndent[] */
         1189  +
         1190  +  const char *azNext[] = { "Next", "Prev", "VPrev", "VNext", "SorterNext", 0 };
         1191  +  const char *azYield[] = { "Yield", "SeekLt", "SeekGt", "RowSetRead", 0 };
         1192  +  const char *azGoto[] = { "Goto", 0 };
         1193  +
         1194  +  /* Try to figure out if this is really an EXPLAIN statement. If this
         1195  +  ** cannot be verified, return early.  */
         1196  +  zSql = sqlite3_sql(pSql);
         1197  +  if( zSql==0 ) return;
         1198  +  for(z=zSql; *z==' ' || *z=='\t' || *z=='\n' || *z=='\f' || *z=='\r'; z++);
         1199  +  if( sqlite3_strnicmp(z, "explain", 7) ) return;
         1200  +
         1201  +  for(iOp=0; SQLITE_ROW==sqlite3_step(pSql); iOp++){
         1202  +    int i;
         1203  +    int iAddr = sqlite3_column_int(pSql, 0);
         1204  +    const char *zOp = (const char*)sqlite3_column_text(pSql, 1);
         1205  +
         1206  +    /* Set p2 to the P2 field of the current opcode. Then, assuming that
         1207  +    ** p2 is an instruction address, set variable p2op to the index of that
         1208  +    ** instruction in the aiIndent[] array. p2 and p2op may be different if
         1209  +    ** the current instruction is part of a sub-program generated by an
         1210  +    ** SQL trigger or foreign key.  */
         1211  +    int p2 = sqlite3_column_int(pSql, 3);
         1212  +    int p2op = (p2 + (iOp-iAddr));
         1213  +
         1214  +    /* Grow the p->aiIndent array as required */
         1215  +    if( iOp>=nAlloc ){
         1216  +      nAlloc += 100;
         1217  +      p->aiIndent = (int*)sqlite3_realloc(p->aiIndent, nAlloc*sizeof(int));
         1218  +      abYield = (int*)sqlite3_realloc(abYield, nAlloc*sizeof(int));
         1219  +    }
         1220  +    abYield[iOp] = str_in_array(zOp, azYield);
         1221  +    p->aiIndent[iOp] = 0;
         1222  +    p->nIndent = iOp+1;
         1223  +
         1224  +    if( str_in_array(zOp, azNext) ){
         1225  +      for(i=p2op; i<iOp; i++) p->aiIndent[i] += 2;
         1226  +    }
         1227  +    if( str_in_array(zOp, azGoto) && p2op<p->nIndent && abYield[p2op] ){
         1228  +      for(i=p2op; i<iOp; i++) p->aiIndent[i] += 2;
         1229  +    }
         1230  +  }
         1231  +
         1232  +  p->iIndent = 0;
         1233  +  sqlite3_free(abYield);
         1234  +  sqlite3_reset(pSql);
         1235  +}
         1236  +
         1237  +/*
         1238  +** Free the array allocated by explain_data_prepare().
         1239  +*/
         1240  +static void explain_data_delete(struct callback_data *p){
         1241  +  sqlite3_free(p->aiIndent);
         1242  +  p->aiIndent = 0;
         1243  +  p->nIndent = 0;
         1244  +  p->iIndent = 0;
         1245  +}
  1118   1246   
  1119   1247   /*
  1120   1248   ** Execute a statement or set of statements.  Print 
  1121   1249   ** any result rows/columns depending on the current mode 
  1122   1250   ** set via the supplied callback.
  1123   1251   **
  1124   1252   ** This is very similar to SQLite's built-in sqlite3_exec() 
................................................................................
  1172   1300         if( pArg && pArg->mode==MODE_Explain ){
  1173   1301           const char *zExplain = 0;
  1174   1302           sqlite3_test_control(SQLITE_TESTCTRL_EXPLAIN_STMT, pStmt, &zExplain);
  1175   1303           if( zExplain && zExplain[0] ){
  1176   1304             fprintf(pArg->out, "%s", zExplain);
  1177   1305           }
  1178   1306         }
         1307  +
         1308  +      /* If the shell is currently in ".explain" mode, gather the extra
         1309  +      ** data required to add indents to the output.*/
         1310  +      if( pArg && pArg->mode==MODE_Explain ){
         1311  +        explain_data_prepare(pArg, pStmt);
         1312  +      }
  1179   1313   
  1180   1314         /* perform the first step.  this will tell us if we
  1181   1315         ** have a result set or not and how wide it is.
  1182   1316         */
  1183   1317         rc = sqlite3_step(pStmt);
  1184   1318         /* if we have a result set... */
  1185   1319         if( SQLITE_ROW == rc ){
................................................................................
  1229   1363             }
  1230   1364           }else{
  1231   1365             do{
  1232   1366               rc = sqlite3_step(pStmt);
  1233   1367             } while( rc == SQLITE_ROW );
  1234   1368           }
  1235   1369         }
         1370  +
         1371  +      explain_data_delete(pArg);
  1236   1372   
  1237   1373         /* print usage stats if stats on */
  1238   1374         if( pArg && pArg->statsOn ){
  1239   1375           display_stats(db, pArg, 0);
  1240   1376         }
  1241   1377   
  1242   1378         /* Finalize the statement just executed. If this fails, save a 
................................................................................
  1433   1569     "                         html     HTML <table> code\n"
  1434   1570     "                         insert   SQL insert statements for TABLE\n"
  1435   1571     "                         line     One value per line\n"
  1436   1572     "                         list     Values delimited by .separator string\n"
  1437   1573     "                         tabs     Tab-separated values\n"
  1438   1574     "                         tcl      TCL list elements\n"
  1439   1575     ".nullvalue STRING      Use STRING in place of NULL values\n"
         1576  +  ".open ?FILENAME?       Close existing database and reopen FILENAME\n"
  1440   1577     ".output FILENAME       Send output to FILENAME\n"
  1441   1578     ".output stdout         Send output to the screen\n"
  1442   1579     ".print STRING...       Print literal STRING\n"
  1443   1580     ".prompt MAIN CONTINUE  Replace the standard prompts\n"
  1444   1581     ".quit                  Exit this program\n"
  1445   1582     ".read FILENAME         Execute SQL in FILENAME\n"
  1446   1583     ".restore ?DB? FILE     Restore content of DB (default \"main\") from FILE\n"
................................................................................
  1466   1603   /* Forward reference */
  1467   1604   static int process_input(struct callback_data *p, FILE *in);
  1468   1605   
  1469   1606   /*
  1470   1607   ** Make sure the database is open.  If it is not, then open it.  If
  1471   1608   ** the database fails to open, print an error message and exit.
  1472   1609   */
  1473         -static void open_db(struct callback_data *p){
         1610  +static void open_db(struct callback_data *p, int keepAlive){
  1474   1611     if( p->db==0 ){
  1475   1612       sqlite3_initialize();
  1476   1613       sqlite3_open(p->zDbFilename, &p->db);
  1477   1614       db = p->db;
  1478   1615       if( db && sqlite3_errcode(db)==SQLITE_OK ){
  1479   1616         sqlite3_create_function(db, "shellstatic", 0, SQLITE_UTF8, 0,
  1480   1617             shellstaticFunc, 0, 0);
  1481   1618       }
  1482   1619       if( db==0 || SQLITE_OK!=sqlite3_errcode(db) ){
  1483   1620         fprintf(stderr,"Error: unable to open database \"%s\": %s\n", 
  1484   1621             p->zDbFilename, sqlite3_errmsg(db));
         1622  +      if( keepAlive ) return;
  1485   1623         exit(1);
  1486   1624       }
  1487   1625   #ifndef SQLITE_OMIT_LOAD_EXTENSION
  1488   1626       sqlite3_enable_load_extension(p->db, 1);
  1489   1627   #endif
  1490   1628     }
  1491   1629   }
................................................................................
  1830   1968       if( zDb==0 ) zDb = "main";
  1831   1969       rc = sqlite3_open(zDestFile, &pDest);
  1832   1970       if( rc!=SQLITE_OK ){
  1833   1971         fprintf(stderr, "Error: cannot open \"%s\"\n", zDestFile);
  1834   1972         sqlite3_close(pDest);
  1835   1973         return 1;
  1836   1974       }
  1837         -    open_db(p);
         1975  +    open_db(p, 0);
  1838   1976       pBackup = sqlite3_backup_init(pDest, "main", p->db, zDb);
  1839   1977       if( pBackup==0 ){
  1840   1978         fprintf(stderr, "Error: %s\n", sqlite3_errmsg(pDest));
  1841   1979         sqlite3_close(pDest);
  1842   1980         return 1;
  1843   1981       }
  1844   1982       while(  (rc = sqlite3_backup_step(pBackup,100))==SQLITE_OK ){}
................................................................................
  1862   2000     if( c=='b' && n>=3 && strncmp(azArg[0], "breakpoint", n)==0 ){
  1863   2001       test_breakpoint();
  1864   2002     }else
  1865   2003   
  1866   2004     if( c=='d' && n>1 && strncmp(azArg[0], "databases", n)==0 && nArg==1 ){
  1867   2005       struct callback_data data;
  1868   2006       char *zErrMsg = 0;
  1869         -    open_db(p);
         2007  +    open_db(p, 0);
  1870   2008       memcpy(&data, p, sizeof(data));
  1871   2009       data.showHeader = 1;
  1872   2010       data.mode = MODE_Column;
  1873   2011       data.colWidth[0] = 3;
  1874   2012       data.colWidth[1] = 15;
  1875   2013       data.colWidth[2] = 58;
  1876   2014       data.cnt = 0;
................................................................................
  1879   2017         fprintf(stderr,"Error: %s\n", zErrMsg);
  1880   2018         sqlite3_free(zErrMsg);
  1881   2019         rc = 1;
  1882   2020       }
  1883   2021     }else
  1884   2022   
  1885   2023     if( c=='d' && strncmp(azArg[0], "dump", n)==0 && nArg<3 ){
  1886         -    open_db(p);
         2024  +    open_db(p, 0);
  1887   2025       /* When playing back a "dump", the content might appear in an order
  1888   2026       ** which causes immediate foreign key constraints to be violated.
  1889   2027       ** So disable foreign-key constraint enforcement to prevent problems. */
  1890   2028       fprintf(p->out, "PRAGMA foreign_keys=OFF;\n");
  1891   2029       fprintf(p->out, "BEGIN TRANSACTION;\n");
  1892   2030       p->writableSchema = 0;
  1893   2031       sqlite3_exec(p->db, "SAVEPOINT dump; PRAGMA writable_schema=ON", 0, 0, 0);
................................................................................
  1954   2092         ** explain mode. However, always executing it allows us an easy
  1955   2093         ** was to reset to explain mode in case the user previously
  1956   2094         ** did an .explain followed by a .width, .mode or .header
  1957   2095         ** command.
  1958   2096         */
  1959   2097         p->mode = MODE_Explain;
  1960   2098         p->showHeader = 1;
  1961         -      memset(p->colWidth,0,ArraySize(p->colWidth));
         2099  +      memset(p->colWidth,0,sizeof(p->colWidth));
  1962   2100         p->colWidth[0] = 4;                  /* addr */
  1963   2101         p->colWidth[1] = 13;                 /* opcode */
  1964   2102         p->colWidth[2] = 4;                  /* P1 */
  1965   2103         p->colWidth[3] = 4;                  /* P2 */
  1966   2104         p->colWidth[4] = 4;                  /* P3 */
  1967   2105         p->colWidth[5] = 13;                 /* P4 */
  1968   2106         p->colWidth[6] = 2;                  /* P5 */
................................................................................
  1998   2136       int nSep;                   /* Number of bytes in p->separator[] */
  1999   2137       char *zSql;                 /* An SQL statement */
  2000   2138       CSVReader sCsv;             /* Reader context */
  2001   2139       int (*xCloser)(FILE*);      /* Procedure to close th3 connection */
  2002   2140   
  2003   2141       seenInterrupt = 0;
  2004   2142       memset(&sCsv, 0, sizeof(sCsv));
  2005         -    open_db(p);
         2143  +    open_db(p, 0);
  2006   2144       nSep = strlen30(p->separator);
  2007   2145       if( nSep==0 ){
  2008   2146         fprintf(stderr, "Error: non-null separator required for import\n");
  2009   2147         return 1;
  2010   2148       }
  2011   2149       if( nSep>1 ){
  2012   2150         fprintf(stderr, "Error: multi-character separators not allowed"
................................................................................
  2136   2274       sqlite3_finalize(pStmt);
  2137   2275       if( needCommit ) sqlite3_exec(db, "COMMIT", 0, 0, 0);
  2138   2276     }else
  2139   2277   
  2140   2278     if( c=='i' && strncmp(azArg[0], "indices", n)==0 && nArg<3 ){
  2141   2279       struct callback_data data;
  2142   2280       char *zErrMsg = 0;
  2143         -    open_db(p);
         2281  +    open_db(p, 0);
  2144   2282       memcpy(&data, p, sizeof(data));
  2145   2283       data.showHeader = 0;
  2146   2284       data.mode = MODE_List;
  2147   2285       if( nArg==1 ){
  2148   2286         rc = sqlite3_exec(p->db,
  2149   2287           "SELECT name FROM sqlite_master "
  2150   2288           "WHERE type='index' AND name NOT LIKE 'sqlite_%' "
................................................................................
  2202   2340   
  2203   2341   #ifndef SQLITE_OMIT_LOAD_EXTENSION
  2204   2342     if( c=='l' && strncmp(azArg[0], "load", n)==0 && nArg>=2 ){
  2205   2343       const char *zFile, *zProc;
  2206   2344       char *zErrMsg = 0;
  2207   2345       zFile = azArg[1];
  2208   2346       zProc = nArg>=3 ? azArg[2] : 0;
  2209         -    open_db(p);
         2347  +    open_db(p, 0);
  2210   2348       rc = sqlite3_load_extension(p->db, zFile, zProc, &zErrMsg);
  2211   2349       if( rc!=SQLITE_OK ){
  2212   2350         fprintf(stderr, "Error: %s\n", zErrMsg);
  2213   2351         sqlite3_free(zErrMsg);
  2214   2352         rc = 1;
  2215   2353       }
  2216   2354     }else
................................................................................
  2267   2405       }
  2268   2406     }else
  2269   2407   
  2270   2408     if( c=='n' && strncmp(azArg[0], "nullvalue", n)==0 && nArg==2 ) {
  2271   2409       sqlite3_snprintf(sizeof(p->nullvalue), p->nullvalue,
  2272   2410                        "%.*s", (int)ArraySize(p->nullvalue)-1, azArg[1]);
  2273   2411     }else
         2412  +
         2413  +  if( c=='o' && strncmp(azArg[0], "open", n)==0 && n>=2 ){
         2414  +    sqlite3 *savedDb = p->db;
         2415  +    const char *zSavedFilename = p->zDbFilename;
         2416  +    char *zNewFilename = 0;
         2417  +    p->db = 0;
         2418  +    if( nArg>=2 ){
         2419  +      p->zDbFilename = zNewFilename = sqlite3_mprintf("%s", azArg[1]);
         2420  +    }
         2421  +    open_db(p, 1);
         2422  +    if( p->db!=0 ){
         2423  +      sqlite3_close(savedDb);
         2424  +      sqlite3_free(p->zFreeOnClose);
         2425  +      p->zFreeOnClose = zNewFilename;
         2426  +    }else{
         2427  +      sqlite3_free(zNewFilename);
         2428  +      p->db = savedDb;
         2429  +      p->zDbFilename = zSavedFilename;
         2430  +    }
         2431  +  }else
  2274   2432   
  2275   2433     if( c=='o' && strncmp(azArg[0], "output", n)==0 && nArg==2 ){
  2276   2434       if( p->outfile[0]=='|' ){
  2277   2435         pclose(p->out);
  2278   2436       }else{
  2279   2437         output_file_close(p->out);
  2280   2438       }
................................................................................
  2351   2509       }
  2352   2510       rc = sqlite3_open(zSrcFile, &pSrc);
  2353   2511       if( rc!=SQLITE_OK ){
  2354   2512         fprintf(stderr, "Error: cannot open \"%s\"\n", zSrcFile);
  2355   2513         sqlite3_close(pSrc);
  2356   2514         return 1;
  2357   2515       }
  2358         -    open_db(p);
         2516  +    open_db(p, 0);
  2359   2517       pBackup = sqlite3_backup_init(p->db, zDb, pSrc, "main");
  2360   2518       if( pBackup==0 ){
  2361   2519         fprintf(stderr, "Error: %s\n", sqlite3_errmsg(p->db));
  2362   2520         sqlite3_close(pSrc);
  2363   2521         return 1;
  2364   2522       }
  2365   2523       while( (rc = sqlite3_backup_step(pBackup,100))==SQLITE_OK
................................................................................
  2381   2539       }
  2382   2540       sqlite3_close(pSrc);
  2383   2541     }else
  2384   2542   
  2385   2543     if( c=='s' && strncmp(azArg[0], "schema", n)==0 && nArg<3 ){
  2386   2544       struct callback_data data;
  2387   2545       char *zErrMsg = 0;
  2388         -    open_db(p);
         2546  +    open_db(p, 0);
  2389   2547       memcpy(&data, p, sizeof(data));
  2390   2548       data.showHeader = 0;
  2391   2549       data.mode = MODE_Semi;
  2392   2550       if( nArg>1 ){
  2393   2551         int i;
  2394   2552         for(i=0; azArg[1][i]; i++) azArg[1][i] = ToLower(azArg[1][i]);
  2395   2553         if( strcmp(azArg[1],"sqlite_master")==0 ){
................................................................................
  2512   2670   
  2513   2671     if( c=='t' && n>1 && strncmp(azArg[0], "tables", n)==0 && nArg<3 ){
  2514   2672       sqlite3_stmt *pStmt;
  2515   2673       char **azResult;
  2516   2674       int nRow, nAlloc;
  2517   2675       char *zSql = 0;
  2518   2676       int ii;
  2519         -    open_db(p);
         2677  +    open_db(p, 0);
  2520   2678       rc = sqlite3_prepare_v2(p->db, "PRAGMA database_list", -1, &pStmt, 0);
  2521   2679       if( rc ) return rc;
  2522   2680       zSql = sqlite3_mprintf(
  2523   2681           "SELECT name FROM sqlite_master"
  2524   2682           " WHERE type IN ('table','view')"
  2525   2683           "   AND name NOT LIKE 'sqlite_%%'"
  2526   2684           "   AND name LIKE ?1");
................................................................................
  2612   2770         { "optimizations",         SQLITE_TESTCTRL_OPTIMIZATIONS          },
  2613   2771         { "iskeyword",             SQLITE_TESTCTRL_ISKEYWORD              },
  2614   2772         { "scratchmalloc",         SQLITE_TESTCTRL_SCRATCHMALLOC          },
  2615   2773       };
  2616   2774       int testctrl = -1;
  2617   2775       int rc = 0;
  2618   2776       int i, n;
  2619         -    open_db(p);
         2777  +    open_db(p, 0);
  2620   2778   
  2621   2779       /* convert testctrl text option to value. allow any unique prefix
  2622   2780       ** of the option name, or a numerical value. */
  2623   2781       n = strlen30(azArg[1]);
  2624   2782       for(i=0; i<(int)(sizeof(aCtrl)/sizeof(aCtrl[0])); i++){
  2625   2783         if( strncmp(azArg[1], aCtrl[i].zCtrlName, n)==0 ){
  2626   2784           if( testctrl<0 ){
................................................................................
  2711   2869                     azArg[1]);
  2712   2870             break;
  2713   2871         }
  2714   2872       }
  2715   2873     }else
  2716   2874   
  2717   2875     if( c=='t' && n>4 && strncmp(azArg[0], "timeout", n)==0 && nArg==2 ){
  2718         -    open_db(p);
         2876  +    open_db(p, 0);
  2719   2877       sqlite3_busy_timeout(p->db, (int)integerValue(azArg[1]));
  2720   2878     }else
  2721   2879       
  2722   2880     if( HAS_TIMER && c=='t' && n>=5 && strncmp(azArg[0], "timer", n)==0
  2723   2881      && nArg==2
  2724   2882     ){
  2725   2883       enableTimer = booleanValue(azArg[1]);
  2726   2884     }else
  2727   2885     
  2728   2886     if( c=='t' && strncmp(azArg[0], "trace", n)==0 && nArg>1 ){
  2729         -    open_db(p);
         2887  +    open_db(p, 0);
  2730   2888       output_file_close(p->traceOut);
  2731   2889       p->traceOut = output_file_open(azArg[1]);
  2732   2890   #if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT)
  2733   2891       if( p->traceOut==0 ){
  2734   2892         sqlite3_trace(p->db, 0, 0);
  2735   2893       }else{
  2736   2894         sqlite3_trace(p->db, sql_trace_callback, p->traceOut);
................................................................................
  2914   3072         zSql[nSql++] = '\n';
  2915   3073         memcpy(zSql+nSql, zLine, nLine+1);
  2916   3074         nSql += nLine;
  2917   3075       }
  2918   3076       if( nSql && line_contains_semicolon(&zSql[nSqlPrior], nSql-nSqlPrior)
  2919   3077                   && sqlite3_complete(zSql) ){
  2920   3078         p->cnt = 0;
  2921         -      open_db(p);
         3079  +      open_db(p, 0);
  2922   3080         BEGIN_TIMER;
  2923   3081         rc = shell_exec(p->db, zSql, shell_callback, p, &zErrMsg);
  2924   3082         END_TIMER;
  2925   3083         if( rc || zErrMsg ){
  2926   3084           char zPrefix[100];
  2927   3085           if( in!=0 || !stdin_is_interactive ){
  2928   3086             sqlite3_snprintf(sizeof(zPrefix), zPrefix, 
................................................................................
  3247   3405   
  3248   3406     /* Go ahead and open the database file if it already exists.  If the
  3249   3407     ** file does not exist, delay opening it.  This prevents empty database
  3250   3408     ** files from being created if a user mistypes the database name argument
  3251   3409     ** to the sqlite command-line tool.
  3252   3410     */
  3253   3411     if( access(data.zDbFilename, 0)==0 ){
  3254         -    open_db(&data);
         3412  +    open_db(&data, 0);
  3255   3413     }
  3256   3414   
  3257   3415     /* Process the initialization file if there is one.  If no -init option
  3258   3416     ** is given on the command line, look for a file named ~/.sqliterc and
  3259   3417     ** try to process it.
  3260   3418     */
  3261   3419     rc = process_sqliterc(&data,zInitFile);
................................................................................
  3327   3485       }else if( strcmp(z,"-cmd")==0 ){
  3328   3486         if( i==argc-1 ) break;
  3329   3487         z = cmdline_option_value(argc,argv,++i);
  3330   3488         if( z[0]=='.' ){
  3331   3489           rc = do_meta_command(z, &data);
  3332   3490           if( rc && bail_on_error ) return rc==2 ? 0 : rc;
  3333   3491         }else{
  3334         -        open_db(&data);
         3492  +        open_db(&data, 0);
  3335   3493           rc = shell_exec(data.db, z, shell_callback, &data, &zErrMsg);
  3336   3494           if( zErrMsg!=0 ){
  3337   3495             fprintf(stderr,"Error: %s\n", zErrMsg);
  3338   3496             if( bail_on_error ) return rc!=0 ? rc : 1;
  3339   3497           }else if( rc!=0 ){
  3340   3498             fprintf(stderr,"Error: unable to process SQL \"%s\"\n", z);
  3341   3499             if( bail_on_error ) return rc;
................................................................................
  3351   3509     if( zFirstCmd ){
  3352   3510       /* Run just the command that follows the database name
  3353   3511       */
  3354   3512       if( zFirstCmd[0]=='.' ){
  3355   3513         rc = do_meta_command(zFirstCmd, &data);
  3356   3514         if( rc==2 ) rc = 0;
  3357   3515       }else{
  3358         -      open_db(&data);
         3516  +      open_db(&data, 0);
  3359   3517         rc = shell_exec(data.db, zFirstCmd, shell_callback, &data, &zErrMsg);
  3360   3518         if( zErrMsg!=0 ){
  3361   3519           fprintf(stderr,"Error: %s\n", zErrMsg);
  3362   3520           return rc!=0 ? rc : 1;
  3363   3521         }else if( rc!=0 ){
  3364   3522           fprintf(stderr,"Error: unable to process SQL \"%s\"\n", zFirstCmd);
  3365   3523           return rc;
................................................................................
  3398   3556         rc = process_input(&data, stdin);
  3399   3557       }
  3400   3558     }
  3401   3559     set_table_name(&data, 0);
  3402   3560     if( data.db ){
  3403   3561       sqlite3_close(data.db);
  3404   3562     }
         3563  +  sqlite3_free(data.zFreeOnClose); 
  3405   3564     return rc;
  3406   3565   }

Changes to src/skins.c.

   115    115   @ div.content {
   116    116   @   padding: 0ex 0ex 0ex 0ex;
   117    117   @ }
   118    118   @ /* Hyperlink colors */
   119    119   @ div.content a { color: #604000; }
   120    120   @ div.content a:link { color: #604000;}
   121    121   @ div.content a:visited { color: #600000; }
          122  +@
          123  +@ /* <verbatim> blocks */
          124  +@ pre.verbatim {
          125  +@   background-color: #ffffff;
          126  +@   padding: 0.5em;
          127  +@   white-space: pre-wrap;
          128  +@ }
   122    129   @
   123    130   @ /* Some pages have section dividers */
   124    131   @ div.section {
   125    132   @   margin-bottom: 0px;
   126    133   @   margin-top: 1em;
   127    134   @   padding: 1px 1px 1px 1px;
   128    135   @   font-size: 1.2em;

Changes to src/sqlcmd.c.

   121    121     sqlite3_create_function(db, "decompress", 1, SQLITE_ANY, 0,
   122    122                             sqlcmd_decompress, 0, 0);
   123    123     re_add_sql_func(db);
   124    124     g.repositoryOpen = 1;
   125    125     g.db = db;
   126    126     return SQLITE_OK;
   127    127   }
   128         -
   129    128   
   130    129   /*
   131    130   ** COMMAND: sqlite3
   132    131   **
   133    132   ** Usage: %fossil sqlite3 ?DATABASE? ?OPTIONS?
   134    133   **
   135    134   ** Run the standalone sqlite3 command-line shell on DATABASE with OPTIONS.

Changes to src/sqlite3.c.

more than 10,000 changes

Changes to src/sqlite3.h.

   103    103   ** string contains the date and time of the check-in (UTC) and an SHA1
   104    104   ** hash of the entire source tree.
   105    105   **
   106    106   ** See also: [sqlite3_libversion()],
   107    107   ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
   108    108   ** [sqlite_version()] and [sqlite_source_id()].
   109    109   */
   110         -#define SQLITE_VERSION        "3.8.1"
   111         -#define SQLITE_VERSION_NUMBER 3008001
   112         -#define SQLITE_SOURCE_ID      "2013-10-17 12:57:35 c78be6d786c19073b3a6730dfe3fb1be54f5657a"
          110  +#define SQLITE_VERSION        "3.8.3"
          111  +#define SQLITE_VERSION_NUMBER 3008003
          112  +#define SQLITE_SOURCE_ID      "2013-12-11 12:02:55 3e1d55f0bd84810a035bd6c54583eb373784a9a3"
   113    113   
   114    114   /*
   115    115   ** CAPI3REF: Run-Time Library Version Numbers
   116    116   ** KEYWORDS: sqlite3_version, sqlite3_sourceid
   117    117   **
   118    118   ** These interfaces provide the same information as the [SQLITE_VERSION],
   119    119   ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros
................................................................................
   366    366   ** is not changed.
   367    367   **
   368    368   ** Restrictions:
   369    369   **
   370    370   ** <ul>
   371    371   ** <li> The application must insure that the 1st parameter to sqlite3_exec()
   372    372   **      is a valid and open [database connection].
   373         -** <li> The application must not close [database connection] specified by
          373  +** <li> The application must not close the [database connection] specified by
   374    374   **      the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.
   375    375   ** <li> The application must not modify the SQL statement text passed into
   376    376   **      the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.
   377    377   ** </ul>
   378    378   */
   379    379   SQLITE_API int sqlite3_exec(
   380    380     sqlite3*,                                  /* An open database */
................................................................................
   443    443   ** address this, newer versions of SQLite (version 3.3.8 and later) include
   444    444   ** support for additional result codes that provide more detailed information
   445    445   ** about errors. The extended result codes are enabled or disabled
   446    446   ** on a per database connection basis using the
   447    447   ** [sqlite3_extended_result_codes()] API.
   448    448   **
   449    449   ** Some of the available extended result codes are listed here.
   450         -** One may expect the number of extended result codes will be expand
          450  +** One may expect the number of extended result codes will increase
   451    451   ** over time.  Software that uses extended result codes should expect
   452    452   ** to see new result codes in future releases of SQLite.
   453    453   **
   454    454   ** The SQLITE_OK result code will never be extended.  It will always
   455    455   ** be exactly zero.
   456    456   */
   457    457   #define SQLITE_IOERR_READ              (SQLITE_IOERR | (1<<8))
................................................................................
   487    487   #define SQLITE_CANTOPEN_ISDIR          (SQLITE_CANTOPEN | (2<<8))
   488    488   #define SQLITE_CANTOPEN_FULLPATH       (SQLITE_CANTOPEN | (3<<8))
   489    489   #define SQLITE_CANTOPEN_CONVPATH       (SQLITE_CANTOPEN | (4<<8))
   490    490   #define SQLITE_CORRUPT_VTAB            (SQLITE_CORRUPT | (1<<8))
   491    491   #define SQLITE_READONLY_RECOVERY       (SQLITE_READONLY | (1<<8))
   492    492   #define SQLITE_READONLY_CANTLOCK       (SQLITE_READONLY | (2<<8))
   493    493   #define SQLITE_READONLY_ROLLBACK       (SQLITE_READONLY | (3<<8))
          494  +#define SQLITE_READONLY_DBMOVED        (SQLITE_READONLY | (4<<8))
   494    495   #define SQLITE_ABORT_ROLLBACK          (SQLITE_ABORT | (2<<8))
   495    496   #define SQLITE_CONSTRAINT_CHECK        (SQLITE_CONSTRAINT | (1<<8))
   496    497   #define SQLITE_CONSTRAINT_COMMITHOOK   (SQLITE_CONSTRAINT | (2<<8))
   497    498   #define SQLITE_CONSTRAINT_FOREIGNKEY   (SQLITE_CONSTRAINT | (3<<8))
   498    499   #define SQLITE_CONSTRAINT_FUNCTION     (SQLITE_CONSTRAINT | (4<<8))
   499    500   #define SQLITE_CONSTRAINT_NOTNULL      (SQLITE_CONSTRAINT | (5<<8))
   500    501   #define SQLITE_CONSTRAINT_PRIMARYKEY   (SQLITE_CONSTRAINT | (6<<8))
   501    502   #define SQLITE_CONSTRAINT_TRIGGER      (SQLITE_CONSTRAINT | (7<<8))
   502    503   #define SQLITE_CONSTRAINT_UNIQUE       (SQLITE_CONSTRAINT | (8<<8))
   503    504   #define SQLITE_CONSTRAINT_VTAB         (SQLITE_CONSTRAINT | (9<<8))
          505  +#define SQLITE_CONSTRAINT_ROWID        (SQLITE_CONSTRAINT |(10<<8))
   504    506   #define SQLITE_NOTICE_RECOVER_WAL      (SQLITE_NOTICE | (1<<8))
   505    507   #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
   506    508   #define SQLITE_WARNING_AUTOINDEX       (SQLITE_WARNING | (1<<8))
   507    509   
   508    510   /*
   509    511   ** CAPI3REF: Flags For File Open Operations
   510    512   **
................................................................................
   553    555   ** first then the size of the file is extended, never the other
   554    556   ** way around.  The SQLITE_IOCAP_SEQUENTIAL property means that
   555    557   ** information is written to disk in the same order as calls
   556    558   ** to xWrite().  The SQLITE_IOCAP_POWERSAFE_OVERWRITE property means that
   557    559   ** after reboot following a crash or power loss, the only bytes in a
   558    560   ** file that were written at the application level might have changed
   559    561   ** and that adjacent bytes, even bytes within the same sector are
   560         -** guaranteed to be unchanged.
          562  +** guaranteed to be unchanged.  The SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN
          563  +** flag indicate that a file cannot be deleted when open.
   561    564   */
   562    565   #define SQLITE_IOCAP_ATOMIC                 0x00000001
   563    566   #define SQLITE_IOCAP_ATOMIC512              0x00000002
   564    567   #define SQLITE_IOCAP_ATOMIC1K               0x00000004
   565    568   #define SQLITE_IOCAP_ATOMIC2K               0x00000008
   566    569   #define SQLITE_IOCAP_ATOMIC4K               0x00000010
   567    570   #define SQLITE_IOCAP_ATOMIC8K               0x00000020
................................................................................
   908    911   ** The argument is a pointer to a value of type sqlite3_int64 that
   909    912   ** is an advisory maximum number of bytes in the file to memory map.  The
   910    913   ** pointer is overwritten with the old value.  The limit is not changed if
   911    914   ** the value originally pointed to is negative, and so the current limit 
   912    915   ** can be queried by passing in a pointer to a negative number.  This
   913    916   ** file-control is used internally to implement [PRAGMA mmap_size].
   914    917   **
          918  +** <li>[[SQLITE_FCNTL_TRACE]]
          919  +** The [SQLITE_FCNTL_TRACE] file control provides advisory information
          920  +** to the VFS about what the higher layers of the SQLite stack are doing.
          921  +** This file control is used by some VFS activity tracing [shims].
          922  +** The argument is a zero-terminated string.  Higher layers in the
          923  +** SQLite stack may generate instances of this file control if
          924  +** the [SQLITE_USE_FCNTL_TRACE] compile-time option is enabled.
          925  +**
          926  +** <li>[[SQLITE_FCNTL_HAS_MOVED]]
          927  +** The [SQLITE_FCNTL_HAS_MOVED] file control interprets its argument as a
          928  +** pointer to an integer and it writes a boolean into that integer depending
          929  +** on whether or not the file has been renamed, moved, or deleted since it
          930  +** was first opened.
          931  +**
   915    932   ** </ul>
   916    933   */
   917    934   #define SQLITE_FCNTL_LOCKSTATE               1
   918    935   #define SQLITE_GET_LOCKPROXYFILE             2
   919    936   #define SQLITE_SET_LOCKPROXYFILE             3
   920    937   #define SQLITE_LAST_ERRNO                    4
   921    938   #define SQLITE_FCNTL_SIZE_HINT               5
................................................................................
   927    944   #define SQLITE_FCNTL_OVERWRITE              11
   928    945   #define SQLITE_FCNTL_VFSNAME                12
   929    946   #define SQLITE_FCNTL_POWERSAFE_OVERWRITE    13
   930    947   #define SQLITE_FCNTL_PRAGMA                 14
   931    948   #define SQLITE_FCNTL_BUSYHANDLER            15
   932    949   #define SQLITE_FCNTL_TEMPFILENAME           16
   933    950   #define SQLITE_FCNTL_MMAP_SIZE              18
          951  +#define SQLITE_FCNTL_TRACE                  19
          952  +#define SQLITE_FCNTL_HAS_MOVED              20
   934    953   
   935    954   /*
   936    955   ** CAPI3REF: Mutex Handle
   937    956   **
   938    957   ** The mutex module within SQLite defines [sqlite3_mutex] to be an
   939    958   ** abstract type for a mutex object.  The SQLite core never looks
   940    959   ** at the internal representation of an [sqlite3_mutex].  It only
................................................................................
  1371   1390   ** a memory allocation given a particular requested size.  Most memory
  1372   1391   ** allocators round up memory allocations at least to the next multiple
  1373   1392   ** of 8.  Some allocators round up to a larger multiple or to a power of 2.
  1374   1393   ** Every memory allocation request coming in through [sqlite3_malloc()]
  1375   1394   ** or [sqlite3_realloc()] first calls xRoundup.  If xRoundup returns 0, 
  1376   1395   ** that causes the corresponding memory allocation to fail.
  1377   1396   **
  1378         -** The xInit method initializes the memory allocator.  (For example,
         1397  +** The xInit method initializes the memory allocator.  For example,
  1379   1398   ** it might allocate any require mutexes or initialize internal data
  1380   1399   ** structures.  The xShutdown method is invoked (indirectly) by
  1381   1400   ** [sqlite3_shutdown()] and should deallocate any resources acquired
  1382   1401   ** by xInit.  The pAppData pointer is used as the only parameter to
  1383   1402   ** xInit and xShutdown.
  1384   1403   **
  1385   1404   ** SQLite holds the [SQLITE_MUTEX_STATIC_MASTER] mutex when it invokes
................................................................................
  1673   1692   ** either the [PRAGMA mmap_size] command, or by using the
  1674   1693   ** [SQLITE_FCNTL_MMAP_SIZE] file control.  ^(The maximum allowed mmap size
  1675   1694   ** cannot be changed at run-time.  Nor may the maximum allowed mmap size
  1676   1695   ** exceed the compile-time maximum mmap size set by the
  1677   1696   ** [SQLITE_MAX_MMAP_SIZE] compile-time option.)^
  1678   1697   ** ^If either argument to this option is negative, then that argument is
  1679   1698   ** changed to its compile-time default.
         1699  +**
         1700  +** [[SQLITE_CONFIG_WIN32_HEAPSIZE]]
         1701  +** <dt>SQLITE_CONFIG_WIN32_HEAPSIZE
         1702  +** <dd>^This option is only available if SQLite is compiled for Windows
         1703  +** with the [SQLITE_WIN32_MALLOC] pre-processor macro defined.
         1704  +** SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value
         1705  +** that specifies the maximum size of the created heap.
  1680   1706   ** </dl>
  1681   1707   */
  1682   1708   #define SQLITE_CONFIG_SINGLETHREAD  1  /* nil */
  1683   1709   #define SQLITE_CONFIG_MULTITHREAD   2  /* nil */
  1684   1710   #define SQLITE_CONFIG_SERIALIZED    3  /* nil */
  1685   1711   #define SQLITE_CONFIG_MALLOC        4  /* sqlite3_mem_methods* */
  1686   1712   #define SQLITE_CONFIG_GETMALLOC     5  /* sqlite3_mem_methods* */
................................................................................
  1697   1723   #define SQLITE_CONFIG_LOG          16  /* xFunc, void* */
  1698   1724   #define SQLITE_CONFIG_URI          17  /* int */
  1699   1725   #define SQLITE_CONFIG_PCACHE2      18  /* sqlite3_pcache_methods2* */
  1700   1726   #define SQLITE_CONFIG_GETPCACHE2   19  /* sqlite3_pcache_methods2* */
  1701   1727   #define SQLITE_CONFIG_COVERING_INDEX_SCAN 20  /* int */
  1702   1728   #define SQLITE_CONFIG_SQLLOG       21  /* xSqllog, void* */
  1703   1729   #define SQLITE_CONFIG_MMAP_SIZE    22  /* sqlite3_int64, sqlite3_int64 */
         1730  +#define SQLITE_CONFIG_WIN32_HEAPSIZE      23  /* int nByte */
  1704   1731   
  1705   1732   /*
  1706   1733   ** CAPI3REF: Database Connection Configuration Options
  1707   1734   **
  1708   1735   ** These constants are the available integer configuration options that
  1709   1736   ** can be passed as the second argument to the [sqlite3_db_config()] interface.
  1710   1737   **
................................................................................
  1773   1800   ** codes are disabled by default for historical compatibility.
  1774   1801   */
  1775   1802   SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff);
  1776   1803   
  1777   1804   /*
  1778   1805   ** CAPI3REF: Last Insert Rowid
  1779   1806   **
  1780         -** ^Each entry in an SQLite table has a unique 64-bit signed
         1807  +** ^Each entry in most SQLite tables (except for [WITHOUT ROWID] tables)
         1808  +** has a unique 64-bit signed
  1781   1809   ** integer key called the [ROWID | "rowid"]. ^The rowid is always available
  1782   1810   ** as an undeclared column named ROWID, OID, or _ROWID_ as long as those
  1783   1811   ** names are not also used by explicitly declared columns. ^If
  1784   1812   ** the table has a column of type [INTEGER PRIMARY KEY] then that column
  1785   1813   ** is another alias for the rowid.
  1786   1814   **
  1787         -** ^This routine returns the [rowid] of the most recent
  1788         -** successful [INSERT] into the database from the [database connection]
  1789         -** in the first argument.  ^As of SQLite version 3.7.7, this routines
  1790         -** records the last insert rowid of both ordinary tables and [virtual tables].
  1791         -** ^If no successful [INSERT]s
  1792         -** have ever occurred on that database connection, zero is returned.
         1815  +** ^The sqlite3_last_insert_rowid(D) interface returns the [rowid] of the 
         1816  +** most recent successful [INSERT] into a rowid table or [virtual table]
         1817  +** on database connection D.
         1818  +** ^Inserts into [WITHOUT ROWID] tables are not recorded.
         1819  +** ^If no successful [INSERT]s into rowid tables
         1820  +** have ever occurred on the database connection D, 
         1821  +** then sqlite3_last_insert_rowid(D) returns zero.
  1793   1822   **
  1794   1823   ** ^(If an [INSERT] occurs within a trigger or within a [virtual table]
  1795   1824   ** method, then this routine will return the [rowid] of the inserted
  1796   1825   ** row as long as the trigger or virtual table method is running.
  1797   1826   ** But once the trigger or virtual table method ends, the value returned 
  1798   1827   ** by this routine reverts to what it was before the trigger or virtual
  1799   1828   ** table method began.)^
................................................................................
  3095   3124   ** then the statement will be automatically recompiled, as if there had been 
  3096   3125   ** a schema change, on the first  [sqlite3_step()] call following any change
  3097   3126   ** to the [sqlite3_bind_text | bindings] of that [parameter]. 
  3098   3127   ** ^The specific value of WHERE-clause [parameter] might influence the 
  3099   3128   ** choice of query plan if the parameter is the left-hand side of a [LIKE]
  3100   3129   ** or [GLOB] operator or if the parameter is compared to an indexed column
  3101   3130   ** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.
  3102         -** the 
  3103   3131   ** </li>
  3104   3132   ** </ol>
  3105   3133   */
  3106   3134   SQLITE_API int sqlite3_prepare(
  3107   3135     sqlite3 *db,            /* Database handle */
  3108   3136     const char *zSql,       /* SQL statement, UTF-8 encoded */
  3109   3137     int nByte,              /* Maximum length of zSql in bytes. */
................................................................................
  3757   3785   **
  3758   3786   ** <blockquote>
  3759   3787   ** <table border="1">
  3760   3788   ** <tr><th> Internal<br>Type <th> Requested<br>Type <th>  Conversion
  3761   3789   **
  3762   3790   ** <tr><td>  NULL    <td> INTEGER   <td> Result is 0
  3763   3791   ** <tr><td>  NULL    <td>  FLOAT    <td> Result is 0.0
  3764         -** <tr><td>  NULL    <td>   TEXT    <td> Result is NULL pointer
  3765         -** <tr><td>  NULL    <td>   BLOB    <td> Result is NULL pointer
         3792  +** <tr><td>  NULL    <td>   TEXT    <td> Result is a NULL pointer
         3793  +** <tr><td>  NULL    <td>   BLOB    <td> Result is a NULL pointer
  3766   3794   ** <tr><td> INTEGER  <td>  FLOAT    <td> Convert from integer to float
  3767   3795   ** <tr><td> INTEGER  <td>   TEXT    <td> ASCII rendering of the integer
  3768   3796   ** <tr><td> INTEGER  <td>   BLOB    <td> Same as INTEGER->TEXT
  3769         -** <tr><td>  FLOAT   <td> INTEGER   <td> Convert from float to integer
         3797  +** <tr><td>  FLOAT   <td> INTEGER   <td> [CAST] to INTEGER
  3770   3798   ** <tr><td>  FLOAT   <td>   TEXT    <td> ASCII rendering of the float
  3771         -** <tr><td>  FLOAT   <td>   BLOB    <td> Same as FLOAT->TEXT
  3772         -** <tr><td>  TEXT    <td> INTEGER   <td> Use atoi()
  3773         -** <tr><td>  TEXT    <td>  FLOAT    <td> Use atof()
         3799  +** <tr><td>  FLOAT   <td>   BLOB    <td> [CAST] to BLOB
         3800  +** <tr><td>  TEXT    <td> INTEGER   <td> [CAST] to INTEGER
         3801  +** <tr><td>  TEXT    <td>  FLOAT    <td> [CAST] to REAL
  3774   3802   ** <tr><td>  TEXT    <td>   BLOB    <td> No change
  3775         -** <tr><td>  BLOB    <td> INTEGER   <td> Convert to TEXT then use atoi()
  3776         -** <tr><td>  BLOB    <td>  FLOAT    <td> Convert to TEXT then use atof()
         3803  +** <tr><td>  BLOB    <td> INTEGER   <td> [CAST] to INTEGER
         3804  +** <tr><td>  BLOB    <td>  FLOAT    <td> [CAST] to REAL
  3777   3805   ** <tr><td>  BLOB    <td>   TEXT    <td> Add a zero terminator if needed
  3778   3806   ** </table>
  3779   3807   ** </blockquote>)^
  3780   3808   **
  3781   3809   ** The table above makes reference to standard C library functions atoi()
  3782   3810   ** and atof().  SQLite does not really use these functions.  It has its
  3783   3811   ** own equivalent internal routines.  The atoi() and atof() names are
................................................................................
  3825   3853   ** sqlite3_column_bytes16(), and do not mix calls to sqlite3_column_text16()
  3826   3854   ** with calls to sqlite3_column_bytes().
  3827   3855   **
  3828   3856   ** ^The pointers returned are valid until a type conversion occurs as
  3829   3857   ** described above, or until [sqlite3_step()] or [sqlite3_reset()] or
  3830   3858   ** [sqlite3_finalize()] is called.  ^The memory space used to hold strings
  3831   3859   ** and BLOBs is freed automatically.  Do <b>not</b> pass the pointers returned
  3832         -** [sqlite3_column_blob()], [sqlite3_column_text()], etc. into
         3860  +** from [sqlite3_column_blob()], [sqlite3_column_text()], etc. into
  3833   3861   ** [sqlite3_free()].
  3834   3862   **
  3835   3863   ** ^(If a memory allocation error occurs during the evaluation of any
  3836   3864   ** of these routines, a default value is returned.  The default value
  3837   3865   ** is either the integer 0, the floating point number 0.0, or a NULL
  3838   3866   ** pointer.  Subsequent calls to [sqlite3_errcode()] will return
  3839   3867   ** [SQLITE_NOMEM].)^
................................................................................
  4802   4830   SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
  4803   4831   
  4804   4832   /*
  4805   4833   ** CAPI3REF: Data Change Notification Callbacks
  4806   4834   **
  4807   4835   ** ^The sqlite3_update_hook() interface registers a callback function
  4808   4836   ** with the [database connection] identified by the first argument
  4809         -** to be invoked whenever a row is updated, inserted or deleted.
         4837  +** to be invoked whenever a row is updated, inserted or deleted in
         4838  +** a rowid table.
  4810   4839   ** ^Any callback set by a previous call to this function
  4811   4840   ** for the same database connection is overridden.
  4812   4841   **
  4813   4842   ** ^The second argument is a pointer to the function to invoke when a
  4814         -** row is updated, inserted or deleted.
         4843  +** row is updated, inserted or deleted in a rowid table.
  4815   4844   ** ^The first argument to the callback is a copy of the third argument
  4816   4845   ** to sqlite3_update_hook().
  4817   4846   ** ^The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE],
  4818   4847   ** or [SQLITE_UPDATE], depending on the operation that caused the callback
  4819   4848   ** to be invoked.
  4820   4849   ** ^The third and fourth arguments to the callback contain pointers to the
  4821   4850   ** database and table name containing the affected row.
  4822   4851   ** ^The final callback parameter is the [rowid] of the row.
  4823   4852   ** ^In the case of an update, this is the [rowid] after the update takes place.
  4824   4853   **
  4825   4854   ** ^(The update hook is not invoked when internal system tables are
  4826   4855   ** modified (i.e. sqlite_master and sqlite_sequence).)^
         4856  +** ^The update hook is not invoked when [WITHOUT ROWID] tables are modified.
  4827   4857   **
  4828   4858   ** ^In the current implementation, the update hook
  4829   4859   ** is not invoked when duplication rows are deleted because of an
  4830   4860   ** [ON CONFLICT | ON CONFLICT REPLACE] clause.  ^Nor is the update hook
  4831   4861   ** invoked when rows are deleted using the [truncate optimization].
  4832   4862   ** The exceptions defined in this paragraph might change in a future
  4833   4863   ** release of SQLite.
................................................................................
  4901   4931   SQLITE_API int sqlite3_release_memory(int);
  4902   4932   
  4903   4933   /*
  4904   4934   ** CAPI3REF: Free Memory Used By A Database Connection
  4905   4935   **
  4906   4936   ** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap
  4907   4937   ** memory as possible from database connection D. Unlike the
  4908         -** [sqlite3_release_memory()] interface, this interface is effect even
  4909         -** when then [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is
         4938  +** [sqlite3_release_memory()] interface, this interface is in effect even
         4939  +** when the [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is
  4910   4940   ** omitted.
  4911   4941   **
  4912   4942   ** See also: [sqlite3_release_memory()]
  4913   4943   */
  4914   4944   SQLITE_API int sqlite3_db_release_memory(sqlite3*);
  4915   4945   
  4916   4946   /*
................................................................................
  5277   5307   ** ^[sqlite3_free()] is used to free idxPtr if and only if
  5278   5308   ** needToFreeIdxPtr is true.
  5279   5309   **
  5280   5310   ** ^The orderByConsumed means that output from [xFilter]/[xNext] will occur in
  5281   5311   ** the correct order to satisfy the ORDER BY clause so that no separate
  5282   5312   ** sorting step is required.
  5283   5313   **
  5284         -** ^The estimatedCost value is an estimate of the cost of doing the
  5285         -** particular lookup.  A full scan of a table with N entries should have
  5286         -** a cost of N.  A binary search of a table of N entries should have a
  5287         -** cost of approximately log(N).
         5314  +** ^The estimatedCost value is an estimate of the cost of a particular
         5315  +** strategy. A cost of N indicates that the cost of the strategy is similar
         5316  +** to a linear scan of an SQLite table with N rows. A cost of log(N) 
         5317  +** indicates that the expense of the operation is similar to that of a
         5318  +** binary search on a unique indexed field of an SQLite table with N rows.
         5319  +**
         5320  +** ^The estimatedRows value is an estimate of the number of rows that
         5321  +** will be returned by the strategy.
         5322  +**
         5323  +** IMPORTANT: The estimatedRows field was added to the sqlite3_index_info
         5324  +** structure for SQLite version 3.8.2. If a virtual table extension is
         5325  +** used with an SQLite version earlier than 3.8.2, the results of attempting 
         5326  +** to read or write the estimatedRows field are undefined (but are likely 
         5327  +** to included crashing the application). The estimatedRows field should
         5328  +** therefore only be used if [sqlite3_libversion_number()] returns a
         5329  +** value greater than or equal to 3008002.
  5288   5330   */
  5289   5331   struct sqlite3_index_info {
  5290   5332     /* Inputs */
  5291   5333     int nConstraint;           /* Number of entries in aConstraint */
  5292   5334     struct sqlite3_index_constraint {
  5293   5335        int iColumn;              /* Column on left-hand side of constraint */
  5294   5336        unsigned char op;         /* Constraint operator */
................................................................................
  5305   5347       int argvIndex;           /* if >0, constraint is part of argv to xFilter */
  5306   5348       unsigned char omit;      /* Do not code a test for this constraint */
  5307   5349     } *aConstraintUsage;
  5308   5350     int idxNum;                /* Number used to identify the index */
  5309   5351     char *idxStr;              /* String, possibly obtained from sqlite3_malloc */
  5310   5352     int needToFreeIdxStr;      /* Free idxStr using sqlite3_free() if true */
  5311   5353     int orderByConsumed;       /* True if output is already ordered */
  5312         -  double estimatedCost;      /* Estimated cost of using this index */
         5354  +  double estimatedCost;           /* Estimated cost of using this index */
         5355  +  /* Fields below are only available in SQLite 3.8.2 and later */
         5356  +  sqlite3_int64 estimatedRows;    /* Estimated number of rows returned */
  5313   5357   };
  5314   5358   
  5315   5359   /*
  5316   5360   ** CAPI3REF: Virtual Table Constraint Operator Codes
  5317   5361   **
  5318   5362   ** These macros defined the allowed values for the
  5319   5363   ** [sqlite3_index_info].aConstraint[].op field.  Each value represents
................................................................................
  5509   5553   ** commit if the transaction continues to completion.)^
  5510   5554   **
  5511   5555   ** ^Use the [sqlite3_blob_bytes()] interface to determine the size of
  5512   5556   ** the opened blob.  ^The size of a blob may not be changed by this
  5513   5557   ** interface.  Use the [UPDATE] SQL command to change the size of a
  5514   5558   ** blob.
  5515   5559   **
         5560  +** ^The [sqlite3_blob_open()] interface will fail for a [WITHOUT ROWID]
         5561  +** table.  Incremental BLOB I/O is not possible on [WITHOUT ROWID] tables.
         5562  +**
  5516   5563   ** ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces
  5517   5564   ** and the built-in [zeroblob] SQL function can be used, if desired,
  5518   5565   ** to create an empty, zero-filled blob in which to read or write using
  5519   5566   ** this interface.
  5520   5567   **
  5521   5568   ** To avoid a resource leak, every open [BLOB handle] should eventually
  5522   5569   ** be released by a call to [sqlite3_blob_close()].
................................................................................
  6032   6079   #define SQLITE_TESTCTRL_ALWAYS                  13
  6033   6080   #define SQLITE_TESTCTRL_RESERVE                 14
  6034   6081   #define SQLITE_TESTCTRL_OPTIMIZATIONS           15
  6035   6082   #define SQLITE_TESTCTRL_ISKEYWORD               16
  6036   6083   #define SQLITE_TESTCTRL_SCRATCHMALLOC           17
  6037   6084   #define SQLITE_TESTCTRL_LOCALTIME_FAULT         18
  6038   6085   #define SQLITE_TESTCTRL_EXPLAIN_STMT            19
  6039         -#define SQLITE_TESTCTRL_LAST                    19
         6086  +#define SQLITE_TESTCTRL_NEVER_CORRUPT           20
         6087  +#define SQLITE_TESTCTRL_LAST                    20
  6040   6088   
  6041   6089   /*
  6042   6090   ** CAPI3REF: SQLite Runtime Status
  6043   6091   **
  6044   6092   ** ^This interface is used to retrieve runtime status information
  6045   6093   ** about the performance of SQLite, and optionally to reset various
  6046   6094   ** highwater marks.  ^The first argument is an integer code for

Changes to src/stat.c.

    53     53   
    54     54     login_check_credentials();
    55     55     if( !g.perm.Read ){ login_needed(); return; }
    56     56     brief = P("brief")!=0;
    57     57     style_header("Repository Statistics");
    58     58     if( g.perm.Admin ){
    59     59       style_submenu_element("URLs", "URLs and Checkouts", "urllist");
           60  +    style_submenu_element("Schema", "Repository Schema", "repo_schema");
    60     61     }
    61     62     @ <table class="label-value">
    62     63     @ <tr><th>Repository&nbsp;Size:</th><td>
    63     64     fsize = file_size(g.zRepositoryName);
    64     65     bigSizeName(sizeof(zBuf), zBuf, fsize);
    65     66     @ %s(zBuf)
    66     67     @ </td></tr>
................................................................................
   120    121     @ %d(n) days or approximately %.2f(n/365.2425) years.
   121    122     @ </td></tr>
   122    123     @ <tr><th>Project&nbsp;ID:</th><td>%h(db_get("project-code",""))</td></tr>
   123    124     @ <tr><th>Fossil&nbsp;Version:</th><td>
   124    125     @ %h(MANIFEST_DATE) %h(MANIFEST_VERSION)
   125    126     @ (%h(RELEASE_VERSION)) [compiled using %h(COMPILER_NAME)]
   126    127     @ </td></tr>
   127         -  @ <tr><th>SQLite&nbsp;Version:</th><td>%.19s(SQLITE_SOURCE_ID)
   128         -  @ [%.10s(&SQLITE_SOURCE_ID[20])] (%s(SQLITE_VERSION))</td></tr>
          128  +  @ <tr><th>SQLite&nbsp;Version:</th><td>%.19s(sqlite3_sourceid())
          129  +  @ [%.10s(&sqlite3_sourceid()[20])] (%s(sqlite3_libversion()))</td></tr>
          130  +  @ <tr><th>Repository Rebuilt:</th><td>
          131  +  @ %h(db_get_mtime("rebuilt","%Y-%m-%d %H:%M:%S","Never"))
          132  +  @ By Fossil %h(db_get("rebuilt","Unknown"))</td></tr>
   129    133     @ <tr><th>Database&nbsp;Stats:</th><td>
   130    134     zDb = db_name("repository");
   131    135     @ %d(db_int(0, "PRAGMA %s.page_count", zDb)) pages,
   132    136     @ %d(db_int(0, "PRAGMA %s.page_size", zDb)) bytes/page,
   133    137     @ %d(db_int(0, "PRAGMA %s.freelist_count", zDb)) free pages,
   134    138     @ %s(db_text(0, "PRAGMA %s.encoding", zDb)),
   135    139     @ %s(db_text(0, "PRAGMA %s.journal_mode", zDb)) mode
................................................................................
   218    222     fossil_print("%*s%s\n", colWidth, "project-id:", db_get("project-code",""));
   219    223     fossil_print("%*s%s %s [%s] (%s)\n",
   220    224                  colWidth, "fossil-version:",
   221    225                  MANIFEST_DATE, MANIFEST_VERSION, RELEASE_VERSION,
   222    226                  COMPILER_NAME);
   223    227     fossil_print("%*s%.19s [%.10s] (%s)\n",
   224    228                  colWidth, "sqlite-version:",
   225         -               SQLITE_SOURCE_ID, &SQLITE_SOURCE_ID[20],
   226         -               SQLITE_VERSION);
          229  +               sqlite3_sourceid(), &sqlite3_sourceid()[20],
          230  +               sqlite3_libversion());
   227    231     zDb = db_name("repository");
   228    232     fossil_print("%*s%d pages, %d bytes/pg, %d free pages, "
   229    233                  "%s, %s mode\n",
   230    234                  colWidth, "database-stats:",
   231    235                  db_int(0, "PRAGMA %s.page_count", zDb),
   232    236                  db_int(0, "PRAGMA %s.page_size", zDb),
   233    237                  db_int(0, "PRAGMA %s.freelist_count", zDb),
   234    238                  db_text(0, "PRAGMA %s.encoding", zDb),
   235    239                  db_text(0, "PRAGMA %s.journal_mode", zDb));
   236    240   
   237    241   }
   238         -
   239         -
   240    242   
   241    243   /*
   242    244   ** WEBPAGE: urllist
   243    245   **
   244    246   ** Show ways in which this repository has been accessed
   245    247   */
   246    248   void urllist_page(void){
................................................................................
   247    249     Stmt q;
   248    250     int cnt;
   249    251     login_check_credentials();
   250    252     if( !g.perm.Admin ){ login_needed(); return; }
   251    253   
   252    254     style_header("URLs and Checkouts");
   253    255     style_submenu_element("Stat", "Repository Stats", "stat");
          256  +  style_submenu_element("Schema", "Repository Schema", "repo_schema");
   254    257     @ <div class="section">URLs</div>
   255    258     @ <table border="0" width='100%%'>
   256    259     db_prepare(&q, "SELECT substr(name,9), datetime(mtime,'unixepoch')"
   257    260                    "  FROM config WHERE name GLOB 'baseurl:*' ORDER BY 2 DESC");
   258    261     cnt = 0;
   259    262     while( db_step(&q)==SQLITE_ROW ){
   260    263       @ <tr><td width='100%%'>%h(db_column_text(&q,0))</td>
................................................................................
   279    282     db_finalize(&q);
   280    283     if( cnt==0 ){
   281    284       @ <tr><td>(none)</td>
   282    285     }
   283    286     @ </table>
   284    287     style_footer();
   285    288   }
          289  +
          290  +/*
          291  +** WEBPAGE: repo_schema
          292  +**
          293  +** Show the repository schema
          294  +*/
          295  +void repo_schema_page(void){
          296  +  Stmt q;
          297  +  login_check_credentials();
          298  +  if( !g.perm.Admin ){ login_needed(); return; }
          299  +
          300  +  style_header("Repository Schema");
          301  +  style_submenu_element("Stat", "Repository Stats", "stat");
          302  +  style_submenu_element("URLs", "URLs and Checkouts", "urllist");
          303  +  db_prepare(&q, "SELECT sql FROM %s.sqlite_master WHERE sql IS NOT NULL",
          304  +             db_name("repository"));
          305  +  @ <pre>
          306  +  while( db_step(&q)==SQLITE_ROW ){
          307  +    @ %h(db_column_text(&q, 0));
          308  +  }
          309  +  @ </pre>
          310  +  db_finalize(&q);
          311  +  style_footer();
          312  +}

Changes to src/style.c.

  1112   1112   */
  1113   1113   void cgi_append_default_css(void) {
  1114   1114     int i;
  1115   1115   
  1116   1116     for (i=0;cssDefaultList[i].elementClass;i++){
  1117   1117       if (cssDefaultList[i].elementClass[0]){
  1118   1118         cgi_printf("/* %s */\n%s {\n%s\n}\n\n",
  1119         -		 cssDefaultList[i].comment,
  1120         -		 cssDefaultList[i].elementClass,
  1121         -		 cssDefaultList[i].value
  1122         -		);
         1119  +                 cssDefaultList[i].comment,
         1120  +                 cssDefaultList[i].elementClass,
         1121  +                 cssDefaultList[i].value
         1122  +                );
  1123   1123       }else{
  1124   1124         cgi_printf("%s",
  1125         -		 cssDefaultList[i].value
  1126         -		);
         1125  +                 cssDefaultList[i].value
         1126  +                );
  1127   1127       }
  1128   1128     }
  1129   1129   }
  1130   1130   
  1131   1131   /*
  1132   1132   ** WEBPAGE: style.css
  1133   1133   */

Changes to src/sync.c.

    52     52     url_parse(0, URL_REMEMBER);
    53     53     if( g.urlProtocol==0 ) return 0;  
    54     54     if( g.urlUser!=0 && g.urlPasswd==0 ){
    55     55       g.urlPasswd = unobscure(db_get("last-sync-pw", 0));
    56     56       g.urlFlags |= URL_PROMPT_PW;
    57     57       url_prompt_for_password();
    58     58     }
           59  +  url_remember();
    59     60   #if 0 /* Disabled for now */
    60     61     if( (flags & AUTOSYNC_PULL)!=0 && db_get_boolean("auto-shun",1) ){
    61     62       /* When doing an automatic pull, also automatically pull shuns from
    62     63       ** the server if pull_shuns is enabled.
    63     64       **
    64     65       ** TODO:  What happens if the shun list gets really big? 
    65     66       ** Maybe the shunning list should only be pulled on every 10th
................................................................................
   113    114     }else if( g.argc==3 ){
   114    115       zUrl = g.argv[2];
   115    116     }
   116    117     if( urlFlags & URL_REMEMBER ){
   117    118       clone_ssh_db_set_options();
   118    119     }
   119    120     url_parse(zUrl, urlFlags);
          121  +  url_remember();
   120    122     if( g.urlProtocol==0 ){
   121    123       if( urlOptional ) fossil_exit(0);
   122    124       usage("URL");
   123    125     }
   124    126     user_select();
   125    127     if( g.argc==2 ){
   126    128       if( ((*pSyncFlags) & (SYNC_PUSH|SYNC_PULL))==(SYNC_PUSH|SYNC_PULL) ){
................................................................................
   260    262     if( g.argc!=2 && g.argc!=3 ){
   261    263       usage("remote-url ?URL|off?");
   262    264     }
   263    265     if( g.argc==3 ){
   264    266       db_unset("last-sync-url", 0);
   265    267       db_unset("last-sync-pw", 0);
   266    268       if( is_false(g.argv[2]) ) return;
   267         -    url_parse(g.argv[2], URL_REMEMBER|URL_PROMPT_PW);
          269  +    url_parse(g.argv[2], URL_REMEMBER|URL_PROMPT_PW|URL_ASK_REMEMBER_PW);
   268    270     }
          271  +  url_remember();
   269    272     zUrl = db_get("last-sync-url", 0);
   270    273     if( zUrl==0 ){
   271    274       fossil_print("off\n");
   272    275       return;
   273    276     }else{
   274    277       url_parse(zUrl, 0);
   275    278       fossil_print("%s\n", g.urlCanonical);
   276    279     }
   277    280   }

Changes to src/timeline.c.

   109    109   #define TIMELINE_BRIEF    0x0004  /* Combine adjacent elements of same object */
   110    110   #define TIMELINE_GRAPH    0x0008  /* Compute a graph */
   111    111   #define TIMELINE_DISJOINT 0x0010  /* Elements are not contiguous */
   112    112   #define TIMELINE_FCHANGES 0x0020  /* Detail file changes */
   113    113   #define TIMELINE_BRCOLOR  0x0040  /* Background color by branch name */
   114    114   #define TIMELINE_UCOLOR   0x0080  /* Background color by user */
   115    115   #define TIMELINE_FRENAMES 0x0100  /* Detail only file name changes */
          116  +#define TIMELINE_UNHIDE   0x0200  /* Unhide check-ins with "hidden" tag */
   116    117   #endif
   117    118   
   118    119   /*
   119    120   ** Hash a string and use the hash to determine a background color.
   120    121   */
   121    122   char *hash_color(const char *z){
   122    123     int i;                       /* Loop counter */
................................................................................
   587    588     int omitDescenders,       /* True to omit descenders */
   588    589     int fileDiff              /* True for file diff.  False for check-in diff */
   589    590   ){
   590    591     if( pGraph && pGraph->nErr==0 && pGraph->nRow>0 ){
   591    592       GraphRow *pRow;
   592    593       int i;
   593    594       char cSep;
          595  +    
   594    596       @ <script  type="text/JavaScript">
   595    597       @ /* <![CDATA[ */
   596    598       @ var railPitch=%d(pGraph->iRailPitch);
   597    599   
   598    600       /* the rowinfo[] array contains all the information needed to generate
   599    601       ** the graph.  Each entry contains information for a single row:
   600    602       **
................................................................................
   848    850       @     canvasDiv.removeChild(selBox);
   849    851       @     selBox = null;
   850    852       @     selRow = null;
   851    853       @   }else{
   852    854       if( fileDiff ){
   853    855         @     location.href="%R/fdiff?v1="+selRow.h+"&v2="+p.h+"&sbs=1";
   854    856       }else{
   855         -      @     location.href="%R/vdiff?from="+selRow.h+"&to="+p.h+"&sbs=1";
          857  +      if( db_get_boolean("show-version-diffs", 0)==0 ){
          858  +        @     location.href="%R/vdiff?from="+selRow.h+"&to="+p.h+"&sbs=0";
          859  +      }else{
          860  +        @     location.href="%R/vdiff?from="+selRow.h+"&to="+p.h+"&sbs=1";
          861  +      }
   856    862       }
   857    863       @   }
   858    864       @ }
   859    865       @ var lastId = "m"+rowinfo[rowinfo.length-1].id;
   860    866       @ var lastY = 0;
   861    867       @ function checkHeight(){
   862    868       @   var h = absoluteY(lastId);
................................................................................
   896    902   }
   897    903   
   898    904   /*
   899    905   ** Return a pointer to a constant string that forms the basis
   900    906   ** for a timeline query for the WWW interface.
   901    907   */
   902    908   const char *timeline_query_for_www(void){
   903         -  static char *zBase = 0;
   904    909     static const char zBaseSql[] =
   905    910       @ SELECT
   906    911       @   blob.rid AS blobRid,
   907    912       @   uuid AS uuid,
   908    913       @   datetime(event.mtime,'localtime') AS timestamp,
   909    914       @   coalesce(ecomment, comment) AS comment,
   910    915       @   coalesce(euser, user) AS user,
................................................................................
   916    921       @       AND tagxref.rid=blob.rid AND tagxref.tagtype>0) AS tags,
   917    922       @   tagid AS tagid,
   918    923       @   brief AS brief,
   919    924       @   event.mtime AS mtime
   920    925       @  FROM event CROSS JOIN blob
   921    926       @ WHERE blob.rid=event.objid
   922    927     ;
   923         -  if( zBase==0 ){
   924         -    zBase = mprintf(zBaseSql, TAG_BRANCH, TAG_BRANCH);
   925         -  }
   926         -  return zBase;
          928  +  return zBaseSql;
   927    929   }
   928    930   
   929    931   /*
   930    932   ** Generate a submenu element with a single parameter change.
   931    933   */
   932    934   static void timeline_submenu(
   933    935     HQuery *pUrl,            /* Base URL */
................................................................................
  1115   1117       tmFlags &= ~TIMELINE_GRAPH;
  1116   1118       url_add_parameter(&url, "ng", 0);
  1117   1119     }
  1118   1120     if( P("brbg")!=0 ){
  1119   1121       tmFlags |= TIMELINE_BRCOLOR;
  1120   1122       url_add_parameter(&url, "brbg", 0);
  1121   1123     }
         1124  +  if( P("unhide")!=0 ){
         1125  +    tmFlags |= TIMELINE_UNHIDE;
         1126  +    url_add_parameter(&url, "unhide", 0);
         1127  +  }
  1122   1128     if( P("ubg")!=0 ){
  1123   1129       tmFlags |= TIMELINE_UCOLOR;
  1124   1130       url_add_parameter(&url, "ubg", 0);
  1125   1131     }
  1126   1132     if( zUses!=0 ){
  1127   1133       int ufid = db_int(0, "SELECT rid FROM blob WHERE uuid GLOB '%q*'", zUses);
  1128   1134       if( ufid ){
................................................................................
  1149   1155     blob_zero(&sql);
  1150   1156     blob_zero(&desc);
  1151   1157     blob_append(&sql, "INSERT OR IGNORE INTO timeline ", -1);
  1152   1158     blob_append(&sql, timeline_query_for_www(), -1);
  1153   1159     if( P("fc")!=0 || P("v")!=0 || P("detail")!=0 ){
  1154   1160       tmFlags |= TIMELINE_FCHANGES;
  1155   1161       url_add_parameter(&url, "v", 0);
         1162  +  }
         1163  +  if( (tmFlags & TIMELINE_UNHIDE)==0 ){
         1164  +    blob_appendf(&sql, " AND NOT EXISTS(SELECT 1 FROM tagxref"
         1165  +                 "     WHERE tagid=%d AND tagtype>0 AND rid=blob.rid)",
         1166  +                 TAG_HIDDEN);
  1156   1167     }
  1157   1168     if( !useDividers ) url_add_parameter(&url, "nd", 0);
  1158   1169     if( ((from_rid && to_rid) || (me_rid && you_rid)) && g.perm.Read ){
  1159   1170       /* If from= and to= are present, display all nodes on a path connecting
  1160   1171       ** the two */
  1161   1172       PathNode *p = 0;
  1162   1173       const char *zFrom = 0;
................................................................................
  1274   1285           ** branch that is infrequently merged with a much more activate branch.
  1275   1286           */
  1276   1287           blob_appendf(&sql,
  1277   1288             " OR EXISTS(SELECT 1 FROM plink CROSS JOIN tagxref ON rid=cid"
  1278   1289                        " WHERE tagid=%d AND tagtype>0 AND pid=blob.rid)",
  1279   1290              tagid
  1280   1291           );
         1292  +        if( (tmFlags & TIMELINE_UNHIDE)==0 ){
         1293  +          blob_appendf(&sql,
         1294  +            " AND NOT EXISTS(SELECT 1 FROM plink JOIN tagxref ON rid=cid"
         1295  +                       " WHERE tagid=%d AND tagtype>0 AND pid=blob.rid)",
         1296  +            TAG_HIDDEN
         1297  +          );
         1298  +        }
  1281   1299           if( P("mionly")==0 ){
  1282   1300             blob_appendf(&sql,
  1283   1301               " OR EXISTS(SELECT 1 FROM plink CROSS JOIN tagxref ON rid=pid"
  1284   1302                          " WHERE tagid=%d AND tagtype>0 AND cid=blob.rid)",
  1285   1303               tagid
  1286   1304             );
         1305  +          if( (tmFlags & TIMELINE_UNHIDE)==0 ){
         1306  +            blob_appendf(&sql, " AND NOT EXISTS(SELECT 1 FROM plink JOIN tagxref ON rid=pid"
         1307  +                       " WHERE tagid=%d AND tagtype>0 AND cid=blob.rid)",
         1308  +                         TAG_HIDDEN);
         1309  +          }
  1287   1310           }else{
  1288   1311             url_add_parameter(&url, "mionly", "1");
  1289   1312           }
  1290   1313         }else{
  1291   1314           url_add_parameter(&url, "t", zTagName);
  1292   1315         }
  1293   1316         blob_appendf(&sql, ")");
................................................................................
  1473   1496         }
  1474   1497         if( zType[0]=='a' || zType[0]=='c' ){
  1475   1498           if( tmFlags & TIMELINE_FCHANGES ){
  1476   1499             timeline_submenu(&url, "Hide Files", "v", 0, 0);
  1477   1500           }else{
  1478   1501             timeline_submenu(&url, "Show Files", "v", "", 0);
  1479   1502           }
         1503  +        if( (tmFlags & TIMELINE_UNHIDE)==0 ){
         1504  +          timeline_submenu(&url, "Unhide", "unhide", "", 0);
         1505  +        }
  1480   1506         }
  1481   1507       }
  1482   1508     }
  1483   1509     if( P("showsql") ){
  1484   1510       @ <blockquote>%h(blob_str(&sql))</blockquote>
  1485   1511     }
  1486   1512     blob_zero(&sql);
................................................................................
  1516   1542   **    7.  branch
  1517   1543   */
  1518   1544   void print_timeline(Stmt *q, int nLimit, int width, int verboseFlag){
  1519   1545     int nAbsLimit = (nLimit >= 0) ? nLimit : -nLimit;
  1520   1546     int nLine = 0;
  1521   1547     int nEntry = 0;
  1522   1548     char zPrevDate[20];
  1523         -  const char *zCurrentUuid=0;
         1549  +  const char *zCurrentUuid = 0;
  1524   1550     int fchngQueryInit = 0;     /* True if fchngQuery is initialized */
  1525   1551     Stmt fchngQuery;            /* Query for file changes on check-ins */
         1552  +  int rc;
         1553  +
  1526   1554     zPrevDate[0] = 0;
  1527         -
  1528   1555     if( g.localOpen ){
  1529   1556       int rid = db_lget_int("checkout", 0);
  1530   1557       zCurrentUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
  1531   1558     }
  1532   1559   
  1533         -  while( db_step(q)==SQLITE_ROW ){
         1560  +  while( (rc=db_step(q))==SQLITE_ROW ){
  1534   1561       int rid = db_column_int(q, 0);
  1535   1562       const char *zId = db_column_text(q, 1);
  1536   1563       const char *zDate = db_column_text(q, 2);
  1537   1564       const char *zCom = db_column_text(q, 3);
  1538   1565       int nChild = db_column_int(q, 4);
  1539   1566       int nParent = db_column_int(q, 5);
  1540   1567       char *zFree = 0;
  1541   1568       int n = 0;
  1542   1569       char zPrefix[80];
  1543   1570       char zUuid[UUID_SIZE+1];
  1544   1571   
  1545   1572       if( nAbsLimit!=0 ){
  1546   1573         if( nLimit<0 && nLine>=nAbsLimit ){
  1547         -        fossil_print("=== line limit (%d) reached ===\n", nAbsLimit);
         1574  +        fossil_print("--- line limit (%d) reached ---\n", nAbsLimit);
  1548   1575           break; /* line count limit hit, stop. */
  1549   1576         }else if( nEntry>=nAbsLimit ){
  1550         -        fossil_print("=== entry limit (%d) reached ===\n", nAbsLimit);
         1577  +        fossil_print("--- entry limit (%d) reached ---\n", nAbsLimit);
  1551   1578           break; /* entry count limit hit, stop. */
  1552   1579         }
  1553   1580       }
  1554   1581       sqlite3_snprintf(sizeof(zUuid), zUuid, "%.10s", zId);
  1555   1582       if( memcmp(zDate, zPrevDate, 10) ){
  1556   1583         fossil_print("=== %.10s ===\n", zDate);
  1557   1584         memcpy(zPrevDate, zDate, 10);
................................................................................
  1609   1636             fossil_print("   EDITED %s\n", zFilename);
  1610   1637           }
  1611   1638           nLine++; /* record another line */
  1612   1639         }
  1613   1640         db_reset(&fchngQuery);
  1614   1641       }
  1615   1642       nEntry++; /* record another complete entry */
         1643  +  }
         1644  +  if( rc==SQLITE_DONE ){
         1645  +    /* Did the underlying query actually have all entries? */
         1646  +    if( nAbsLimit==0 ){
         1647  +      fossil_print("+++ end of timeline (%d) +++\n", nEntry);
         1648  +    }else{
         1649  +      fossil_print("+++ no more data (%d) +++\n", nEntry);
         1650  +    }
  1616   1651     }
  1617   1652     if( fchngQueryInit ) db_finalize(&fchngQuery);
  1618   1653   }
  1619   1654   
  1620   1655   /*
  1621   1656   ** Return a pointer to a static string that forms the basis for
  1622   1657   ** a timeline query for display on a TTY.
................................................................................
  1681   1716   ** The DATETIME should be in the ISO8601 format.  For
  1682   1717   ** examples: "2007-08-18 07:21:21".  You can also say "current"
  1683   1718   ** for the current version or "now" for the current time.
  1684   1719   **
  1685   1720   ** Options:
  1686   1721   **   -n|--limit N         Output the first N entries (default 20 lines).
  1687   1722   **                        N=0 means no limit.
         1723  +**   --offset P           skip P changes
  1688   1724   **   -t|--type TYPE       Output items from the given types only, such as:
  1689   1725   **                            ci = file commits only
  1690   1726   **                            e  = events only
  1691   1727   **                            t  = tickets only
  1692   1728   **                            w  = wiki commits only
  1693   1729   **   -v|--verbose         Output the list of files changed by each commit
  1694   1730   **                        and the type of each change (edited, deleted,
  1695   1731   **                        etc.) after the checkin comment.
  1696         -**   -W|--width <num>     With of lines (default 79). Must be >20 or 0.
         1732  +**   -W|--width <num>     With of lines (default 79). Must be >20 or 0
         1733  +**                        (= no limit, resulting in a single line per entry).
  1697   1734   */
  1698   1735   void timeline_cmd(void){
  1699   1736     Stmt q;
  1700   1737     int n, k, width;
  1701   1738     const char *zLimit;
  1702   1739     const char *zWidth;
         1740  +  const char *zOffset;
  1703   1741     const char *zType;
  1704   1742     char *zOrigin;
  1705   1743     char *zDate;
  1706   1744     Blob sql;
  1707   1745     int objid = 0;
  1708   1746     Blob uuid;
  1709   1747     int mode = 0 ;       /* 0:none  1: before  2:after  3:children  4:parents */
  1710   1748     int verboseFlag = 0 ;
         1749  +  int iOffset;
         1750  +
  1711   1751     verboseFlag = find_option("verbose","v", 0)!=0;
  1712   1752     if( !verboseFlag){
  1713   1753       verboseFlag = find_option("showfiles","f", 0)!=0; /* deprecated */
  1714   1754     }
  1715   1755     db_find_and_open_repository(0, 0);
  1716   1756     zLimit = find_option("limit","n",1);
  1717   1757     zWidth = find_option("width","W",1);
................................................................................
  1728   1768       width = atoi(zWidth);
  1729   1769       if( (width!=0) && (width<=20) ){
  1730   1770         fossil_fatal("--width|-W value must be >20 or 0");
  1731   1771       }
  1732   1772     }else{
  1733   1773       width = 79;
  1734   1774     }
         1775  +  zOffset = find_option("offset",0,1);
         1776  +  iOffset = zOffset ? atoi(zOffset) : 0;
  1735   1777     if( g.argc>=4 ){
  1736   1778       k = strlen(g.argv[2]);
  1737   1779       if( strncmp(g.argv[2],"before",k)==0 ){
  1738   1780         mode = 1;
  1739   1781       }else if( strncmp(g.argv[2],"after",k)==0 && k>1 ){
  1740   1782         mode = 2;
  1741   1783       }else if( strncmp(g.argv[2],"descendants",k)==0 ){
................................................................................
  1743   1785       }else if( strncmp(g.argv[2],"children",k)==0 ){
  1744   1786         mode = 3;
  1745   1787       }else if( strncmp(g.argv[2],"ancestors",k)==0 && k>1 ){
  1746   1788         mode = 4;
  1747   1789       }else if( strncmp(g.argv[2],"parents",k)==0 ){
  1748   1790         mode = 4;
  1749   1791       }else if(!zType && !zLimit){
  1750         -      usage("?WHEN? ?BASELINE|DATETIME? ?-n|--limit #? ?-t|--type TYPE? ?-W|--width WIDTH?");
         1792  +      usage("?WHEN? ?BASELINE|DATETIME? ?-n|--limit #? ?-t|--type TYPE? "
         1793  +            "?-W|--width WIDTH?");
  1751   1794       }
  1752   1795       if( '-' != *g.argv[3] ){
  1753   1796         zOrigin = g.argv[3];
  1754   1797       }else{
  1755   1798         zOrigin = "now";
  1756   1799       }
  1757   1800     }else if( g.argc==3 ){
................................................................................
  1803   1846       }
  1804   1847       blob_appendf(&sql, " AND blob.rid IN ok");
  1805   1848     }
  1806   1849     if( zType && (zType[0]!='a') ){
  1807   1850       blob_appendf(&sql, " AND event.type=%Q ", zType);
  1808   1851     }
  1809   1852     blob_appendf(&sql, " ORDER BY event.mtime DESC");
         1853  +  if( iOffset>0 ){
         1854  +    /* Don't handle LIMIT here, otherwise print_timeline()
         1855  +     * will not determine the end-marker correctly! */
         1856  +    blob_appendf(&sql, " LIMIT -1 OFFSET %d", iOffset);
         1857  +  }
  1810   1858     db_prepare(&q, blob_str(&sql));
  1811   1859     blob_reset(&sql);
  1812   1860     print_timeline(&q, n, width, verboseFlag);
  1813   1861     db_finalize(&q);
  1814   1862   }
  1815   1863   
  1816   1864   /*

Changes to src/tkt.c.

  1255   1255                 for(i=0; i<pTicket->nField; i++){
  1256   1256                   Blob val;
  1257   1257                   const char *z;
  1258   1258                   z = pTicket->aField[i].zName;
  1259   1259                   blob_set(&val, pTicket->aField[i].zValue);
  1260   1260                   if( z[0]=='+' ){
  1261   1261                     fossil_print("  Append to ");
  1262         -		    z++;
  1263         -		  }else{
  1264         -		    fossil_print("  Change ");
  1265         -                }
  1266         -		  fossil_print("%h: ",z);
  1267         -		  if( blob_size(&val)>50 || contains_newline(&val)) {
         1262  +            z++;
         1263  +          }else{
         1264  +            fossil_print("  Change ");
         1265  +          }
         1266  +          fossil_print("%h: ",z);
         1267  +          if( blob_size(&val)>50 || contains_newline(&val)) {
  1268   1268                     fossil_print("\n    ",blob_str(&val));
  1269   1269                     comment_print(blob_str(&val),4,79);
  1270   1270                   }else{
  1271   1271                     fossil_print("%s\n",blob_str(&val));
  1272   1272                   }
  1273   1273                   blob_reset(&val);
  1274   1274                 }

Changes to src/url.c.

    15     15   **
    16     16   *******************************************************************************
    17     17   **
    18     18   ** This file contains code for parsing URLs that appear on the command-line
    19     19   */
    20     20   #include "config.h"
    21     21   #include "url.h"
           22  +#include <stdio.h>
           23  +
           24  +#ifdef _WIN32
           25  +#include <io.h>
           26  +#ifndef isatty
           27  +#define isatty(d) _isatty(d)
           28  +#endif
           29  +#ifndef fileno
           30  +#define fileno(s) _fileno(s)
           31  +#endif
           32  +#endif
    22     33   
    23     34   #if INTERFACE
    24     35   /*
    25     36   ** Flags for url_parse()
    26     37   */
    27     38   #define URL_PROMPT_PW        0x001  /* Prompt for password if needed */
    28     39   #define URL_REMEMBER         0x002  /* Remember the url for later reuse */
................................................................................
    62     73   **
    63     74   ** HTTP url format as follows (HTTPS is the same with a different scheme):
    64     75   **
    65     76   **     http://userid:password@host:port/path
    66     77   **
    67     78   ** SSH url format is:
    68     79   **
    69         -**     ssh://userid:password@host:port/path?fossil=path/to/fossil.exe
           80  +**     ssh://userid@host:port/path?fossil=path/to/fossil.exe
    70     81   **
    71     82   */
    72     83   void url_parse(const char *zUrl, unsigned int urlFlags){
    73     84     int i, j, c;
    74     85     char *zFile = 0;
    75         -  int bPrompted = 0;
    76         -  int bSetUrl = 1;
    77     86    
    78     87     if( zUrl==0 ){
    79     88       zUrl = db_get("last-sync-url", 0);
    80     89       if( zUrl==0 ) return;
    81         -    g.urlPasswd = unobscure(db_get("last-sync-pw", 0));
    82         -    bSetUrl = 0;
           90  +    if( g.urlPasswd==0 ){
           91  +      g.urlPasswd = unobscure(db_get("last-sync-pw", 0));
           92  +    }
    83     93     }
    84     94   
    85     95     if( strncmp(zUrl, "http://", 7)==0
    86     96      || strncmp(zUrl, "https://", 8)==0
    87     97      || strncmp(zUrl, "ssh://", 6)==0
    88     98     ){
    89     99       int iStart;
................................................................................
   112    122       for(i=iStart; (c=zUrl[i])!=0 && c!='/' && c!='@'; i++){}
   113    123       if( c=='@' ){
   114    124         /* Parse up the user-id and password */
   115    125         for(j=iStart; j<i && zUrl[j]!=':'; j++){}
   116    126         g.urlUser = mprintf("%.*s", j-iStart, &zUrl[iStart]);
   117    127         dehttpize(g.urlUser);
   118    128         if( j<i ){
          129  +        if( ( urlFlags & URL_REMEMBER ) && g.urlIsSsh==0 ){
          130  +          urlFlags |= URL_ASK_REMEMBER_PW;
          131  +        }
   119    132           g.urlPasswd = mprintf("%.*s", i-j-1, &zUrl[j+1]);
   120    133           dehttpize(g.urlPasswd);
   121    134         }
   122         -      if( g.urlIsSsh && g.urlPasswd ){
   123         -        zLogin = mprintf("%t:*@", g.urlUser);
   124         -      }else{
   125         -        zLogin = mprintf("%t@", g.urlUser);
          135  +      if( g.urlIsSsh ){
          136  +        urlFlags &= ~URL_ASK_REMEMBER_PW;
   126    137         }
          138  +      zLogin = mprintf("%t@", g.urlUser);
   127    139         for(j=i+1; (c=zUrl[j])!=0 && c!='/' && c!=':'; j++){}
   128    140         g.urlName = mprintf("%.*s", j-i-1, &zUrl[i+1]);
   129    141         i = j;
   130    142       }else{
   131    143         for(i=iStart; (c=zUrl[i])!=0 && c!='/' && c!=':'; i++){}
   132    144         g.urlName = mprintf("%.*s", i-iStart, &zUrl[iStart]);
   133    145         zLogin = mprintf("");
................................................................................
   208    220       }else{
   209    221         free(zFile);
   210    222         fossil_fatal("unknown repository: %s", zUrl);
   211    223       }
   212    224     }else{
   213    225       fossil_fatal("unknown repository: %s", zUrl);
   214    226     }
   215         -  g.urlFlags = urlFlags;
          227  +  if( urlFlags ) g.urlFlags = urlFlags;
   216    228     if( g.urlIsFile ){
   217    229       Blob cfile;
   218    230       dehttpize(zFile);  
   219    231       file_canonical_name(zFile, &cfile, 0);
   220    232       free(zFile);
   221    233       g.urlProtocol = "file";
   222    234       g.urlPath = "";
   223    235       g.urlName = mprintf("%b", &cfile);
   224    236       g.urlCanonical = mprintf("file://%T", g.urlName);
   225    237       blob_reset(&cfile);
   226    238     }else if( g.urlUser!=0 && g.urlPasswd==0 && (urlFlags & URL_PROMPT_PW) ){
   227    239       url_prompt_for_password();
   228         -    bPrompted = 1;
   229         -  }
   230         -  if( urlFlags & URL_REMEMBER ){
   231         -    if( bSetUrl ){
   232         -      db_set("last-sync-url", g.urlCanonical, 0);
   233         -    }
   234         -    if( !bPrompted && g.urlPasswd && g.urlUser ){
   235         -      db_set("last-sync-pw", obscure(g.urlPasswd), 0);
          240  +  }else if( g.urlUser!=0 && ( urlFlags & URL_ASK_REMEMBER_PW ) ){
          241  +    if( isatty(fileno(stdin)) ){
          242  +      if( save_password_prompt() ){
          243  +        g.urlFlags = urlFlags |= URL_REMEMBER_PW;
          244  +      }else{
          245  +        g.urlFlags = urlFlags &= ~URL_REMEMBER_PW;
          246  +      }
   236    247       }
   237    248     }
   238    249   }
   239    250   
   240    251   /*
   241    252   ** COMMAND: test-urlparser
   242    253   **
................................................................................
   442    453       g.urlFlags |= URL_PROMPTED;
   443    454       g.urlPasswd = prompt_for_user_password(g.urlUser);
   444    455       if( g.urlPasswd[0]
   445    456        && (g.urlFlags & (URL_REMEMBER|URL_ASK_REMEMBER_PW))!=0
   446    457       ){
   447    458         if( save_password_prompt() ){
   448    459           g.urlFlags |= URL_REMEMBER_PW;
   449         -        if( g.urlFlags & URL_REMEMBER ){
   450         -          db_set("last-sync-pw", obscure(g.urlPasswd), 0);
   451         -        }
          460  +      }else{
          461  +        g.urlFlags &= ~URL_REMEMBER_PW;
   452    462         }
   453    463       }
   454    464     }else{
   455    465       fossil_fatal("missing or incorrect password for user \"%s\"",
   456    466                    g.urlUser);
   457    467     }
   458    468   }
   459    469   
   460    470   /*
   461         -** Remember the URL if requested.
          471  +** Remember the URL and password if requested.
   462    472   */
   463    473   void url_remember(void){
   464         -  db_set("last-sync-url", g.urlCanonical, 0);
   465         -  if( g.urlFlags & URL_REMEMBER_PW ){
   466         -    db_set("last-sync-pw", obscure(g.urlPasswd), 0);
          474  +  if( g.urlFlags & URL_REMEMBER ){
          475  +    db_set("last-sync-url", g.urlCanonical, 0);
          476  +    if( g.urlUser!=0 && g.urlPasswd!=0 && ( g.urlFlags & URL_REMEMBER_PW ) ){
          477  +      db_set("last-sync-pw", obscure(g.urlPasswd), 0);
          478  +    }
   467    479     }
   468         -  g.urlFlags |= URL_REMEMBER;
   469    480   }
   470    481   
   471    482   /* Preemptively prompt for a password if a username is given in the
   472    483   ** URL but no password.
   473    484   */
   474    485   void url_get_password_if_needed(void){
   475    486     if( (g.urlUser && g.urlUser[0])
   476    487      && (g.urlPasswd==0 || g.urlPasswd[0]==0)
   477         -   && isatty(fileno(stdin)) 
          488  +   && isatty(fileno(stdin))
   478    489     ){
   479    490       url_prompt_for_password();
   480    491     }
   481    492   }

Changes to src/user.c.

   133    133   
   134    134   /*
   135    135   ** Prompt to save Fossil user password
   136    136   */
   137    137   int save_password_prompt(){
   138    138     Blob x;
   139    139     char c;
          140  +  const char *old = db_get("last-sync-pw", 0);
          141  +  if( (old!=0) && fossil_strcmp(unobscure(old), g.urlPasswd)==0 ){
          142  +     return 0;
          143  +  }
   140    144     prompt_user("remember password (Y/n)? ", &x);
   141    145     c = blob_str(&x)[0];
   142    146     blob_reset(&x);
   143    147     return ( c!='n' && c!='N' );
   144    148   }
   145    149   
   146    150   /*
................................................................................
   288    292         db_multi_exec("UPDATE user SET pw=%Q, mtime=now() WHERE uid=%d",
   289    293                       zSecret, uid);
   290    294         free(zSecret);
   291    295       }
   292    296     }else if( n>=2 && strncmp(g.argv[2],"capabilities",2)==0 ){
   293    297       int uid;
   294    298       if( g.argc!=4 && g.argc!=5 ){
   295         -      usage("user capabilities USERNAME ?PERMISSIONS?");
          299  +      usage("capabilities USERNAME ?PERMISSIONS?");
   296    300       }
   297    301       uid = db_int(0, "SELECT uid FROM user WHERE login=%Q", g.argv[3]);
   298    302       if( uid==0 ){
   299    303         fossil_fatal("no such user: %s", g.argv[3]);
   300    304       }
   301    305       if( g.argc==5 ){
   302    306         db_multi_exec(

Changes to src/wiki.c.

    25     25   
    26     26   /*
    27     27   ** Return true if the input string is a well-formed wiki page name.
    28     28   **
    29     29   ** Well-formed wiki page names do not begin or end with whitespace,
    30     30   ** and do not contain tabs or other control characters and do not
    31     31   ** contain more than a single space character in a row.  Well-formed
    32         -** names must be between 3 and 100 characters in length, inclusive.
           32  +** names must be between 1 and 100 characters in length, inclusive.
    33     33   */
    34     34   int wiki_name_is_wellformed(const unsigned char *z){
    35     35     int i;
    36     36     if( z[0]<=0x20 ){
    37     37       return 0;
    38     38     }
    39     39     for(i=1; z[i]; i++){
    40     40       if( z[i]<0x20 ) return 0;
    41     41       if( z[i]==0x20 && z[i-1]==0x20 ) return 0;
    42     42     }
    43     43     if( z[i-1]==' ' ) return 0;
    44         -  if( i<3 || i>100 ) return 0;
           44  +  if( i<1 || i>100 ) return 0;
    45     45     return 1;
    46     46   }
    47     47   
    48     48   /*
    49     49   ** Output rules for well-formed wiki pages
    50     50   */
    51     51   static void well_formed_wiki_name_rules(void){
    52     52     @ <ul>
    53     53     @ <li> Must not begin or end with a space.</li>
    54     54     @ <li> Must not contain any control characters, including tab or
    55     55     @      newline.</li>
    56     56     @ <li> Must not have two or more spaces in a row internally.</li>
    57         -  @ <li> Must be between 3 and 100 characters in length.</li>
           57  +  @ <li> Must be between 1 and 100 characters in length.</li>
    58     58     @ </ul>
    59     59   }
    60     60   
    61     61   /*
    62     62   ** Check a wiki name.  If it is not well-formed, then issue an error
    63     63   ** and return true.  If it is well-formed, return false.
    64     64   */
................................................................................
   867    867     if( !g.perm.RdWiki ){ login_needed(); return; }
   868    868     zTitle = PD("title","*");
   869    869     style_header("Wiki Pages Found");
   870    870     @ <ul>
   871    871     db_prepare(&q, 
   872    872       "SELECT substr(tagname, 6, 1000) FROM tag WHERE tagname like 'wiki-%%%q%%'"
   873    873       " ORDER BY lower(tagname) /*sort*/" ,
   874         -	zTitle);
          874  +    zTitle);
   875    875     while( db_step(&q)==SQLITE_ROW ){
   876    876       const char *zName = db_column_text(&q, 0);
   877    877       @ <li>%z(href("%R/wiki?name=%T",zName))%h(zName)</a></li>
   878    878     }
   879    879     db_finalize(&q);
   880    880     @ </ul>
   881    881     style_footer();

Added src/winfile.c.

            1  +/*
            2  +** Copyright (c) 2006 D. Richard Hipp
            3  +**
            4  +** This program is free software; you can redistribute it and/or
            5  +** modify it under the terms of the Simplified BSD License (also
            6  +** known as the "2-Clause License" or "FreeBSD License".)
            7  +
            8  +** This program is distributed in the hope that it will be useful,
            9  +** but without any warranty; without even the implied warranty of
           10  +** merchantability or fitness for a particular purpose.
           11  +**
           12  +** Author contact information:
           13  +**   drh@hwaci.com
           14  +**   http://www.hwaci.com/drh/
           15  +**
           16  +*******************************************************************************
           17  +**
           18  +** This file implements several non-trivial file handling wrapper functions
           19  +** on Windows using the Win32 API.
           20  +*/
           21  +#include "config.h"
           22  +#ifdef _WIN32
           23  +/* This code is for win32 only */
           24  +#include <sys/stat.h>
           25  +#include <windows.h>
           26  +#include "winfile.h"
           27  +
           28  +/*
           29  +** Fill stat buf with information received from stat() or lstat().
           30  +** lstat() is called on Unix if isWd is TRUE and allow-symlinks setting is on.
           31  +**
           32  +*/
           33  +int win32_stat(const char *zFilename, struct fossilStat *buf, int isWd){
           34  +  WIN32_FILE_ATTRIBUTE_DATA attr;
           35  +  wchar_t *zMbcs = fossil_utf8_to_filename(zFilename);
           36  +  int rc = GetFileAttributesExW(zMbcs, GetFileExInfoStandard, &attr);
           37  +  fossil_filename_free(zMbcs);
           38  +  if( rc ){
           39  +    ULARGE_INTEGER ull;
           40  +    ull.LowPart = attr.ftLastWriteTime.dwLowDateTime;
           41  +    ull.HighPart = attr.ftLastWriteTime.dwHighDateTime;
           42  +    buf->st_mode = (attr.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ?
           43  +                   S_IFDIR : S_IFREG;
           44  +    buf->st_size = (((i64)attr.nFileSizeHigh)<<32) | attr.nFileSizeLow;
           45  +    buf->st_mtime = ull.QuadPart / 10000000ULL - 11644473600ULL;
           46  +  }
           47  +  return !rc;
           48  +}
           49  +
           50  +/*
           51  +** Wrapper around the access() system call.  This code was copied from Tcl
           52  +** 8.6 and then modified.
           53  +*/
           54  +int win32_access(const char *zFilename, int flags){
           55  +  int rc = 0;
           56  +  PSECURITY_DESCRIPTOR pSd = NULL;
           57  +  unsigned long size;
           58  +  PSID pSid = NULL;
           59  +  BOOL sidDefaulted;
           60  +  BOOL impersonated = FALSE;
           61  +  SID_IDENTIFIER_AUTHORITY unmapped = {{0, 0, 0, 0, 0, 22}};
           62  +  GENERIC_MAPPING genMap;
           63  +  HANDLE hToken = NULL;
           64  +  DWORD desiredAccess = 0, grantedAccess = 0;
           65  +  BOOL accessYesNo = FALSE;
           66  +  PRIVILEGE_SET privSet;
           67  +  DWORD privSetSize = sizeof(PRIVILEGE_SET);
           68  +  wchar_t *zMbcs = fossil_utf8_to_filename(zFilename);
           69  +  DWORD attr = GetFileAttributesW(zMbcs);
           70  +
           71  +  if( attr==INVALID_FILE_ATTRIBUTES ){
           72  +    /*
           73  +     * File might not exist.
           74  +     */
           75  +
           76  +    if( GetLastError()!=ERROR_SHARING_VIOLATION ){
           77  +      rc = -1; goto done;
           78  +    }
           79  +  }
           80  +
           81  +  if( flags==F_OK ){
           82  +    /*
           83  +     * File exists, nothing else to check.
           84  +     */
           85  +
           86  +    goto done;
           87  +  }
           88  +
           89  +  if( (flags & W_OK)
           90  +      && (attr & FILE_ATTRIBUTE_READONLY)
           91  +      && !(attr & FILE_ATTRIBUTE_DIRECTORY) ){
           92  +    /*
           93  +     * The attributes say the file is not writable.  If the file is a
           94  +     * regular file (i.e., not a directory), then the file is not
           95  +     * writable, full stop.  For directories, the read-only bit is
           96  +     * (mostly) ignored by Windows, so we can't ascertain anything about
           97  +     * directory access from the attrib data.
           98  +     */
           99  +
          100  +    rc = -1; goto done;
          101  +  }
          102  +
          103  +  /*
          104  +   * It looks as if the permissions are ok, but if we are on NT, 2000 or XP,
          105  +   * we have a more complex permissions structure so we try to check that.
          106  +   * The code below is remarkably complex for such a simple thing as finding
          107  +   * what permissions the OS has set for a file.
          108  +   */
          109  +
          110  +  /*
          111  +   * First find out how big the buffer needs to be.
          112  +   */
          113  +
          114  +  size = 0;
          115  +  GetFileSecurityW(zMbcs,
          116  +      OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION |
          117  +      DACL_SECURITY_INFORMATION | LABEL_SECURITY_INFORMATION,
          118  +      0, 0, &size);
          119  +
          120  +  /*
          121  +   * Should have failed with ERROR_INSUFFICIENT_BUFFER
          122  +   */
          123  +
          124  +  if( GetLastError()!=ERROR_INSUFFICIENT_BUFFER ){
          125  +    /*
          126  +     * Most likely case is ERROR_ACCESS_DENIED, which we will convert to
          127  +     * EACCES - just what we want!
          128  +     */
          129  +
          130  +    rc = -1; goto done;
          131  +  }
          132  +
          133  +  /*
          134  +   * Now size contains the size of buffer needed.
          135  +   */
          136  +
          137  +  pSd = (PSECURITY_DESCRIPTOR)HeapAlloc(GetProcessHeap(), 0, size);
          138  +
          139  +  if( pSd==NULL ){
          140  +    rc = -1; goto done;
          141  +  }
          142  +
          143  +  /*
          144  +   * Call GetFileSecurity() for real.
          145  +   */
          146  +
          147  +  if( !GetFileSecurityW(zMbcs,
          148  +          OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION |
          149  +          DACL_SECURITY_INFORMATION | LABEL_SECURITY_INFORMATION,
          150  +          pSd, size, &size) ){
          151  +    /*
          152  +     * Error getting owner SD
          153  +     */
          154  +
          155  +    rc = -1; goto done;
          156  +  }
          157  +
          158  +  /*
          159  +   * As of Samba 3.0.23 (10-Jul-2006), unmapped users and groups are
          160  +   * assigned to SID domains S-1-22-1 and S-1-22-2, where "22" is the
          161  +   * top-level authority.  If the file owner and group is unmapped then
          162  +   * the ACL access check below will only test against world access,
          163  +   * which is likely to be more restrictive than the actual access
          164  +   * restrictions.  Since the ACL tests are more likely wrong than
          165  +   * right, skip them.  Moreover, the unix owner access permissions are
          166  +   * usually mapped to the Windows attributes, so if the user is the
          167  +   * file owner then the attrib checks above are correct (as far as they
          168  +   * go).
          169  +   */
          170  +
          171  +  if( !GetSecurityDescriptorOwner(pSd, &pSid, &sidDefaulted) ||
          172  +      memcmp(GetSidIdentifierAuthority(pSid), &unmapped,
          173  +             sizeof(SID_IDENTIFIER_AUTHORITY))==0 ){
          174  +    goto done; /* Attrib tests say access allowed. */
          175  +  }
          176  +
          177  +  /*
          178  +   * Perform security impersonation of the user and open the resulting
          179  +   * thread token.
          180  +   */
          181  +
          182  +  if( !ImpersonateSelf(SecurityImpersonation) ){
          183  +    /*
          184  +     * Unable to perform security impersonation.
          185  +     */
          186  +
          187  +    rc = -1; goto done;
          188  +  }
          189  +  impersonated = TRUE;
          190  +
          191  +  if( !OpenThreadToken(GetCurrentThread(),
          192  +      TOKEN_DUPLICATE | TOKEN_QUERY, FALSE, &hToken) ){
          193  +    /*
          194  +     * Unable to get current thread's token.
          195  +     */
          196  +
          197  +    rc = -1; goto done;
          198  +  }
          199  +
          200  +  /*
          201  +   * Setup desiredAccess according to the access priveleges we are
          202  +   * checking.
          203  +   */
          204  +
          205  +  if( flags & R_OK ){
          206  +    desiredAccess |= FILE_GENERIC_READ;
          207  +  }
          208  +  if( flags & W_OK){
          209  +    desiredAccess |= FILE_GENERIC_WRITE;
          210  +  }
          211  +
          212  +  memset(&genMap, 0, sizeof(GENERIC_MAPPING));
          213  +  genMap.GenericRead = FILE_GENERIC_READ;
          214  +  genMap.GenericWrite = FILE_GENERIC_WRITE;
          215  +  genMap.GenericExecute = FILE_GENERIC_EXECUTE;
          216  +  genMap.GenericAll = FILE_ALL_ACCESS;
          217  +
          218  +  /*
          219  +   * Perform access check using the token.
          220  +   */
          221  +
          222  +  if( !AccessCheck(pSd, hToken, desiredAccess, &genMap, &privSet,
          223  +                   &privSetSize, &grantedAccess, &accessYesNo) ){
          224  +    /*
          225  +     * Unable to perform access check.
          226  +     */
          227  +
          228  +    rc = -1; goto done;
          229  +  }
          230  +  if( !accessYesNo ) rc = -1;
          231  +
          232  +done:
          233  +
          234  +  if( hToken != NULL ){
          235  +    CloseHandle(hToken);
          236  +  }
          237  +  if( impersonated ){
          238  +    RevertToSelf();
          239  +    impersonated = FALSE;
          240  +  }
          241  +  if( pSd!=NULL ){
          242  +    HeapFree(GetProcessHeap(), 0, pSd);
          243  +  }
          244  +  fossil_filename_free(zMbcs);
          245  +  return rc;
          246  +}
          247  +
          248  +/*
          249  +** Wrapper around the chdir() system call.
          250  +** If bChroot=1, do a chroot to this dir as well
          251  +** (UNIX only)
          252  +*/
          253  +int win32_chdir(const char *zChDir, int bChroot){
          254  +  wchar_t *zPath = fossil_utf8_to_filename(zChDir);
          255  +  int rc = (int)!SetCurrentDirectoryW(zPath);
          256  +  fossil_filename_free(zPath);
          257  +  return rc;
          258  +}
          259  +
          260  +/*
          261  +** Get the current working directory.
          262  +**
          263  +** On windows, the name is converted from unicode to UTF8 and all '\\'
          264  +** characters are converted to '/'.  No conversions are needed on
          265  +** unix.
          266  +*/
          267  +void win32_getcwd(char *zBuf, int nBuf){
          268  +  int i;
          269  +  char *zUtf8;
          270  +  wchar_t *zWide = fossil_malloc( sizeof(wchar_t)*nBuf );
          271  +  if( GetCurrentDirectoryW(nBuf, zWide)==0 ){
          272  +    fossil_fatal("cannot find current working directory.");
          273  +  }
          274  +  zUtf8 = fossil_filename_to_utf8(zWide);
          275  +  fossil_free(zWide);
          276  +  for(i=0; zUtf8[i]; i++) if( zUtf8[i]=='\\' ) zUtf8[i] = '/';
          277  +  strncpy(zBuf, zUtf8, nBuf);
          278  +  fossil_filename_free(zUtf8);
          279  +}
          280  +#endif /* _WIN32  -- This code is for win32 only */

Changes to src/xfer.c.

  1265   1265     ** to use up a significant fraction of our time window.
  1266   1266     */
  1267   1267     zNow = db_text(0, "SELECT strftime('%%Y-%%m-%%dT%%H:%%M:%%S', 'now')");
  1268   1268     @ # timestamp %s(zNow)
  1269   1269     free(zNow);
  1270   1270   
  1271   1271     db_end_transaction(0);
         1272  +  configure_rebuild();
  1272   1273   }
  1273   1274   
  1274   1275   /*
  1275   1276   ** COMMAND: test-xfer
  1276   1277   **
  1277   1278   ** This command is used for debugging the server.  There is a single
  1278   1279   ** argument which is the uncompressed content of an "xfer" message
................................................................................
  1779   1780             fossil_print("Error: %s\n", zMsg);
  1780   1781             if( fossil_strcmp(zMsg, "login failed")==0 ){
  1781   1782               if( nCycle<2 ){
  1782   1783                 g.urlPasswd = 0;
  1783   1784                 go = 1;
  1784   1785                 if( g.cgiOutput==0 ){
  1785   1786                   g.urlFlags |= URL_PROMPT_PW;
         1787  +                g.urlFlags &= ~URL_PROMPTED;
  1786   1788                   url_prompt_for_password();
         1789  +                url_remember();
  1787   1790                 }
  1788   1791               }
  1789   1792             }else{
  1790   1793               blob_appendf(&xfer.err, "server says: %s\n", zMsg);
  1791   1794               nErr++;
  1792   1795             }
  1793   1796             break;

Changes to win/Makefile.PellesCGMake.

    81     81   UTILS_OBJ=$(UTILS:.exe=.obj)
    82     82   UTILS_SRC=$(foreach uf,$(UTILS),$(SRCDIR)$(uf:.exe=.c))
    83     83   
    84     84   # define the sqlite files, which need special flags on compile
    85     85   SQLITESRC=sqlite3.c
    86     86   ORIGSQLITESRC=$(foreach sf,$(SQLITESRC),$(SRCDIR)$(sf))
    87     87   SQLITEOBJ=$(foreach sf,$(SQLITESRC),$(sf:.c=.obj))
    88         -SQLITEDEFINES=-DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -Dlocaltime=fossil_localtime -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_WIN32_NO_ANSI
           88  +SQLITEDEFINES=-DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_OMIT_DEPRECATED -DSQLITE_ENABLE_EXPLAIN_COMMENTS -Dlocaltime=fossil_localtime -DSQLITE_ENABLE_LOCKING_STYLE=0
    89     89   
    90     90   # define the sqlite shell files, which need special flags on compile
    91     91   SQLITESHELLSRC=shell.c
    92     92   ORIGSQLITESHELLSRC=$(foreach sf,$(SQLITESHELLSRC),$(SRCDIR)$(sf))
    93     93   SQLITESHELLOBJ=$(foreach sf,$(SQLITESHELLSRC),$(sf:.c=.obj))
    94         -SQLITESHELLDEFINES=-Dmain=sqlite3_shell -DSQLITE_OMIT_LOAD_EXTENSION=1 -Dsqlite3_strglob=strglob
           94  +SQLITESHELLDEFINES=-Dmain=sqlite3_shell -DSQLITE_OMIT_LOAD_EXTENSION=1 -Dsqlite3_strglob=strglob -Dgetenv=fossil_getenv -Dfopen=fossil_fopen
    95     95   
    96     96   # define the th scripting files, which need special flags on compile
    97     97   THSRC=th.c th_lang.c
    98     98   ORIGTHSRC=$(foreach sf,$(THSRC),$(SRCDIR)$(sf))
    99     99   THOBJ=$(foreach sf,$(THSRC),$(sf:.c=.obj))
   100    100   
   101    101   # define the zlib files, needed by this compile

Changes to win/Makefile.dmc.

    22     22   SSL    =
    23     23   
    24     24   CFLAGS = -o
    25     25   BCC    = $(DMDIR)\bin\dmc $(CFLAGS)
    26     26   TCC    = $(DMDIR)\bin\dmc $(CFLAGS) $(DMCDEF) $(SSL) $(INCL)
    27     27   LIBS   = $(DMDIR)\extra\lib\ zlib wsock32 advapi32
    28     28   
    29         -SQLITE_OPTIONS = -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_STAT3 -Dlocaltime=fossil_localtime -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_WIN32_NO_ANSI
           29  +SQLITE_OPTIONS = -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_OMIT_DEPRECATED -DSQLITE_ENABLE_EXPLAIN_COMMENTS -Dlocaltime=fossil_localtime -DSQLITE_ENABLE_LOCKING_STYLE=0
    30     30   
    31         -SRC   = add_.c allrepo_.c attach_.c bag_.c bisect_.c blob_.c branch_.c browse_.c captcha_.c cgi_.c checkin_.c checkout_.c clearsign_.c clone_.c comformat_.c configure_.c content_.c db_.c delta_.c deltacmd_.c descendants_.c diff_.c diffcmd_.c doc_.c encode_.c event_.c export_.c file_.c finfo_.c glob_.c graph_.c gzip_.c http_.c http_socket_.c http_ssl_.c http_transport_.c import_.c info_.c json_.c json_artifact_.c json_branch_.c json_config_.c json_diff_.c json_dir_.c json_finfo_.c json_login_.c json_query_.c json_report_.c json_status_.c json_tag_.c json_timeline_.c json_user_.c json_wiki_.c leaf_.c login_.c lookslike_.c main_.c manifest_.c markdown_.c markdown_html_.c md5_.c merge_.c merge3_.c moderate_.c name_.c path_.c pivot_.c popen_.c pqueue_.c printf_.c rebuild_.c regexp_.c report_.c rss_.c schema_.c search_.c setup_.c sha1_.c shun_.c skins_.c sqlcmd_.c stash_.c stat_.c style_.c sync_.c tag_.c tar_.c th_main_.c timeline_.c tkt_.c tktsetup_.c undo_.c unicode_.c update_.c url_.c user_.c utf8_.c util_.c verify_.c vfile_.c wiki_.c wikiformat_.c winhttp_.c wysiwyg_.c xfer_.c xfersetup_.c zip_.c 
           31  +SHELL_OPTIONS = -Dmain=sqlite3_shell -DSQLITE_OMIT_LOAD_EXTENSION=1 -Dsqlite3_strglob=strglob -Dgetenv=fossil_getenv -Dfopen=fossil_fopen
    32     32   
    33         -OBJ   = $(OBJDIR)\add$O $(OBJDIR)\allrepo$O $(OBJDIR)\attach$O $(OBJDIR)\bag$O $(OBJDIR)\bisect$O $(OBJDIR)\blob$O $(OBJDIR)\branch$O $(OBJDIR)\browse$O $(OBJDIR)\captcha$O $(OBJDIR)\cgi$O $(OBJDIR)\checkin$O $(OBJDIR)\checkout$O $(OBJDIR)\clearsign$O $(OBJDIR)\clone$O $(OBJDIR)\comformat$O $(OBJDIR)\configure$O $(OBJDIR)\content$O $(OBJDIR)\db$O $(OBJDIR)\delta$O $(OBJDIR)\deltacmd$O $(OBJDIR)\descendants$O $(OBJDIR)\diff$O $(OBJDIR)\diffcmd$O $(OBJDIR)\doc$O $(OBJDIR)\encode$O $(OBJDIR)\event$O $(OBJDIR)\export$O $(OBJDIR)\file$O $(OBJDIR)\finfo$O $(OBJDIR)\glob$O $(OBJDIR)\graph$O $(OBJDIR)\gzip$O $(OBJDIR)\http$O $(OBJDIR)\http_socket$O $(OBJDIR)\http_ssl$O $(OBJDIR)\http_transport$O $(OBJDIR)\import$O $(OBJDIR)\info$O $(OBJDIR)\json$O $(OBJDIR)\json_artifact$O $(OBJDIR)\json_branch$O $(OBJDIR)\json_config$O $(OBJDIR)\json_diff$O $(OBJDIR)\json_dir$O $(OBJDIR)\json_finfo$O $(OBJDIR)\json_login$O $(OBJDIR)\json_query$O $(OBJDIR)\json_report$O $(OBJDIR)\json_status$O $(OBJDIR)\json_tag$O $(OBJDIR)\json_timeline$O $(OBJDIR)\json_user$O $(OBJDIR)\json_wiki$O $(OBJDIR)\leaf$O $(OBJDIR)\login$O $(OBJDIR)\lookslike$O $(OBJDIR)\main$O $(OBJDIR)\manifest$O $(OBJDIR)\markdown$O $(OBJDIR)\markdown_html$O $(OBJDIR)\md5$O $(OBJDIR)\merge$O $(OBJDIR)\merge3$O $(OBJDIR)\moderate$O $(OBJDIR)\name$O $(OBJDIR)\path$O $(OBJDIR)\pivot$O $(OBJDIR)\popen$O $(OBJDIR)\pqueue$O $(OBJDIR)\printf$O $(OBJDIR)\rebuild$O $(OBJDIR)\regexp$O $(OBJDIR)\report$O $(OBJDIR)\rss$O $(OBJDIR)\schema$O $(OBJDIR)\search$O $(OBJDIR)\setup$O $(OBJDIR)\sha1$O $(OBJDIR)\shun$O $(OBJDIR)\skins$O $(OBJDIR)\sqlcmd$O $(OBJDIR)\stash$O $(OBJDIR)\stat$O $(OBJDIR)\style$O $(OBJDIR)\sync$O $(OBJDIR)\tag$O $(OBJDIR)\tar$O $(OBJDIR)\th_main$O $(OBJDIR)\timeline$O $(OBJDIR)\tkt$O $(OBJDIR)\tktsetup$O $(OBJDIR)\undo$O $(OBJDIR)\unicode$O $(OBJDIR)\update$O $(OBJDIR)\url$O $(OBJDIR)\user$O $(OBJDIR)\utf8$O $(OBJDIR)\util$O $(OBJDIR)\verify$O $(OBJDIR)\vfile$O $(OBJDIR)\wiki$O $(OBJDIR)\wikiformat$O $(OBJDIR)\winhttp$O $(OBJDIR)\wysiwyg$O $(OBJDIR)\xfer$O $(OBJDIR)\xfersetup$O $(OBJDIR)\zip$O $(OBJDIR)\shell$O $(OBJDIR)\sqlite3$O $(OBJDIR)\th$O $(OBJDIR)\th_lang$O 
           33  +SRC   = add_.c allrepo_.c attach_.c bag_.c bisect_.c blob_.c branch_.c browse_.c captcha_.c cgi_.c checkin_.c checkout_.c clearsign_.c clone_.c comformat_.c configure_.c content_.c db_.c delta_.c deltacmd_.c descendants_.c diff_.c diffcmd_.c doc_.c encode_.c event_.c export_.c file_.c finfo_.c glob_.c graph_.c gzip_.c http_.c http_socket_.c http_ssl_.c http_transport_.c import_.c info_.c json_.c json_artifact_.c json_branch_.c json_config_.c json_diff_.c json_dir_.c json_finfo_.c json_login_.c json_query_.c json_report_.c json_status_.c json_tag_.c json_timeline_.c json_user_.c json_wiki_.c leaf_.c login_.c lookslike_.c main_.c manifest_.c markdown_.c markdown_html_.c md5_.c merge_.c merge3_.c moderate_.c name_.c path_.c pivot_.c popen_.c pqueue_.c printf_.c rebuild_.c regexp_.c report_.c rss_.c schema_.c search_.c setup_.c sha1_.c shun_.c skins_.c sqlcmd_.c stash_.c stat_.c style_.c sync_.c tag_.c tar_.c th_main_.c timeline_.c tkt_.c tktsetup_.c undo_.c unicode_.c update_.c url_.c user_.c utf8_.c util_.c verify_.c vfile_.c wiki_.c wikiformat_.c winfile_.c winhttp_.c wysiwyg_.c xfer_.c xfersetup_.c zip_.c 
           34  +
           35  +OBJ   = $(OBJDIR)\add$O $(OBJDIR)\allrepo$O $(OBJDIR)\attach$O $(OBJDIR)\bag$O $(OBJDIR)\bisect$O $(OBJDIR)\blob$O $(OBJDIR)\branch$O $(OBJDIR)\browse$O $(OBJDIR)\captcha$O $(OBJDIR)\cgi$O $(OBJDIR)\checkin$O $(OBJDIR)\checkout$O $(OBJDIR)\clearsign$O $(OBJDIR)\clone$O $(OBJDIR)\comformat$O $(OBJDIR)\configure$O $(OBJDIR)\content$O $(OBJDIR)\db$O $(OBJDIR)\delta$O $(OBJDIR)\deltacmd$O $(OBJDIR)\descendants$O $(OBJDIR)\diff$O $(OBJDIR)\diffcmd$O $(OBJDIR)\doc$O $(OBJDIR)\encode$O $(OBJDIR)\event$O $(OBJDIR)\export$O $(OBJDIR)\file$O $(OBJDIR)\finfo$O $(OBJDIR)\glob$O $(OBJDIR)\graph$O $(OBJDIR)\gzip$O $(OBJDIR)\http$O $(OBJDIR)\http_socket$O $(OBJDIR)\http_ssl$O $(OBJDIR)\http_transport$O $(OBJDIR)\import$O $(OBJDIR)\info$O $(OBJDIR)\json$O $(OBJDIR)\json_artifact$O $(OBJDIR)\json_branch$O $(OBJDIR)\json_config$O $(OBJDIR)\json_diff$O $(OBJDIR)\json_dir$O $(OBJDIR)\json_finfo$O $(OBJDIR)\json_login$O $(OBJDIR)\json_query$O $(OBJDIR)\json_report$O $(OBJDIR)\json_status$O $(OBJDIR)\json_tag$O $(OBJDIR)\json_timeline$O $(OBJDIR)\json_user$O $(OBJDIR)\json_wiki$O $(OBJDIR)\leaf$O $(OBJDIR)\login$O $(OBJDIR)\lookslike$O $(OBJDIR)\main$O $(OBJDIR)\manifest$O $(OBJDIR)\markdown$O $(OBJDIR)\markdown_html$O $(OBJDIR)\md5$O $(OBJDIR)\merge$O $(OBJDIR)\merge3$O $(OBJDIR)\moderate$O $(OBJDIR)\name$O $(OBJDIR)\path$O $(OBJDIR)\pivot$O $(OBJDIR)\popen$O $(OBJDIR)\pqueue$O $(OBJDIR)\printf$O $(OBJDIR)\rebuild$O $(OBJDIR)\regexp$O $(OBJDIR)\report$O $(OBJDIR)\rss$O $(OBJDIR)\schema$O $(OBJDIR)\search$O $(OBJDIR)\setup$O $(OBJDIR)\sha1$O $(OBJDIR)\shun$O $(OBJDIR)\skins$O $(OBJDIR)\sqlcmd$O $(OBJDIR)\stash$O $(OBJDIR)\stat$O $(OBJDIR)\style$O $(OBJDIR)\sync$O $(OBJDIR)\tag$O $(OBJDIR)\tar$O $(OBJDIR)\th_main$O $(OBJDIR)\timeline$O $(OBJDIR)\tkt$O $(OBJDIR)\tktsetup$O $(OBJDIR)\undo$O $(OBJDIR)\unicode$O $(OBJDIR)\update$O $(OBJDIR)\url$O $(OBJDIR)\user$O $(OBJDIR)\utf8$O $(OBJDIR)\util$O $(OBJDIR)\verify$O $(OBJDIR)\vfile$O $(OBJDIR)\wiki$O $(OBJDIR)\wikiformat$O $(OBJDIR)\winfile$O $(OBJDIR)\winhttp$O $(OBJDIR)\wysiwyg$O $(OBJDIR)\xfer$O $(OBJDIR)\xfersetup$O $(OBJDIR)\zip$O $(OBJDIR)\shell$O $(OBJDIR)\sqlite3$O $(OBJDIR)\th$O $(OBJDIR)\th_lang$O 
    34     36   
    35     37   
    36     38   RC=$(DMDIR)\bin\rcc
    37     39   RCFLAGS=-32 -w1 -I$(SRCDIR) /D__DMC__
    38     40   
    39     41   APPNAME = $(OBJDIR)\fossil$(E)
    40     42   
................................................................................
    44     46   	cd $(OBJDIR) 
    45     47   	$(DMDIR)\bin\link @link
    46     48   
    47     49   $(OBJDIR)\fossil.res:	$B\win\fossil.rc
    48     50   	$(RC) $(RCFLAGS) -o$@ $**
    49     51   
    50     52   $(OBJDIR)\link: $B\win\Makefile.dmc $(OBJDIR)\fossil.res
    51         -	+echo add allrepo attach bag bisect blob branch browse captcha cgi checkin checkout clearsign clone comformat configure content db delta deltacmd descendants diff diffcmd doc encode event export file finfo glob graph gzip http http_socket http_ssl http_transport import info json json_artifact json_branch json_config json_diff json_dir json_finfo json_login json_query json_report json_status json_tag json_timeline json_user json_wiki leaf login lookslike main manifest markdown markdown_html md5 merge merge3 moderate name path pivot popen pqueue printf rebuild regexp report rss schema search setup sha1 shun skins sqlcmd stash stat style sync tag tar th_main timeline tkt tktsetup undo unicode update url user utf8 util verify vfile wiki wikiformat winhttp wysiwyg xfer xfersetup zip shell sqlite3 th th_lang > $@
           53  +	+echo add allrepo attach bag bisect blob branch browse captcha cgi checkin checkout clearsign clone comformat configure content db delta deltacmd descendants diff diffcmd doc encode event export file finfo glob graph gzip http http_socket http_ssl http_transport import info json json_artifact json_branch json_config json_diff json_dir json_finfo json_login json_query json_report json_status json_tag json_timeline json_user json_wiki leaf login lookslike main manifest markdown markdown_html md5 merge merge3 moderate name path pivot popen pqueue printf rebuild regexp report rss schema search setup sha1 shun skins sqlcmd stash stat style sync tag tar th_main timeline tkt tktsetup undo unicode update url user utf8 util verify vfile wiki wikiformat winfile winhttp wysiwyg xfer xfersetup zip shell sqlite3 th th_lang > $@
    52     54   	+echo fossil >> $@
    53     55   	+echo fossil >> $@
    54     56   	+echo $(LIBS) >> $@
    55     57   	+echo. >> $@
    56     58   	+echo fossil >> $@
    57     59   
    58     60   translate$E: $(SRCDIR)\translate.c
................................................................................
    64     66   mkindex$E: $(SRCDIR)\mkindex.c
    65     67   	$(BCC) -o$@ $**
    66     68   
    67     69   version$E: $B\src\mkversion.c
    68     70   	$(BCC) -o$@ $**
    69     71   
    70     72   $(OBJDIR)\shell$O : $(SRCDIR)\shell.c
    71         -	$(TCC) -o$@ -c -Dmain=sqlite3_shell $(SQLITE_OPTIONS) $**
           73  +	$(TCC) -o$@ -c $(SHELL_OPTIONS) $(SQLITE_OPTIONS) $(SHELL_CFLAGS) $**
    72     74   
    73     75   $(OBJDIR)\sqlite3$O : $(SRCDIR)\sqlite3.c
    74         -	$(TCC) -o$@ -c $(SQLITE_OPTIONS) $**
           76  +	$(TCC) -o$@ -c $(SQLITE_OPTIONS) $(SQLITE_CFLAGS) $**
    75     77   
    76     78   $(OBJDIR)\th$O : $(SRCDIR)\th.c
    77     79   	$(TCC) -o$@ -c $**
    78     80   
    79     81   $(OBJDIR)\th_lang$O : $(SRCDIR)\th_lang.c
    80     82   	$(TCC) -o$@ -c $**
    81     83   
................................................................................
   720    722   	+translate$E $** > $@
   721    723   
   722    724   $(OBJDIR)\wikiformat$O : wikiformat_.c wikiformat.h
   723    725   	$(TCC) -o$@ -c wikiformat_.c
   724    726   
   725    727   wikiformat_.c : $(SRCDIR)\wikiformat.c
   726    728   	+translate$E $** > $@
          729  +
          730  +$(OBJDIR)\winfile$O : winfile_.c winfile.h
          731  +	$(TCC) -o$@ -c winfile_.c
          732  +
          733  +winfile_.c : $(SRCDIR)\winfile.c
          734  +	+translate$E $** > $@
   727    735   
   728    736   $(OBJDIR)\winhttp$O : winhttp_.c winhttp.h
   729    737   	$(TCC) -o$@ -c winhttp_.c
   730    738   
   731    739   winhttp_.c : $(SRCDIR)\winhttp.c
   732    740   	+translate$E $** > $@
   733    741   
................................................................................
   752    760   $(OBJDIR)\zip$O : zip_.c zip.h
   753    761   	$(TCC) -o$@ -c zip_.c
   754    762   
   755    763   zip_.c : $(SRCDIR)\zip.c
   756    764   	+translate$E $** > $@
   757    765   
   758    766   headers: makeheaders$E page_index.h VERSION.h
   759         -	 +makeheaders$E add_.c:add.h allrepo_.c:allrepo.h attach_.c:attach.h bag_.c:bag.h bisect_.c:bisect.h blob_.c:blob.h branch_.c:branch.h browse_.c:browse.h captcha_.c:captcha.h cgi_.c:cgi.h checkin_.c:checkin.h checkout_.c:checkout.h clearsign_.c:clearsign.h clone_.c:clone.h comformat_.c:comformat.h configure_.c:configure.h content_.c:content.h db_.c:db.h delta_.c:delta.h deltacmd_.c:deltacmd.h descendants_.c:descendants.h diff_.c:diff.h diffcmd_.c:diffcmd.h doc_.c:doc.h encode_.c:encode.h event_.c:event.h export_.c:export.h file_.c:file.h finfo_.c:finfo.h glob_.c:glob.h graph_.c:graph.h gzip_.c:gzip.h http_.c:http.h http_socket_.c:http_socket.h http_ssl_.c:http_ssl.h http_transport_.c:http_transport.h import_.c:import.h info_.c:info.h json_.c:json.h json_artifact_.c:json_artifact.h json_branch_.c:json_branch.h json_config_.c:json_config.h json_diff_.c:json_diff.h json_dir_.c:json_dir.h json_finfo_.c:json_finfo.h json_login_.c:json_login.h json_query_.c:json_query.h json_report_.c:json_report.h json_status_.c:json_status.h json_tag_.c:json_tag.h json_timeline_.c:json_timeline.h json_user_.c:json_user.h json_wiki_.c:json_wiki.h leaf_.c:leaf.h login_.c:login.h lookslike_.c:lookslike.h main_.c:main.h manifest_.c:manifest.h markdown_.c:markdown.h markdown_html_.c:markdown_html.h md5_.c:md5.h merge_.c:merge.h merge3_.c:merge3.h moderate_.c:moderate.h name_.c:name.h path_.c:path.h pivot_.c:pivot.h popen_.c:popen.h pqueue_.c:pqueue.h printf_.c:printf.h rebuild_.c:rebuild.h regexp_.c:regexp.h report_.c:report.h rss_.c:rss.h schema_.c:schema.h search_.c:search.h setup_.c:setup.h sha1_.c:sha1.h shun_.c:shun.h skins_.c:skins.h sqlcmd_.c:sqlcmd.h stash_.c:stash.h stat_.c:stat.h style_.c:style.h sync_.c:sync.h tag_.c:tag.h tar_.c:tar.h th_main_.c:th_main.h timeline_.c:timeline.h tkt_.c:tkt.h tktsetup_.c:tktsetup.h undo_.c:undo.h unicode_.c:unicode.h update_.c:update.h url_.c:url.h user_.c:user.h utf8_.c:utf8.h util_.c:util.h verify_.c:verify.h vfile_.c:vfile.h wiki_.c:wiki.h wikiformat_.c:wikiformat.h winhttp_.c:winhttp.h wysiwyg_.c:wysiwyg.h xfer_.c:xfer.h xfersetup_.c:xfersetup.h zip_.c:zip.h $(SRCDIR)\sqlite3.h $(SRCDIR)\th.h VERSION.h $(SRCDIR)\cson_amalgamation.h
          767  +	 +makeheaders$E add_.c:add.h allrepo_.c:allrepo.h attach_.c:attach.h bag_.c:bag.h bisect_.c:bisect.h blob_.c:blob.h branch_.c:branch.h browse_.c:browse.h captcha_.c:captcha.h cgi_.c:cgi.h checkin_.c:checkin.h checkout_.c:checkout.h clearsign_.c:clearsign.h clone_.c:clone.h comformat_.c:comformat.h configure_.c:configure.h content_.c:content.h db_.c:db.h delta_.c:delta.h deltacmd_.c:deltacmd.h descendants_.c:descendants.h diff_.c:diff.h diffcmd_.c:diffcmd.h doc_.c:doc.h encode_.c:encode.h event_.c:event.h export_.c:export.h file_.c:file.h finfo_.c:finfo.h glob_.c:glob.h graph_.c:graph.h gzip_.c:gzip.h http_.c:http.h http_socket_.c:http_socket.h http_ssl_.c:http_ssl.h http_transport_.c:http_transport.h import_.c:import.h info_.c:info.h json_.c:json.h json_artifact_.c:json_artifact.h json_branch_.c:json_branch.h json_config_.c:json_config.h json_diff_.c:json_diff.h json_dir_.c:json_dir.h json_finfo_.c:json_finfo.h json_login_.c:json_login.h json_query_.c:json_query.h json_report_.c:json_report.h json_status_.c:json_status.h json_tag_.c:json_tag.h json_timeline_.c:json_timeline.h json_user_.c:json_user.h json_wiki_.c:json_wiki.h leaf_.c:leaf.h login_.c:login.h lookslike_.c:lookslike.h main_.c:main.h manifest_.c:manifest.h markdown_.c:markdown.h markdown_html_.c:markdown_html.h md5_.c:md5.h merge_.c:merge.h merge3_.c:merge3.h moderate_.c:moderate.h name_.c:name.h path_.c:path.h pivot_.c:pivot.h popen_.c:popen.h pqueue_.c:pqueue.h printf_.c:printf.h rebuild_.c:rebuild.h regexp_.c:regexp.h report_.c:report.h rss_.c:rss.h schema_.c:schema.h search_.c:search.h setup_.c:setup.h sha1_.c:sha1.h shun_.c:shun.h skins_.c:skins.h sqlcmd_.c:sqlcmd.h stash_.c:stash.h stat_.c:stat.h style_.c:style.h sync_.c:sync.h tag_.c:tag.h tar_.c:tar.h th_main_.c:th_main.h timeline_.c:timeline.h tkt_.c:tkt.h tktsetup_.c:tktsetup.h undo_.c:undo.h unicode_.c:unicode.h update_.c:update.h url_.c:url.h user_.c:user.h utf8_.c:utf8.h util_.c:util.h verify_.c:verify.h vfile_.c:vfile.h wiki_.c:wiki.h wikiformat_.c:wikiformat.h winfile_.c:winfile.h winhttp_.c:winhttp.h wysiwyg_.c:wysiwyg.h xfer_.c:xfer.h xfersetup_.c:xfersetup.h zip_.c:zip.h $(SRCDIR)\sqlite3.h $(SRCDIR)\th.h VERSION.h $(SRCDIR)\cson_amalgamation.h
   760    768   	@copy /Y nul: headers

Changes to win/Makefile.mingw.

   355    355     $(SRCDIR)/user.c \
   356    356     $(SRCDIR)/utf8.c \
   357    357     $(SRCDIR)/util.c \
   358    358     $(SRCDIR)/verify.c \
   359    359     $(SRCDIR)/vfile.c \
   360    360     $(SRCDIR)/wiki.c \
   361    361     $(SRCDIR)/wikiformat.c \
          362  +  $(SRCDIR)/winfile.c \
   362    363     $(SRCDIR)/winhttp.c \
   363    364     $(SRCDIR)/wysiwyg.c \
   364    365     $(SRCDIR)/xfer.c \
   365    366     $(SRCDIR)/xfersetup.c \
   366    367     $(SRCDIR)/zip.c
   367    368   
   368    369   TRANS_SRC = \
................................................................................
   464    465     $(OBJDIR)/user_.c \
   465    466     $(OBJDIR)/utf8_.c \
   466    467     $(OBJDIR)/util_.c \
   467    468     $(OBJDIR)/verify_.c \
   468    469     $(OBJDIR)/vfile_.c \
   469    470     $(OBJDIR)/wiki_.c \
   470    471     $(OBJDIR)/wikiformat_.c \
          472  +  $(OBJDIR)/winfile_.c \
   471    473     $(OBJDIR)/winhttp_.c \
   472    474     $(OBJDIR)/wysiwyg_.c \
   473    475     $(OBJDIR)/xfer_.c \
   474    476     $(OBJDIR)/xfersetup_.c \
   475    477     $(OBJDIR)/zip_.c
   476    478   
   477    479   OBJ = \
................................................................................
   573    575    $(OBJDIR)/user.o \
   574    576    $(OBJDIR)/utf8.o \
   575    577    $(OBJDIR)/util.o \
   576    578    $(OBJDIR)/verify.o \
   577    579    $(OBJDIR)/vfile.o \
   578    580    $(OBJDIR)/wiki.o \
   579    581    $(OBJDIR)/wikiformat.o \
          582  + $(OBJDIR)/winfile.o \
   580    583    $(OBJDIR)/winhttp.o \
   581    584    $(OBJDIR)/wysiwyg.o \
   582    585    $(OBJDIR)/xfer.o \
   583    586    $(OBJDIR)/xfersetup.o \
   584    587    $(OBJDIR)/zip.o
   585    588   
   586    589   APPNAME = fossil.exe
................................................................................
   616    619   
   617    620   all:	$(OBJDIR) $(APPNAME)
   618    621   
   619    622   $(OBJDIR)/fossil.o:	$(SRCDIR)/../win/fossil.rc $(OBJDIR)/VERSION.h
   620    623   ifdef USE_WINDOWS
   621    624   	$(CP) $(subst /,\,$(SRCDIR)\..\win\fossil.rc) $(subst /,\,$(OBJDIR))
   622    625   	$(CP) $(subst /,\,$(SRCDIR)\..\win\fossil.ico) $(subst /,\,$(OBJDIR))
          626  +	$(CP) $(subst /,\,$(SRCDIR)\..\win\fossil.exe.manifest) $(subst /,\,$(OBJDIR))
   623    627   else
   624    628   	$(CP) $(SRCDIR)/../win/fossil.rc $(OBJDIR)
   625    629   	$(CP) $(SRCDIR)/../win/fossil.ico $(OBJDIR)
          630  +	$(CP) $(SRCDIR)/../win/fossil.exe.manifest $(OBJDIR)
   626    631   endif
   627    632   	$(RCC) $(OBJDIR)/fossil.rc -o $(OBJDIR)/fossil.o
   628    633   
   629    634   install:	$(OBJDIR) $(APPNAME)
   630    635   ifdef USE_WINDOWS
   631    636   	$(MKDIR) $(subst /,\,$(INSTALLDIR))
   632    637   	$(MV) $(subst /,\,$(APPNAME)) $(subst /,\,$(INSTALLDIR))
................................................................................
   812    817   		$(OBJDIR)/user_.c:$(OBJDIR)/user.h \
   813    818   		$(OBJDIR)/utf8_.c:$(OBJDIR)/utf8.h \
   814    819   		$(OBJDIR)/util_.c:$(OBJDIR)/util.h \
   815    820   		$(OBJDIR)/verify_.c:$(OBJDIR)/verify.h \
   816    821   		$(OBJDIR)/vfile_.c:$(OBJDIR)/vfile.h \
   817    822   		$(OBJDIR)/wiki_.c:$(OBJDIR)/wiki.h \
   818    823   		$(OBJDIR)/wikiformat_.c:$(OBJDIR)/wikiformat.h \
          824  +		$(OBJDIR)/winfile_.c:$(OBJDIR)/winfile.h \
   819    825   		$(OBJDIR)/winhttp_.c:$(OBJDIR)/winhttp.h \
   820    826   		$(OBJDIR)/wysiwyg_.c:$(OBJDIR)/wysiwyg.h \
   821    827   		$(OBJDIR)/xfer_.c:$(OBJDIR)/xfer.h \
   822    828   		$(OBJDIR)/xfersetup_.c:$(OBJDIR)/xfersetup.h \
   823    829   		$(OBJDIR)/zip_.c:$(OBJDIR)/zip.h \
   824    830   		$(SRCDIR)/sqlite3.h \
   825    831   		$(SRCDIR)/th.h \
................................................................................
  1641   1647   $(OBJDIR)/wikiformat_.c:	$(SRCDIR)/wikiformat.c $(OBJDIR)/translate
  1642   1648   	$(TRANSLATE) $(SRCDIR)/wikiformat.c >$(OBJDIR)/wikiformat_.c
  1643   1649   
  1644   1650   $(OBJDIR)/wikiformat.o:	$(OBJDIR)/wikiformat_.c $(OBJDIR)/wikiformat.h  $(SRCDIR)/config.h
  1645   1651   	$(XTCC) -o $(OBJDIR)/wikiformat.o -c $(OBJDIR)/wikiformat_.c
  1646   1652   
  1647   1653   $(OBJDIR)/wikiformat.h:	$(OBJDIR)/headers
         1654  +
         1655  +$(OBJDIR)/winfile_.c:	$(SRCDIR)/winfile.c $(OBJDIR)/translate
         1656  +	$(TRANSLATE) $(SRCDIR)/winfile.c >$(OBJDIR)/winfile_.c
         1657  +
         1658  +$(OBJDIR)/winfile.o:	$(OBJDIR)/winfile_.c $(OBJDIR)/winfile.h  $(SRCDIR)/config.h
         1659  +	$(XTCC) -o $(OBJDIR)/winfile.o -c $(OBJDIR)/winfile_.c
         1660  +
         1661  +$(OBJDIR)/winfile.h:	$(OBJDIR)/headers
  1648   1662   
  1649   1663   $(OBJDIR)/winhttp_.c:	$(SRCDIR)/winhttp.c $(OBJDIR)/translate
  1650   1664   	$(TRANSLATE) $(SRCDIR)/winhttp.c >$(OBJDIR)/winhttp_.c
  1651   1665   
  1652   1666   $(OBJDIR)/winhttp.o:	$(OBJDIR)/winhttp_.c $(OBJDIR)/winhttp.h  $(SRCDIR)/config.h
  1653   1667   	$(XTCC) -o $(OBJDIR)/winhttp.o -c $(OBJDIR)/winhttp_.c
  1654   1668   
................................................................................
  1681   1695   $(OBJDIR)/zip_.c:	$(SRCDIR)/zip.c $(OBJDIR)/translate
  1682   1696   	$(TRANSLATE) $(SRCDIR)/zip.c >$(OBJDIR)/zip_.c
  1683   1697   
  1684   1698   $(OBJDIR)/zip.o:	$(OBJDIR)/zip_.c $(OBJDIR)/zip.h  $(SRCDIR)/config.h
  1685   1699   	$(XTCC) -o $(OBJDIR)/zip.o -c $(OBJDIR)/zip_.c
  1686   1700   
  1687   1701   $(OBJDIR)/zip.h:	$(OBJDIR)/headers
         1702  +
         1703  +SQLITE_OPTIONS = -DSQLITE_OMIT_LOAD_EXTENSION=1 \
         1704  +                 -DSQLITE_THREADSAFE=0 \
         1705  +                 -DSQLITE_DEFAULT_FILE_FORMAT=4 \
         1706  +                 -DSQLITE_OMIT_DEPRECATED \
         1707  +                 -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
         1708  +                 -Dlocaltime=fossil_localtime \
         1709  +                 -DSQLITE_ENABLE_LOCKING_STYLE=0 \
         1710  +                 -D_HAVE_SQLITE_CONFIG_H \
         1711  +                 -DSQLITE_USE_MALLOC_H \
         1712  +                 -DSQLITE_USE_MSIZE
         1713  +
         1714  +SHELL_OPTIONS = -Dmain=sqlite3_shell \
         1715  +                -DSQLITE_OMIT_LOAD_EXTENSION=1 \
         1716  +                -Dsqlite3_strglob=strglob \
         1717  +                -Dgetenv=fossil_getenv \
         1718  +                -Dfopen=fossil_fopen
  1688   1719   
  1689   1720   $(OBJDIR)/sqlite3.o:	$(SRCDIR)/sqlite3.c
  1690         -	$(XTCC) -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_STAT3 -Dlocaltime=fossil_localtime -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_WIN32_NO_ANSI -D_HAVE_SQLITE_CONFIG_H -c $(SRCDIR)/sqlite3.c -o $(OBJDIR)/sqlite3.o
         1721  +	$(XTCC) $(SQLITE_OPTIONS) $(SQLITE_CFLAGS) -c $(SRCDIR)/sqlite3.c -o $(OBJDIR)/sqlite3.o
  1691   1722   
  1692   1723   $(OBJDIR)/cson_amalgamation.o:	$(SRCDIR)/cson_amalgamation.c
  1693         -	$(XTCC)  -c $(SRCDIR)/cson_amalgamation.c -o $(OBJDIR)/cson_amalgamation.o
         1724  +	$(XTCC) -c $(SRCDIR)/cson_amalgamation.c -o $(OBJDIR)/cson_amalgamation.o
  1694   1725   
  1695   1726   $(OBJDIR)/json.o $(OBJDIR)/json_artifact.o $(OBJDIR)/json_branch.o $(OBJDIR)/json_config.o $(OBJDIR)/json_diff.o $(OBJDIR)/json_dir.o $(OBJDIR)/jsos_finfo.o $(OBJDIR)/json_login.o $(OBJDIR)/json_query.o $(OBJDIR)/json_report.o $(OBJDIR)/json_status.o $(OBJDIR)/json_tag.o $(OBJDIR)/json_timeline.o $(OBJDIR)/json_user.o $(OBJDIR)/json_wiki.o : $(SRCDIR)/json_detail.h
  1696   1727   
  1697   1728   $(OBJDIR)/shell.o:	$(SRCDIR)/shell.c $(SRCDIR)/sqlite3.h
  1698         -	$(XTCC) -Dmain=sqlite3_shell -DSQLITE_OMIT_LOAD_EXTENSION=1 -c $(SRCDIR)/shell.c -o $(OBJDIR)/shell.o
         1729  +	$(XTCC) $(SHELL_OPTIONS) $(SHELL_CFLAGS) -c $(SRCDIR)/shell.c -o $(OBJDIR)/shell.o
  1699   1730   
  1700   1731   $(OBJDIR)/th.o:	$(SRCDIR)/th.c
  1701   1732   	$(XTCC) -c $(SRCDIR)/th.c -o $(OBJDIR)/th.o
  1702   1733   
  1703   1734   $(OBJDIR)/th_lang.o:	$(SRCDIR)/th_lang.c
  1704   1735   	$(XTCC) -c $(SRCDIR)/th_lang.c -o $(OBJDIR)/th_lang.o
  1705   1736   
  1706   1737   ifdef FOSSIL_ENABLE_TCL
  1707   1738   $(OBJDIR)/th_tcl.o:	$(SRCDIR)/th_tcl.c
  1708   1739   	$(XTCC) -c $(SRCDIR)/th_tcl.c -o $(OBJDIR)/th_tcl.o
  1709   1740   endif

Changes to win/Makefile.mingw.mistachkin.

   355    355     $(SRCDIR)/user.c \
   356    356     $(SRCDIR)/utf8.c \
   357    357     $(SRCDIR)/util.c \
   358    358     $(SRCDIR)/verify.c \
   359    359     $(SRCDIR)/vfile.c \
   360    360     $(SRCDIR)/wiki.c \
   361    361     $(SRCDIR)/wikiformat.c \
          362  +  $(SRCDIR)/winfile.c \
   362    363     $(SRCDIR)/winhttp.c \
   363    364     $(SRCDIR)/wysiwyg.c \
   364    365     $(SRCDIR)/xfer.c \
   365    366     $(SRCDIR)/xfersetup.c \
   366    367     $(SRCDIR)/zip.c
   367    368   
   368    369   TRANS_SRC = \
................................................................................
   464    465     $(OBJDIR)/user_.c \
   465    466     $(OBJDIR)/utf8_.c \
   466    467     $(OBJDIR)/util_.c \
   467    468     $(OBJDIR)/verify_.c \
   468    469     $(OBJDIR)/vfile_.c \
   469    470     $(OBJDIR)/wiki_.c \
   470    471     $(OBJDIR)/wikiformat_.c \
          472  +  $(OBJDIR)/winfile_.c \
   471    473     $(OBJDIR)/winhttp_.c \
   472    474     $(OBJDIR)/wysiwyg_.c \
   473    475     $(OBJDIR)/xfer_.c \
   474    476     $(OBJDIR)/xfersetup_.c \
   475    477     $(OBJDIR)/zip_.c
   476    478   
   477    479   OBJ = \
................................................................................
   573    575    $(OBJDIR)/user.o \
   574    576    $(OBJDIR)/utf8.o \
   575    577    $(OBJDIR)/util.o \
   576    578    $(OBJDIR)/verify.o \
   577    579    $(OBJDIR)/vfile.o \
   578    580    $(OBJDIR)/wiki.o \
   579    581    $(OBJDIR)/wikiformat.o \
          582  + $(OBJDIR)/winfile.o \
   580    583    $(OBJDIR)/winhttp.o \
   581    584    $(OBJDIR)/wysiwyg.o \
   582    585    $(OBJDIR)/xfer.o \
   583    586    $(OBJDIR)/xfersetup.o \
   584    587    $(OBJDIR)/zip.o
   585    588   
   586    589   APPNAME = fossil.exe
................................................................................
   616    619   
   617    620   all:	$(OBJDIR) $(APPNAME)
   618    621   
   619    622   $(OBJDIR)/fossil.o:	$(SRCDIR)/../win/fossil.rc $(OBJDIR)/VERSION.h
   620    623   ifdef USE_WINDOWS
   621    624   	$(CP) $(subst /,\,$(SRCDIR)\..\win\fossil.rc) $(subst /,\,$(OBJDIR))
   622    625   	$(CP) $(subst /,\,$(SRCDIR)\..\win\fossil.ico) $(subst /,\,$(OBJDIR))
          626  +	$(CP) $(subst /,\,$(SRCDIR)\..\win\fossil.exe.manifest) $(subst /,\,$(OBJDIR))
   623    627   else
   624    628   	$(CP) $(SRCDIR)/../win/fossil.rc $(OBJDIR)
   625    629   	$(CP) $(SRCDIR)/../win/fossil.ico $(OBJDIR)
          630  +	$(CP) $(SRCDIR)/../win/fossil.exe.manifest $(OBJDIR)
   626    631   endif
   627    632   	$(RCC) $(OBJDIR)/fossil.rc -o $(OBJDIR)/fossil.o
   628    633   
   629    634   install:	$(OBJDIR) $(APPNAME)
   630    635   ifdef USE_WINDOWS
   631    636   	$(MKDIR) $(subst /,\,$(INSTALLDIR))
   632    637   	$(MV) $(subst /,\,$(APPNAME)) $(subst /,\,$(INSTALLDIR))
................................................................................
   812    817   		$(OBJDIR)/user_.c:$(OBJDIR)/user.h \
   813    818   		$(OBJDIR)/utf8_.c:$(OBJDIR)/utf8.h \
   814    819   		$(OBJDIR)/util_.c:$(OBJDIR)/util.h \
   815    820   		$(OBJDIR)/verify_.c:$(OBJDIR)/verify.h \
   816    821   		$(OBJDIR)/vfile_.c:$(OBJDIR)/vfile.h \
   817    822   		$(OBJDIR)/wiki_.c:$(OBJDIR)/wiki.h \
   818    823   		$(OBJDIR)/wikiformat_.c:$(OBJDIR)/wikiformat.h \
          824  +		$(OBJDIR)/winfile_.c:$(OBJDIR)/winfile.h \
   819    825   		$(OBJDIR)/winhttp_.c:$(OBJDIR)/winhttp.h \
   820    826   		$(OBJDIR)/wysiwyg_.c:$(OBJDIR)/wysiwyg.h \
   821    827   		$(OBJDIR)/xfer_.c:$(OBJDIR)/xfer.h \
   822    828   		$(OBJDIR)/xfersetup_.c:$(OBJDIR)/xfersetup.h \
   823    829   		$(OBJDIR)/zip_.c:$(OBJDIR)/zip.h \
   824    830   		$(SRCDIR)/sqlite3.h \
   825    831   		$(SRCDIR)/th.h \
................................................................................
  1641   1647   $(OBJDIR)/wikiformat_.c:	$(SRCDIR)/wikiformat.c $(OBJDIR)/translate
  1642   1648   	$(TRANSLATE) $(SRCDIR)/wikiformat.c >$(OBJDIR)/wikiformat_.c
  1643   1649   
  1644   1650   $(OBJDIR)/wikiformat.o:	$(OBJDIR)/wikiformat_.c $(OBJDIR)/wikiformat.h  $(SRCDIR)/config.h
  1645   1651   	$(XTCC) -o $(OBJDIR)/wikiformat.o -c $(OBJDIR)/wikiformat_.c
  1646   1652   
  1647   1653   $(OBJDIR)/wikiformat.h:	$(OBJDIR)/headers
         1654  +
         1655  +$(OBJDIR)/winfile_.c:	$(SRCDIR)/winfile.c $(OBJDIR)/translate
         1656  +	$(TRANSLATE) $(SRCDIR)/winfile.c >$(OBJDIR)/winfile_.c
         1657  +
         1658  +$(OBJDIR)/winfile.o:	$(OBJDIR)/winfile_.c $(OBJDIR)/winfile.h  $(SRCDIR)/config.h
         1659  +	$(XTCC) -o $(OBJDIR)/winfile.o -c $(OBJDIR)/winfile_.c
         1660  +
         1661  +$(OBJDIR)/winfile.h:	$(OBJDIR)/headers
  1648   1662   
  1649   1663   $(OBJDIR)/winhttp_.c:	$(SRCDIR)/winhttp.c $(OBJDIR)/translate
  1650   1664   	$(TRANSLATE) $(SRCDIR)/winhttp.c >$(OBJDIR)/winhttp_.c
  1651   1665   
  1652   1666   $(OBJDIR)/winhttp.o:	$(OBJDIR)/winhttp_.c $(OBJDIR)/winhttp.h  $(SRCDIR)/config.h
  1653   1667   	$(XTCC) -o $(OBJDIR)/winhttp.o -c $(OBJDIR)/winhttp_.c
  1654   1668   
................................................................................
  1681   1695   $(OBJDIR)/zip_.c:	$(SRCDIR)/zip.c $(OBJDIR)/translate
  1682   1696   	$(TRANSLATE) $(SRCDIR)/zip.c >$(OBJDIR)/zip_.c
  1683   1697   
  1684   1698   $(OBJDIR)/zip.o:	$(OBJDIR)/zip_.c $(OBJDIR)/zip.h  $(SRCDIR)/config.h
  1685   1699   	$(XTCC) -o $(OBJDIR)/zip.o -c $(OBJDIR)/zip_.c
  1686   1700   
  1687   1701   $(OBJDIR)/zip.h:	$(OBJDIR)/headers
         1702  +
         1703  +SQLITE_OPTIONS = -DSQLITE_OMIT_LOAD_EXTENSION=1 \
         1704  +                 -DSQLITE_THREADSAFE=0 \
         1705  +                 -DSQLITE_DEFAULT_FILE_FORMAT=4 \
         1706  +                 -DSQLITE_OMIT_DEPRECATED \
         1707  +                 -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
         1708  +                 -Dlocaltime=fossil_localtime \
         1709  +                 -DSQLITE_ENABLE_LOCKING_STYLE=0 \
         1710  +                 -D_HAVE_SQLITE_CONFIG_H \
         1711  +                 -DSQLITE_USE_MALLOC_H \
         1712  +                 -DSQLITE_USE_MSIZE
         1713  +
         1714  +SHELL_OPTIONS = -Dmain=sqlite3_shell \
         1715  +                -DSQLITE_OMIT_LOAD_EXTENSION=1 \
         1716  +                -Dsqlite3_strglob=strglob \
         1717  +                -Dgetenv=fossil_getenv \
         1718  +                -Dfopen=fossil_fopen
  1688   1719   
  1689   1720   $(OBJDIR)/sqlite3.o:	$(SRCDIR)/sqlite3.c
  1690         -	$(XTCC) -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_STAT3 -Dlocaltime=fossil_localtime -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_WIN32_NO_ANSI -D_HAVE_SQLITE_CONFIG_H -c $(SRCDIR)/sqlite3.c -o $(OBJDIR)/sqlite3.o
         1721  +	$(XTCC) $(SQLITE_OPTIONS) $(SQLITE_CFLAGS) -c $(SRCDIR)/sqlite3.c -o $(OBJDIR)/sqlite3.o
  1691   1722   
  1692   1723   $(OBJDIR)/cson_amalgamation.o:	$(SRCDIR)/cson_amalgamation.c
  1693         -	$(XTCC)  -c $(SRCDIR)/cson_amalgamation.c -o $(OBJDIR)/cson_amalgamation.o
         1724  +	$(XTCC) -c $(SRCDIR)/cson_amalgamation.c -o $(OBJDIR)/cson_amalgamation.o
  1694   1725   
  1695   1726   $(OBJDIR)/json.o $(OBJDIR)/json_artifact.o $(OBJDIR)/json_branch.o $(OBJDIR)/json_config.o $(OBJDIR)/json_diff.o $(OBJDIR)/json_dir.o $(OBJDIR)/jsos_finfo.o $(OBJDIR)/json_login.o $(OBJDIR)/json_query.o $(OBJDIR)/json_report.o $(OBJDIR)/json_status.o $(OBJDIR)/json_tag.o $(OBJDIR)/json_timeline.o $(OBJDIR)/json_user.o $(OBJDIR)/json_wiki.o : $(SRCDIR)/json_detail.h
  1696   1727   
  1697   1728   $(OBJDIR)/shell.o:	$(SRCDIR)/shell.c $(SRCDIR)/sqlite3.h
  1698         -	$(XTCC) -Dmain=sqlite3_shell -DSQLITE_OMIT_LOAD_EXTENSION=1 -c $(SRCDIR)/shell.c -o $(OBJDIR)/shell.o
         1729  +	$(XTCC) $(SHELL_OPTIONS) $(SHELL_CFLAGS) -c $(SRCDIR)/shell.c -o $(OBJDIR)/shell.o
  1699   1730   
  1700   1731   $(OBJDIR)/th.o:	$(SRCDIR)/th.c
  1701   1732   	$(XTCC) -c $(SRCDIR)/th.c -o $(OBJDIR)/th.o
  1702   1733   
  1703   1734   $(OBJDIR)/th_lang.o:	$(SRCDIR)/th_lang.c
  1704   1735   	$(XTCC) -c $(SRCDIR)/th_lang.c -o $(OBJDIR)/th_lang.o
  1705   1736   
  1706   1737   ifdef FOSSIL_ENABLE_TCL
  1707   1738   $(OBJDIR)/th_tcl.o:	$(SRCDIR)/th_tcl.c
  1708   1739   	$(XTCC) -c $(SRCDIR)/th_tcl.c -o $(OBJDIR)/th_tcl.o
  1709   1740   endif

Changes to win/Makefile.msc.

    37     37   INCL      = -I. -I$(SRCDIR) -I$B\win\include -I$(ZINCDIR)
    38     38   
    39     39   !ifdef FOSSIL_ENABLE_SSL
    40     40   INCL      = $(INCL) -I$(SSLINCDIR)
    41     41   !endif
    42     42   
    43     43   CFLAGS    = -nologo -MT -O2
    44         -LDFLAGS   = /NODEFAULTLIB:msvcrt
           44  +LDFLAGS   = /NODEFAULTLIB:msvcrt /MANIFEST:NO
    45     45   
    46     46   !ifdef DEBUG
    47     47   CFLAGS    = $(CFLAGS) -Zi
    48     48   LDFLAGS   = $(LDFLAGS) /DEBUG
    49     49   !endif
    50     50   
    51     51   BCC       = $(CC) $(CFLAGS)
................................................................................
    65     65   LIBS      = $(LIBS) $(SSLLIB)
    66     66   LIBDIR    = $(LIBDIR) -LIBPATH:$(SSLLIBDIR)
    67     67   !endif
    68     68   
    69     69   SQLITE_OPTIONS = /DSQLITE_OMIT_LOAD_EXTENSION=1 \
    70     70                    /DSQLITE_THREADSAFE=0 \
    71     71                    /DSQLITE_DEFAULT_FILE_FORMAT=4 \
    72         -                 /DSQLITE_ENABLE_STAT3 \
           72  +                 /DSQLITE_OMIT_DEPRECATED \
           73  +                 /DSQLITE_ENABLE_EXPLAIN_COMMENTS \
    73     74                    /Dlocaltime=fossil_localtime \
    74         -                 /DSQLITE_ENABLE_LOCKING_STYLE=0 \
    75         -                 /DSQLITE_WIN32_NO_ANSI
           75  +                 /DSQLITE_ENABLE_LOCKING_STYLE=0
           76  +
           77  +SHELL_OPTIONS = /Dmain=sqlite3_shell \
           78  +                /DSQLITE_OMIT_LOAD_EXTENSION=1 \
           79  +                /Dsqlite3_strglob=strglob \
           80  +                /Dgetenv=fossil_getenv \
           81  +                /Dfopen=fossil_fopen
    76     82   
    77     83   SRC   = add_.c \
    78     84           allrepo_.c \
    79     85           attach_.c \
    80     86           bag_.c \
    81     87           bisect_.c \
    82     88           blob_.c \
................................................................................
   172    178           user_.c \
   173    179           utf8_.c \
   174    180           util_.c \
   175    181           verify_.c \
   176    182           vfile_.c \
   177    183           wiki_.c \
   178    184           wikiformat_.c \
          185  +        winfile_.c \
   179    186           winhttp_.c \
   180    187           wysiwyg_.c \
   181    188           xfer_.c \
   182    189           xfersetup_.c \
   183    190           zip_.c
   184    191   
   185    192   OBJ   = $(OX)\add$O \
................................................................................
   285    292           $(OX)\user$O \
   286    293           $(OX)\utf8$O \
   287    294           $(OX)\util$O \
   288    295           $(OX)\verify$O \
   289    296           $(OX)\vfile$O \
   290    297           $(OX)\wiki$O \
   291    298           $(OX)\wikiformat$O \
          299  +        $(OX)\winfile$O \
   292    300           $(OX)\winhttp$O \
   293    301           $(OX)\wysiwyg$O \
   294    302           $(OX)\xfer$O \
   295    303           $(OX)\xfersetup$O \
   296    304           $(OX)\zip$O \
   297    305           $(OX)\fossil.res
   298    306   
................................................................................
   412    420   	echo $(OX)\user.obj >> $@
   413    421   	echo $(OX)\utf8.obj >> $@
   414    422   	echo $(OX)\util.obj >> $@
   415    423   	echo $(OX)\verify.obj >> $@
   416    424   	echo $(OX)\vfile.obj >> $@
   417    425   	echo $(OX)\wiki.obj >> $@
   418    426   	echo $(OX)\wikiformat.obj >> $@
          427  +	echo $(OX)\winfile.obj >> $@
   419    428   	echo $(OX)\winhttp.obj >> $@
   420    429   	echo $(OX)\wysiwyg.obj >> $@
   421    430   	echo $(OX)\xfer.obj >> $@
   422    431   	echo $(OX)\xfersetup.obj >> $@
   423    432   	echo $(OX)\zip.obj >> $@
   424    433   	echo $(LIBS) >> $@
   425    434   
................................................................................
   438    447   mkindex$E: $(SRCDIR)\mkindex.c
   439    448   	$(BCC) $**
   440    449   
   441    450   mkversion$E: $B\src\mkversion.c
   442    451   	$(BCC) $**
   443    452   
   444    453   $(OX)\shell$O : $(SRCDIR)\shell.c
   445         -	$(TCC) /Fo$@ /Dmain=sqlite3_shell $(SQLITE_OPTIONS) -c $(SRCDIR)\shell.c
          454  +	$(TCC) /Fo$@ $(SHELL_OPTIONS) $(SQLITE_OPTIONS) $(SHELL_CFLAGS) -c $(SRCDIR)\shell.c
   446    455   
   447    456   $(OX)\sqlite3$O : $(SRCDIR)\sqlite3.c
   448         -	$(TCC) /Fo$@ -c $(SQLITE_OPTIONS) $**
          457  +	$(TCC) /Fo$@ -c $(SQLITE_OPTIONS) $(SQLITE_CFLAGS) $**
   449    458   
   450    459   $(OX)\th$O : $(SRCDIR)\th.c
   451    460   	$(TCC) /Fo$@ -c $**
   452    461   
   453    462   $(OX)\th_lang$O : $(SRCDIR)\th_lang.c
   454    463   	$(TCC) /Fo$@ -c $**
   455    464   
................................................................................
   463    472   
   464    473   clean:
   465    474   	-del $(OX)\*.obj
   466    475   	-del *.obj
   467    476   	-del *_.c
   468    477   	-del *.h
   469    478   	-del *.map
   470         -	-del *.manifest
   471    479   	-del headers
   472    480   	-del linkopts
   473    481   	-del *.res
   474    482   
   475    483   realclean: clean
   476    484   	-del $(APPNAME)
   477    485   	-del translate$E
................................................................................
  1103   1111   	translate$E $** > $@
  1104   1112   
  1105   1113   $(OX)\wikiformat$O : wikiformat_.c wikiformat.h
  1106   1114   	$(TCC) /Fo$@ -c wikiformat_.c
  1107   1115   
  1108   1116   wikiformat_.c : $(SRCDIR)\wikiformat.c
  1109   1117   	translate$E $** > $@
         1118  +
         1119  +$(OX)\winfile$O : winfile_.c winfile.h
         1120  +	$(TCC) /Fo$@ -c winfile_.c
         1121  +
         1122  +winfile_.c : $(SRCDIR)\winfile.c
         1123  +	translate$E $** > $@
  1110   1124   
  1111   1125   $(OX)\winhttp$O : winhttp_.c winhttp.h
  1112   1126   	$(TCC) /Fo$@ -c winhttp_.c
  1113   1127   
  1114   1128   winhttp_.c : $(SRCDIR)\winhttp.c
  1115   1129   	translate$E $** > $@
  1116   1130   
................................................................................
  1239   1253   			user_.c:user.h \
  1240   1254   			utf8_.c:utf8.h \
  1241   1255   			util_.c:util.h \
  1242   1256   			verify_.c:verify.h \
  1243   1257   			vfile_.c:vfile.h \
  1244   1258   			wiki_.c:wiki.h \
  1245   1259   			wikiformat_.c:wikiformat.h \
         1260  +			winfile_.c:winfile.h \
  1246   1261   			winhttp_.c:winhttp.h \
  1247   1262   			wysiwyg_.c:wysiwyg.h \
  1248   1263   			xfer_.c:xfer.h \
  1249   1264   			xfersetup_.c:xfersetup.h \
  1250   1265   			zip_.c:zip.h \
  1251   1266   			$(SRCDIR)\sqlite3.h \
  1252   1267   			$(SRCDIR)\th.h \
  1253   1268   			VERSION.h \
  1254   1269   			$(SRCDIR)\cson_amalgamation.h
  1255   1270   	@copy /Y nul: headers

Added win/fossil.exe.manifest.

            1  +<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
            2  +<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"
            3  +          xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
            4  +  <assemblyIdentity version="1.0.0.0" processorArchitecture="X86" name="fossil"
            5  +                    type="win32" />
            6  +  <description>
            7  +    Simple, high-reliability, distributed software configuration management system.
            8  +  </description>
            9  +  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
           10  +    <security>
           11  +      <requestedPrivileges>
           12  +        <requestedExecutionLevel level="asInvoker" uiAccess="false" />
           13  +      </requestedPrivileges>
           14  +    </security>
           15  +  </trustInfo>
           16  +  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
           17  +    <application>
           18  +      <!-- Windows 8.1 -->
           19  +      <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
           20  +      <!-- Windows 8 -->
           21  +      <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
           22  +      <!-- Windows 7 -->
           23  +      <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
           24  +      <!-- Windows Vista -->
           25  +      <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
           26  +    </application>
           27  +  </compatibility>
           28  +  <asmv3:application>
           29  +    <asmv3:windowsSettings
           30  +           xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
           31  +      <dpiAware>true</dpiAware>
           32  +    </asmv3:windowsSettings>
           33  +  </asmv3:application>
           34  +  <dependency>
           35  +    <dependentAssembly>
           36  +      <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls"
           37  +                        version="6.0.0.0" processorArchitecture="X86"
           38  +                        publicKeyToken="6595b64144ccf1df" language="*" />
           39  +    </dependentAssembly>
           40  +  </dependency>
           41  +</assembly>

Changes to win/fossil.rc.

   128    128       END
   129    129     END
   130    130     BLOCK "VarFileInfo"
   131    131     BEGIN
   132    132       VALUE "Translation", 0x409, 0x4b0
   133    133     END
   134    134   END
          135  +
          136  +/*
          137  + * This embedded manifest is needed for Windows 8.1.
          138  + */
          139  +
          140  +#ifndef RT_MANIFEST
          141  +#define RT_MANIFEST     24
          142  +#endif
          143  +
          144  +#ifndef CREATEPROCESS_MANIFEST_RESOURCE_ID
          145  +#define CREATEPROCESS_MANIFEST_RESOURCE_ID 1
          146  +#endif
          147  +
          148  +CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "fossil.exe.manifest"

Changes to win/msvc_build.bat.

     1      1   @echo off
     2      2   
     3         -rem getting 32-bit program files directory
     4         -SET pf_32bit=%programfiles(x86)%
     5         -IF "%pf_32bit%"=="" SET pf_32bit=%programfiles%
            3  +rem    this batch file tries to compile fossil using the latest available version
            4  +rem    of Microsoft Visual Studio that can be found on the machine.
     6      5   
     7         -rem getting vcvarsall.bat path for the latest version of visual studio that is available on the system
     8         -SET msvc2013=Microsoft Visual Studio 12.0
     9         -SET msvc2012=Microsoft Visual Studio 11.0
    10         -SET msvc2010=Microsoft Visual Studio 10.0
    11         -SET msvc2008=Microsoft Visual Studio 9.0
    12         -SET msvc2005=Microsoft Visual Studio 8
    13         -
    14         -rem Microsoft Visual Studio .NET 2003 does not have vcvarsall.bat
    15         -                         SET vcvarsall="%pf_32bit%\%msvc2013%\VC\vcvarsall.bat"
    16         -IF NOT EXIST %vcvarsall% SET vcvarsall="%pf_32bit%\%msvc2012%\VC\vcvarsall.bat"
    17         -IF NOT EXIST %vcvarsall% SET vcvarsall="%pf_32bit%\%msvc2010%\VC\vcvarsall.bat"
    18         -IF NOT EXIST %vcvarsall% SET vcvarsall="%pf_32bit%\%msvc2008%\VC\vcvarsall.bat"
    19         -IF NOT EXIST %vcvarsall% SET vcvarsall="%pf_32bit%\%msvc2005%\VC\vcvarsall.bat"
            6  +rem visual studio 2013
            7  +SET vsvars32="%VS120COMNTOOLS%\vsvars32.bat"
            8  +rem visual studio 2012
            9  +IF NOT EXIST %vsvars32% SET vsvars32="%VS110COMNTOOLS%\vsvars32.bat"
           10  +rem visual studio 2010
           11  +IF NOT EXIST %vsvars32% SET vsvars32="%VS100COMNTOOLS%\vsvars32.bat"
           12  +rem visual studio 2008
           13  +IF NOT EXIST %vsvars32% SET vsvars32="%VS90COMNTOOLS%\vsvars32.bat"
           14  +rem visual studio 2005
           15  +IF NOT EXIST %vsvars32% SET vsvars32="%VS80COMNTOOLS%\vsvars32.bat"
           16  +rem visual studio 2003 .NET
           17  +IF NOT EXIST %vsvars32% SET vsvars32="%VS71COMNTOOLS%\vsvars32.bat"
    20     18   
    21     19   rem check everything is correct
    22         -IF NOT EXIST %vcvarsall% goto:bad_environment
           20  +IF NOT EXIST %vsvars32% goto:bad_environment
           21  +
           22  +rem setting environment variables for building with Microsoft Visual C++
           23  +call %vsvars32%
    23     24   
    24     25   rem making build directory
    25     26   pushd "%~dp0"
    26     27   cd ..
    27     28   mkdir msvc_build
    28     29   cd msvc_build
    29     30   
    30         -rem setting environment variables for building with Microsoft Visual C++
    31         -call %vcvarsall%
    32         -
    33     31   rem building
    34     32   nmake /f "%~dp0\Makefile.msc"
           33  +
           34  +rem leaving
    35     35   popd
    36     36   pause
    37     37   goto:eof
    38     38   
    39     39   :bad_environment
    40         -echo "vcvarsall.bat could not be found on this system."
           40  +echo "vsvars32.bat could not be found on this system."
    41     41   pause
    42     42   goto:eof

Changes to www/changes.wiki.

    16     16        Admin/Configuration.
    17     17     *  Fix CGI processing so that it works on web servers that do not
    18     18        supply REQUEST_URI.
    19     19     *  Add options --dirsonly, --emptydirs, and --allckouts to the
    20     20        "[/help?cmd=clean | fossil clean]" command.
    21     21     *  Ten-fold performance improvement in large "fossil blame" or 
    22     22        "fossil annotate" commands.
    23         -  *  Add option -W|--width to the "[/help?cmd=timeline | fossil timeline]"
           23  +  *  Add option -W|--width and --offset to "[/help?cmd=timeline | fossil timeline]"
    24     24        and  "[/help?cmd=finfo | fossil finfo]" commands.
    25     25     *  Option -n|--limit of "[/help?cmd=timeline | fossil timeline]" now
    26     26        specifies the number of entries, just like all other commands which
    27     27        have the -n|--limit option. The various timeline-related functions
    28         -     now output "=== ?? limit (??) reached ===" at the end whenever
           28  +     now output "--- ?? limit (??) reached ---" at the end whenever
    29     29        appropriate. Use "-n 0" if no limit is desired.
           30  +  *  Fix handling of password embedded in Fossil URL.
           31  +  *  New --once option to [/help?cmd=clone | fossil clone] command which does
           32  +     not store the URL or password when cloning.
           33  +  *  Modify [/help?cmd=ui | fossil ui] to respect "default user" in open repository.
    30     34   
    31     35   <h2>Changes For Version 1.27 (2013-09-11)</h2>
    32     36     *  Enhance the [/help?cmd=changes | fossil changes],
    33     37        [/help?cmd=clean | fossil clean], [/help?cmd=extras | fossil extras],
    34     38        [/help?cmd=ls | fossil ls] and [/help?cmd=status | fossil status] commands
    35     39        to restrict operation to files and directories named on the command-line.
    36     40     *  New --integrate option to [/help?cmd=merge | fossil merge], which

Changes to www/quotes.wiki.

   114    114   the published aspect of the project, so it provides tools for rearranging
   115    115   that history so you can present what you "should" have done rather
   116    116   than what you actually did.
   117    117   
   118    118   <blockquote>
   119    119   <i>Mike Meyer on the Fossil mailing list, 2011-10-04</i>
   120    120   </blockquote>
          121  +
          122  +<li>github is such a pale shadow of what fossil does.
          123  +
          124  +<blockquote>
          125  +<i>dkf on the Tcl chatroom, 2013-12-06</i>
          126  +</blockquote>
   121    127   </ol>