Merge updates from trunk.

FossilOrigin-Name: 583a79a04ac6f85766209918d1ee58d394d62454
diff --git a/Makefile.msc b/Makefile.msc
index 914bb1e..bf290d0 100644
--- a/Makefile.msc
+++ b/Makefile.msc
@@ -288,6 +288,11 @@
 #
 !IF $(USE_NATIVE_LIBPATHS)!=0
 NLTLIBPATHS = "/LIBPATH:$(NCRTLIBPATH)" "/LIBPATH:$(NSDKLIBPATH)"
+
+!IFDEF NUCRTLIBPATH
+NUCRTLIBPATH = $(NUCRTLIBPATH:\\=\)
+NLTLIBPATHS = $(NLTLIBPATHS) "/LIBPATH:$(NUCRTLIBPATH)"
+!ENDIF
 !ENDIF
 
 # C compiler and options for use in building executables that
diff --git a/ext/fts3/fts3_tokenizer.c b/ext/fts3/fts3_tokenizer.c
index 2b985f5..2a8e18a 100644
--- a/ext/fts3/fts3_tokenizer.c
+++ b/ext/fts3/fts3_tokenizer.c
@@ -279,9 +279,9 @@
   p = (sqlite3_tokenizer_module *)sqlite3Fts3HashFind(pHash, zName, nName+1);
 
   if( !p ){
-    char *zErr = sqlite3_mprintf("unknown tokenizer: %s", zName);
-    sqlite3_result_error(context, zErr, -1);
-    sqlite3_free(zErr);
+    char *zErr2 = sqlite3_mprintf("unknown tokenizer: %s", zName);
+    sqlite3_result_error(context, zErr2, -1);
+    sqlite3_free(zErr2);
     return;
   }
 
diff --git a/ext/misc/fuzzer.c b/ext/misc/fuzzer.c
index dc03161..3ed4b0a 100644
--- a/ext/misc/fuzzer.c
+++ b/ext/misc/fuzzer.c
@@ -876,7 +876,7 @@
   if( pNew==0 ) return 0;
   memset(pNew, 0, sizeof(*pNew));
   pNew->zBasis = (char*)&pNew[1];
-  pNew->nBasis = (int)strlen(zWord);
+  pNew->nBasis = (fuzzer_len)strlen(zWord);
   memcpy(pNew->zBasis, zWord, pNew->nBasis+1);
   pRule = pCur->pVtab->pRule;
   while( fuzzerSkipRule(pRule, pNew, pCur->iRuleset) ){
diff --git a/manifest b/manifest
index 68707be..df2053f 100644
--- a/manifest
+++ b/manifest
@@ -1,9 +1,9 @@
-C Add\sthe\s--mode\soption\sto\sfuzzershell.
-D 2015-04-20T22:36:49.631
+C Merge\supdates\sfrom\strunk.
+D 2015-04-20T23:53:50.803
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in faaf75b89840659d74501bea269c7e33414761c1
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
-F Makefile.msc a19bceec468fa18bb54df52257b1a2211e69172d
+F Makefile.msc 513abdaff333b04ef68775ec25ceb6053b4ecafd
 F Makefile.vxworks e1b65dea203f054e71653415bd8f96dcaed47858
 F README.md d58e3bebc0a4145e0f2a87994015fdb575a8e866
 F VERSION 2e244662b71e6e68a5c29b014ebc5b7564f4cc5a
@@ -91,7 +91,7 @@
 F ext/fts3/fts3_term.c a521f75132f9a495bdca1bdd45949b3191c52763
 F ext/fts3/fts3_test.c 8a3a78c4458b2d7c631fcf4b152a5cd656fa7038
 F ext/fts3/fts3_tokenize_vtab.c becc661223db7898b213f9e8a23d75bac02408c9
-F ext/fts3/fts3_tokenizer.c b7e586baeb8d0a061cf01a0f7081d88f3935eecf
+F ext/fts3/fts3_tokenizer.c 9afd223b07740b14dd589edd3116acacf951fd78
 F ext/fts3/fts3_tokenizer.h 64c6ef6c5272c51ebe60fc607a896e84288fcbc3
 F ext/fts3/fts3_tokenizer1.c 5c98225a53705e5ee34824087478cf477bdb7004
 F ext/fts3/fts3_unicode.c a93f5edc0aff44ef8b06d7cb55b52026541ca145
@@ -111,7 +111,7 @@
 F ext/misc/compress.c 122faa92d25033d6c3f07c39231de074ab3d2e83
 F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2
 F ext/misc/fileio.c d4171c815d6543a9edef8308aab2951413cd8d0f
-F ext/misc/fuzzer.c e3e18f47252c151b5553d7e806f38e757d37c4cc
+F ext/misc/fuzzer.c 4c84635c71c26cfa7c2e5848cf49fe2d2cfcd767
 F ext/misc/ieee754.c b0362167289170627659e84173f5d2e8fee8566e
 F ext/misc/nextchar.c 35c8b8baacb96d92abbb34a83a997b797075b342
 F ext/misc/percentile.c bcbee3c061b884eccb80e21651daaae8e1e43c63
@@ -190,7 +190,7 @@
 F src/hash.c 4263fbc955f26c2e8cdc0cf214bc42435aa4e4f5
 F src/hash.h c8f3c31722cf3277d03713909761e152a5b81094
 F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08
-F src/insert.c b152e71457c40a3967ceafa9e7cbbb52e9ead2c1
+F src/insert.c 8176ba5bad8fcef643558ca5708f33ed05a4035a
 F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d
 F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e
 F src/lempar.c 7274c97d24bb46631e504332ccd3bd1b37841770
@@ -217,13 +217,13 @@
 F src/os_unix.c 5ed7e2e453c2980909a6b2c80dc55764b50819a8
 F src/os_win.c 03d27be3a20048ef52a648d5f0a15f5edda9f2a3
 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca
-F src/pager.c 4120a49ecd37697e28f5ed807f470b9c0b88410c
+F src/pager.c 5283581c8ce8950ff483a0b3a3cab9cb4d25a21e
 F src/pager.h c3476e7c89cdf1c6914e50a11f3714e30b4e0a77
 F src/parse.y c4e0387bc88c8e21e5ba653e2578959a1f3cdbc7
 F src/pcache.c 10539fb959849ad6efff80050541cab3d25089d4
 F src/pcache.h b44658c9c932d203510279439d891a2a83e12ba8
 F src/pcache1.c 69d137620a305f814398bd29a0c998038c0695e9
-F src/pragma.c 2a81f312cdb78bf0672a0484478ca3c1083028e9
+F src/pragma.c c1f4d012ea9f6b1ce52d341b2cd0ad72d560afd7
 F src/pragma.h 09c89bca58e9a44de2116cc8272b8d454657129f
 F src/prepare.c 1fffbdcd6f8a0173a8f70d71f22528f4c0e1e3d3
 F src/printf.c 08fa675c200aac29e561c6153f91f909ed17612f
@@ -231,7 +231,7 @@
 F src/resolve.c 53486a98c17b7ae09b8c2b398013e973ce4c1aae
 F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e
 F src/select.c 361dfc32244656bbe3f0e53d8ed791b3ec0c4be8
-F src/shell.c 28b3e1174a7fc00155d7d00880a33589a88508c9
+F src/shell.c 78eabce4c16c45e36fea2368f95118116399ba8a
 F src/sqlite.h.in ca27603a36fcacdaac5a19d8ee35aaff8ce8516f
 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad
 F src/sqlite3ext.h 17d487c3c91b0b8c584a32fbeb393f6f795eea7d
@@ -239,7 +239,7 @@
 F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46
 F src/status.c f266ad8a2892d659b74f0f50cb6a88b6e7c12179
 F src/table.c e7a09215315a978057fb42c640f890160dbcc45e
-F src/tclsqlite.c fa72a7c5278662357c105ba7925c1d0972506ff9
+F src/tclsqlite.c 14f1992dd6100bfeb1a3dec7e7f449e1c814b8ee
 F src/test1.c 90fbedce75330d48d99eadb7d5f4223e86969585
 F src/test2.c 577961fe48961b2f2e5c8b56ee50c3f459d3359d
 F src/test3.c 64d2afdd68feac1bb5e2ffb8226c8c639f798622
@@ -265,12 +265,12 @@
 F src/test_intarray.h 9dc57417fb65bc7835cc18548852cc08cc062202
 F src/test_journal.c 5360fbe1d1e4416ca36290562fd5a2e3f70f32aa
 F src/test_loadext.c a5251f956ab6af21e138dc1f9c0399394a510cb4
-F src/test_malloc.c b9495384e74923aefde8311de974bf9b0f5ba570
-F src/test_multiplex.c 97813565daa7ee480abcc5dd1e9984ed1f71eb8c
+F src/test_malloc.c 208f09a4e21defa496bc1094fcfadea19385a112
+F src/test_multiplex.c 4dfb159e5c280c0ebdbf8b5ab9d95bf2765061f9
 F src/test_multiplex.h c08e4e8f8651f0c5e0509b138ff4d5b43ed1f5d3
 F src/test_mutex.c 293042d623ebba969160f471a82aa1551626454f
-F src/test_onefile.c 0396f220561f3b4eedc450cef26d40c593c69a25
-F src/test_osinst.c 3d0340bc31a9f3d8a3547e0272373e80f78dde25
+F src/test_onefile.c 38f7cbe79d5bafe95bde683cc3a53b8ca16daf10
+F src/test_osinst.c 5423dc1d355f594371f27dd292ca54bd320b8196
 F src/test_pcache.c a5cd24730cb43c5b18629043314548c9169abb00
 F src/test_quota.c 180813f43683be5725458fc1ff13ac455d8e722d
 F src/test_quota.h 2a8ad1952d1d2ca9af0ce0465e56e6c023b5e15d
@@ -283,7 +283,7 @@
 F src/test_syscall.c 2e21ca7f7dc54a028f1967b63f1e76155c356f9b
 F src/test_tclvar.c f4dc67d5f780707210d6bb0eb6016a431c04c7fa
 F src/test_thread.c af391ec03d23486dffbcc250b7e58e073f172af9
-F src/test_vfs.c b7e6831e6fcf04c5090accff30640ec5c9630739
+F src/test_vfs.c 3b65d42e18b262805716bd96178c81da8f2d9283
 F src/test_vfstrace.c bab9594adc976cbe696ff3970728830b4c5ed698
 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9
 F src/threads.c 6bbcc9fe50c917864d48287b4792d46d6e873481
@@ -307,7 +307,7 @@
 F src/wal.c 753995db83247f20361a8e8a874990b21a75abd9
 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4
 F src/walker.c c253b95b4ee44b21c406e2a1052636c31ea27804
-F src/where.c 8ba8ff31dc9bf1b69fe771d35d8764d5a1efd310
+F src/where.c 723b4f614cd60b7198f5f1cc053362f8a28b0bed
 F src/whereInt.h cbe4aa57326998d89e7698ca65bb7c28541d483c
 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
@@ -1196,7 +1196,7 @@
 F test/wordcount.c 9915e06cb33d8ca8109b8700791afe80d305afda
 F test/zeroblob.test fb3c0e4ab172d386954deda24c03f500e121d80d
 F test/zerodamage.test cf6748bad89553cc1632be51a6f54e487e4039ac
-F tool/build-all-msvc.bat 72e05bc8deca39a547884485c086b915f50a91ed x
+F tool/build-all-msvc.bat 19be654f72b0b0ed4d2451a998c603a4eb65a60f x
 F tool/build-shell.sh 950f47c6174f1eea171319438b93ba67ff5bf367
 F tool/checkSpacing.c 810e51703529a204fc4e1eb060e9ab663e3c06d2
 F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b
@@ -1207,7 +1207,7 @@
 F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4
 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5
 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce
-F tool/lemon.c ae5f61e3b164d35955777b20d6febcbaf0950702
+F tool/lemon.c b9109f59b57e7b6f101c4fe644c8361ba6dee969
 F tool/lempar.c 01ca97f87610d1dac6d8cd96ab109ab1130e76dc
 F tool/logest.c eef612f8adf4d0993dafed0416064cf50d5d33c6
 F tool/mkautoconfamal.sh d1a2da0e15b2ed33d60af35c7e9d483f13a8eb9f
@@ -1219,7 +1219,7 @@
 F tool/mksqlite3c.tcl 52a3352f7aa15f1db851e45ac3a5e2173d6fe93c
 F tool/mksqlite3h.tcl 44730d586c9031638cdd2eb443b801c0d2dbd9f8
 F tool/mksqlite3internalh.tcl eb994013e833359137eb53a55acdad0b5ae1049b
-F tool/mkvsix.tcl 52a4c613707ac34ae9c226e5ccc69cb948556105
+F tool/mkvsix.tcl 3b58b9398f91c7dbf18d49eb87cefeee9efdbce1
 F tool/offsets.c fe4262fdfa378e8f5499a42136d17bf3b98f6091
 F tool/omittest.tcl 34d7ac01fe4fd18e3637f64abe12c40eca0f6b97
 F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c
@@ -1251,7 +1251,7 @@
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 41c954391690833bf2ece4ea14457ee4bdd74e90
-R 18124f1b8c247e9f547c30e618d3a441
-U drh
-Z d312afa4cd0d932d0a233db0b53736ad
+P 5ae853aaebaee76c9265061984185f74c10c4c8b b940b0fa6cf68fef58344d269ad5d39468ffe72f
+R 9804529a8e22c5281a0b002dbd15342c
+U mistachkin
+Z 86189532b6fc39f0925b12aaa4387878
diff --git a/manifest.uuid b/manifest.uuid
index dfe61ad..71cc58d 100644
--- a/manifest.uuid
+++ b/manifest.uuid
@@ -1 +1 @@
-b940b0fa6cf68fef58344d269ad5d39468ffe72f
\ No newline at end of file
+583a79a04ac6f85766209918d1ee58d394d62454
\ No newline at end of file
diff --git a/src/insert.c b/src/insert.c
index f8f3766..c794ae4 100644
--- a/src/insert.c
+++ b/src/insert.c
@@ -2025,7 +2025,6 @@
       ** might change the definition of a collation sequence and then run
       ** a VACUUM command. In that case keys may not be written in strictly
       ** sorted order.  */
-      int i;
       for(i=0; i<pSrcIdx->nColumn; i++){
         char *zColl = pSrcIdx->azColl[i];
         assert( zColl!=0 );
diff --git a/src/pager.c b/src/pager.c
index 2230174..9ee2eca 100644
--- a/src/pager.c
+++ b/src/pager.c
@@ -3044,9 +3044,7 @@
 ){
   int rc;                         /* Return code */
   int nList;                      /* Number of pages in pList */
-#if defined(SQLITE_DEBUG) || defined(SQLITE_CHECK_PAGES)
   PgHdr *p;                       /* For looping over pages */
-#endif
 
   assert( pPager->pWal );
   assert( pList );
@@ -3063,7 +3061,6 @@
     ** any pages with page numbers greater than nTruncate into the WAL file.
     ** They will never be read by any client. So remove them from the pDirty
     ** list here. */
-    PgHdr *p;
     PgHdr **ppNext = &pList;
     nList = 0;
     for(p=pList; (*ppNext = p)!=0; p=p->pDirty){
@@ -3083,7 +3080,6 @@
       pPager->pageSize, pList, nTruncate, isCommit, pPager->walSyncFlags
   );
   if( rc==SQLITE_OK && pPager->pBackup ){
-    PgHdr *p;
     for(p=pList; p; p=p->pDirty){
       sqlite3BackupUpdate(pPager->pBackup, p->pgno, (u8 *)p->pData);
     }
diff --git a/src/pragma.c b/src/pragma.c
index 614daa5..1b42138 100644
--- a/src/pragma.c
+++ b/src/pragma.c
@@ -164,15 +164,15 @@
 */
 static void returnSingleInt(Parse *pParse, const char *zLabel, i64 value){
   Vdbe *v = sqlite3GetVdbe(pParse);
-  int mem = ++pParse->nMem;
+  int nMem = ++pParse->nMem;
   i64 *pI64 = sqlite3DbMallocRaw(pParse->db, sizeof(value));
   if( pI64 ){
     memcpy(pI64, &value, sizeof(value));
   }
-  sqlite3VdbeAddOp4(v, OP_Int64, 0, mem, 0, (char*)pI64, P4_INT64);
+  sqlite3VdbeAddOp4(v, OP_Int64, 0, nMem, 0, (char*)pI64, P4_INT64);
   sqlite3VdbeSetNumCols(v, 1);
   sqlite3VdbeSetColName(v, 0, COLNAME_NAME, zLabel, SQLITE_STATIC);
-  sqlite3VdbeAddOp2(v, OP_ResultRow, mem, 1);
+  sqlite3VdbeAddOp2(v, OP_ResultRow, nMem, 1);
 }
 
 
@@ -337,11 +337,11 @@
   rc = sqlite3_file_control(db, zDb, SQLITE_FCNTL_PRAGMA, (void*)aFcntl);
   if( rc==SQLITE_OK ){
     if( aFcntl[0] ){
-      int mem = ++pParse->nMem;
-      sqlite3VdbeAddOp4(v, OP_String8, 0, mem, 0, aFcntl[0], 0);
+      int nMem = ++pParse->nMem;
+      sqlite3VdbeAddOp4(v, OP_String8, 0, nMem, 0, aFcntl[0], 0);
       sqlite3VdbeSetNumCols(v, 1);
       sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "result", SQLITE_STATIC);
-      sqlite3VdbeAddOp2(v, OP_ResultRow, mem, 1);
+      sqlite3VdbeAddOp2(v, OP_ResultRow, nMem, 1);
       sqlite3_free(aFcntl[0]);
     }
     goto pragma_out;
diff --git a/src/shell.c b/src/shell.c
index 0d83084..830deb2 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -336,7 +336,7 @@
 ** to this database a static variable so that it can be accessed
 ** by the SIGINT handler to interrupt database processing.
 */
-static sqlite3 *db = 0;
+static sqlite3 *globalDb = 0;
 
 /*
 ** True if an interrupt (Control-C) has been received.
@@ -805,7 +805,7 @@
   UNUSED_PARAMETER(NotUsed);
   seenInterrupt++;
   if( seenInterrupt>2 ) exit(1);
-  if( db ) sqlite3_interrupt(db);
+  if( globalDb ) sqlite3_interrupt(globalDb);
 }
 #endif
 
@@ -1909,23 +1909,23 @@
   if( p->db==0 ){
     sqlite3_initialize();
     sqlite3_open(p->zDbFilename, &p->db);
-    db = p->db;
-    if( db && sqlite3_errcode(db)==SQLITE_OK ){
-      sqlite3_create_function(db, "shellstatic", 0, SQLITE_UTF8, 0,
+    globalDb = p->db;
+    if( p->db && sqlite3_errcode(p->db)==SQLITE_OK ){
+      sqlite3_create_function(p->db, "shellstatic", 0, SQLITE_UTF8, 0,
           shellstaticFunc, 0, 0);
     }
-    if( db==0 || SQLITE_OK!=sqlite3_errcode(db) ){
+    if( p->db==0 || SQLITE_OK!=sqlite3_errcode(p->db) ){
       fprintf(stderr,"Error: unable to open database \"%s\": %s\n", 
-          p->zDbFilename, sqlite3_errmsg(db));
+          p->zDbFilename, sqlite3_errmsg(p->db));
       if( keepAlive ) return;
       exit(1);
     }
 #ifndef SQLITE_OMIT_LOAD_EXTENSION
     sqlite3_enable_load_extension(p->db, 1);
 #endif
-    sqlite3_create_function(db, "readfile", 1, SQLITE_UTF8, 0,
+    sqlite3_create_function(p->db, "readfile", 1, SQLITE_UTF8, 0,
                             readfileFunc, 0, 0);
-    sqlite3_create_function(db, "writefile", 2, SQLITE_UTF8, 0,
+    sqlite3_create_function(p->db, "writefile", 2, SQLITE_UTF8, 0,
                             writefileFunc, 0, 0);
   }
 }
@@ -2586,7 +2586,7 @@
 ** Return 1 on error, 2 to exit, and 0 otherwise.
 */
 static int do_meta_command(char *zLine, ShellState *p){
-  int i = 1;
+  int h = 1;
   int nArg = 0;
   int n, c;
   int rc = 0;
@@ -2594,24 +2594,24 @@
 
   /* Parse the input line into tokens.
   */
-  while( zLine[i] && nArg<ArraySize(azArg) ){
-    while( IsSpace(zLine[i]) ){ i++; }
-    if( zLine[i]==0 ) break;
-    if( zLine[i]=='\'' || zLine[i]=='"' ){
-      int delim = zLine[i++];
-      azArg[nArg++] = &zLine[i];
-      while( zLine[i] && zLine[i]!=delim ){ 
-        if( zLine[i]=='\\' && delim=='"' && zLine[i+1]!=0 ) i++;
-        i++; 
+  while( zLine[h] && nArg<ArraySize(azArg) ){
+    while( IsSpace(zLine[h]) ){ h++; }
+    if( zLine[h]==0 ) break;
+    if( zLine[h]=='\'' || zLine[h]=='"' ){
+      int delim = zLine[h++];
+      azArg[nArg++] = &zLine[h];
+      while( zLine[h] && zLine[h]!=delim ){ 
+        if( zLine[h]=='\\' && delim=='"' && zLine[h+1]!=0 ) h++;
+        h++; 
       }
-      if( zLine[i]==delim ){
-        zLine[i++] = 0;
+      if( zLine[h]==delim ){
+        zLine[h++] = 0;
       }
       if( delim=='"' ) resolve_backslashes(azArg[nArg-1]);
     }else{
-      azArg[nArg++] = &zLine[i];
-      while( zLine[i] && !IsSpace(zLine[i]) ){ i++; }
-      if( zLine[i] ) zLine[i++] = 0;
+      azArg[nArg++] = &zLine[h];
+      while( zLine[h] && !IsSpace(zLine[h]) ){ h++; }
+      if( zLine[h] ) zLine[h++] = 0;
       resolve_backslashes(azArg[nArg-1]);
     }
   }
@@ -2987,7 +2987,7 @@
     nByte = strlen30(zSql);
     rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
     import_append_char(&sCtx, 0);    /* To ensure sCtx.z is allocated */
-    if( rc && sqlite3_strglob("no such table: *", sqlite3_errmsg(db))==0 ){
+    if( rc && sqlite3_strglob("no such table: *", sqlite3_errmsg(p->db))==0 ){
       char *zCreate = sqlite3_mprintf("CREATE TABLE %s", zTable);
       char cSep = '(';
       while( xRead(&sCtx) ){
@@ -3007,7 +3007,7 @@
       sqlite3_free(zCreate);
       if( rc ){
         fprintf(stderr, "CREATE TABLE %s(...) failed: %s\n", zTable,
-                sqlite3_errmsg(db));
+                sqlite3_errmsg(p->db));
         sqlite3_free(sCtx.z);
         xCloser(sCtx.in);
         return 1;
@@ -3017,7 +3017,7 @@
     sqlite3_free(zSql);
     if( rc ){
       if (pStmt) sqlite3_finalize(pStmt);
-      fprintf(stderr,"Error: %s\n", sqlite3_errmsg(db));
+      fprintf(stderr,"Error: %s\n", sqlite3_errmsg(p->db));
       xCloser(sCtx.in);
       return 1;
     }
@@ -3042,13 +3042,13 @@
     rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
     sqlite3_free(zSql);
     if( rc ){
-      fprintf(stderr, "Error: %s\n", sqlite3_errmsg(db));
+      fprintf(stderr, "Error: %s\n", sqlite3_errmsg(p->db));
       if (pStmt) sqlite3_finalize(pStmt);
       xCloser(sCtx.in);
       return 1;
     }
-    needCommit = sqlite3_get_autocommit(db);
-    if( needCommit ) sqlite3_exec(db, "BEGIN", 0, 0, 0);
+    needCommit = sqlite3_get_autocommit(p->db);
+    if( needCommit ) sqlite3_exec(p->db, "BEGIN", 0, 0, 0);
     do{
       int startLine = sCtx.nLine;
       for(i=0; i<nCol; i++){
@@ -3087,7 +3087,7 @@
         rc = sqlite3_reset(pStmt);
         if( rc!=SQLITE_OK ){
           fprintf(stderr, "%s:%d: INSERT failed: %s\n", sCtx.zFile, startLine,
-                  sqlite3_errmsg(db));
+                  sqlite3_errmsg(p->db));
         }
       }
     }while( sCtx.cTerm!=EOF );
@@ -3095,7 +3095,7 @@
     xCloser(sCtx.in);
     sqlite3_free(sCtx.z);
     sqlite3_finalize(pStmt);
-    if( needCommit ) sqlite3_exec(db, "COMMIT", 0, 0, 0);
+    if( needCommit ) sqlite3_exec(p->db, "COMMIT", 0, 0, 0);
   }else
 
   if( c=='i' && (strncmp(azArg[0], "indices", n)==0
@@ -3649,13 +3649,13 @@
     while( sqlite3_step(pStmt)==SQLITE_ROW ){
       if( nRow>=nAlloc ){
         char **azNew;
-        int n = nAlloc*2 + 10;
-        azNew = sqlite3_realloc(azResult, sizeof(azResult[0])*n);
+        int n2 = nAlloc*2 + 10;
+        azNew = sqlite3_realloc(azResult, sizeof(azResult[0])*n2);
         if( azNew==0 ){
           fprintf(stderr, "Error: out of memory\n");
           break;
         }
-        nAlloc = n;
+        nAlloc = n2;
         azResult = azNew;
       }
       azResult[nRow] = sqlite3_mprintf("%s", sqlite3_column_text(pStmt, 0));
@@ -3708,15 +3708,15 @@
       { "imposter",              SQLITE_TESTCTRL_IMPOSTER               },
     };
     int testctrl = -1;
-    int rc = 0;
-    int i, n;
+    int rc2 = 0;
+    int i, n2;
     open_db(p, 0);
 
     /* convert testctrl text option to value. allow any unique prefix
     ** of the option name, or a numerical value. */
-    n = strlen30(azArg[1]);
+    n2 = strlen30(azArg[1]);
     for(i=0; i<(int)(sizeof(aCtrl)/sizeof(aCtrl[0])); i++){
-      if( strncmp(azArg[1], aCtrl[i].zCtrlName, n)==0 ){
+      if( strncmp(azArg[1], aCtrl[i].zCtrlName, n2)==0 ){
         if( testctrl<0 ){
           testctrl = aCtrl[i].ctrlCode;
         }else{
@@ -3737,8 +3737,8 @@
         case SQLITE_TESTCTRL_RESERVE:             
           if( nArg==3 ){
             int opt = (int)strtol(azArg[2], 0, 0);        
-            rc = sqlite3_test_control(testctrl, p->db, opt);
-            fprintf(p->out, "%d (0x%08x)\n", rc, rc);
+            rc2 = sqlite3_test_control(testctrl, p->db, opt);
+            fprintf(p->out, "%d (0x%08x)\n", rc2, rc2);
           } else {
             fprintf(stderr,"Error: testctrl %s takes a single int option\n",
                     azArg[1]);
@@ -3751,8 +3751,8 @@
         case SQLITE_TESTCTRL_PRNG_RESET:
         case SQLITE_TESTCTRL_BYTEORDER:
           if( nArg==2 ){
-            rc = sqlite3_test_control(testctrl);
-            fprintf(p->out, "%d (0x%08x)\n", rc, rc);
+            rc2 = sqlite3_test_control(testctrl);
+            fprintf(p->out, "%d (0x%08x)\n", rc2, rc2);
           } else {
             fprintf(stderr,"Error: testctrl %s takes no options\n", azArg[1]);
           }
@@ -3762,8 +3762,8 @@
         case SQLITE_TESTCTRL_PENDING_BYTE:        
           if( nArg==3 ){
             unsigned int opt = (unsigned int)integerValue(azArg[2]);
-            rc = sqlite3_test_control(testctrl, opt);
-            fprintf(p->out, "%d (0x%08x)\n", rc, rc);
+            rc2 = sqlite3_test_control(testctrl, opt);
+            fprintf(p->out, "%d (0x%08x)\n", rc2, rc2);
           } else {
             fprintf(stderr,"Error: testctrl %s takes a single unsigned"
                            " int option\n", azArg[1]);
@@ -3776,8 +3776,8 @@
         case SQLITE_TESTCTRL_NEVER_CORRUPT:        
           if( nArg==3 ){
             int opt = booleanValue(azArg[2]);        
-            rc = sqlite3_test_control(testctrl, opt);
-            fprintf(p->out, "%d (0x%08x)\n", rc, rc);
+            rc2 = sqlite3_test_control(testctrl, opt);
+            fprintf(p->out, "%d (0x%08x)\n", rc2, rc2);
           } else {
             fprintf(stderr,"Error: testctrl %s takes a single int option\n",
                             azArg[1]);
@@ -3789,8 +3789,8 @@
         case SQLITE_TESTCTRL_ISKEYWORD:           
           if( nArg==3 ){
             const char *opt = azArg[2];        
-            rc = sqlite3_test_control(testctrl, opt);
-            fprintf(p->out, "%d (0x%08x)\n", rc, rc);
+            rc2 = sqlite3_test_control(testctrl, opt);
+            fprintf(p->out, "%d (0x%08x)\n", rc2, rc2);
           } else {
             fprintf(stderr,"Error: testctrl %s takes a single char * option\n",
                             azArg[1]);
@@ -3800,11 +3800,11 @@
 
         case SQLITE_TESTCTRL_IMPOSTER:
           if( nArg==5 ){
-            rc = sqlite3_test_control(testctrl, p->db, 
+            rc2 = sqlite3_test_control(testctrl, p->db, 
                           azArg[2],
                           integerValue(azArg[3]),
                           integerValue(azArg[4]));
-            fprintf(p->out, "%d (0x%08x)\n", rc, rc);
+            fprintf(p->out, "%d (0x%08x)\n", rc2, rc2);
           }else{
             fprintf(stderr,"Usage: .testctrl imposter dbName onoff tnum\n");
           }
diff --git a/src/tclsqlite.c b/src/tclsqlite.c
index 710084b..e38c1dd 100644
--- a/src/tclsqlite.c
+++ b/src/tclsqlite.c
@@ -1191,7 +1191,7 @@
         int n;
         u8 *data;
         const char *zType = (pVar->typePtr ? pVar->typePtr->name : "");
-        char c = zType[0];
+        c = zType[0];
         if( zVar[0]=='@' ||
            (c=='b' && strcmp(zType,"bytearray")==0 && pVar->bytes==0) ){
           /* Load a BLOB type if the Tcl variable is a bytearray and
@@ -2298,7 +2298,7 @@
       }
       Tcl_DecrRefCount(pRet);
     }else{
-      ClientData cd[2];
+      ClientData cd2[2];
       DbEvalContext *p;
       Tcl_Obj *pArray = 0;
       Tcl_Obj *pScript;
@@ -2312,9 +2312,9 @@
       p = (DbEvalContext *)Tcl_Alloc(sizeof(DbEvalContext));
       dbEvalInit(p, pDb, objv[2], pArray);
 
-      cd[0] = (void *)p;
-      cd[1] = (void *)pScript;
-      rc = DbEvalNextCmd(cd, interp, TCL_OK);
+      cd2[0] = (void *)p;
+      cd2[1] = (void *)pScript;
+      rc = DbEvalNextCmd(cd2, interp, TCL_OK);
     }
     break;
   }
diff --git a/src/test_malloc.c b/src/test_malloc.c
index 1ea4de5..94a2282 100644
--- a/src/test_malloc.c
+++ b/src/test_malloc.c
@@ -211,15 +211,15 @@
         faultsimBeginBenign, faultsimEndBenign
     );
   }else{
-    sqlite3_mem_methods m;
+    sqlite3_mem_methods m2;
     assert(memfault.m.xMalloc);
 
     /* One should be able to reset the default memory allocator by storing
     ** a zeroed allocator then calling GETMALLOC. */
-    memset(&m, 0, sizeof(m));
-    sqlite3_config(SQLITE_CONFIG_MALLOC, &m);
-    sqlite3_config(SQLITE_CONFIG_GETMALLOC, &m);
-    assert( memcmp(&m, &memfault.m, sizeof(m))==0 );
+    memset(&m2, 0, sizeof(m2));
+    sqlite3_config(SQLITE_CONFIG_MALLOC, &m2);
+    sqlite3_config(SQLITE_CONFIG_GETMALLOC, &m2);
+    assert( memcmp(&m2, &memfault.m, sizeof(m2))==0 );
 
     rc = sqlite3_config(SQLITE_CONFIG_MALLOC, &memfault.m);
     sqlite3_test_control(SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS, 0, 0);
diff --git a/src/test_multiplex.c b/src/test_multiplex.c
index cd379f1..c1077fb 100644
--- a/src/test_multiplex.c
+++ b/src/test_multiplex.c
@@ -568,15 +568,15 @@
       if( pSubOpen==0 && rc==SQLITE_OK ) rc = SQLITE_CANTOPEN;
     }
     if( rc==SQLITE_OK ){
-      sqlite3_int64 sz;
+      sqlite3_int64 sz64;
 
-      rc = pSubOpen->pMethods->xFileSize(pSubOpen, &sz);
+      rc = pSubOpen->pMethods->xFileSize(pSubOpen, &sz64);
       if( rc==SQLITE_OK && zName ){
         int bExists;
         if( flags & SQLITE_OPEN_MASTER_JOURNAL ){
           pGroup->bEnabled = 0;
         }else
-        if( sz==0 ){
+        if( sz64==0 ){
           if( flags & SQLITE_OPEN_MAIN_JOURNAL ){
             /* If opening a main journal file and the first chunk is zero
             ** bytes in size, delete any subsequent chunks from the 
@@ -607,10 +607,10 @@
           rc = pOrigVfs->xAccess(pOrigVfs, pGroup->aReal[1].z,
               SQLITE_ACCESS_EXISTS, &bExists);
           bExists = multiplexSubSize(pGroup, 1, &rc)>0;
-          if( rc==SQLITE_OK && bExists  && sz==(sz&0xffff0000) && sz>0
-              && sz!=pGroup->szChunk ){
-            pGroup->szChunk = (int)sz;
-          }else if( rc==SQLITE_OK && !bExists && sz>pGroup->szChunk ){
+          if( rc==SQLITE_OK && bExists && sz64==(sz64&0xffff0000) && sz64>0
+              && sz64!=pGroup->szChunk ){
+            pGroup->szChunk = (int)sz64;
+          }else if( rc==SQLITE_OK && !bExists && sz64>pGroup->szChunk ){
             pGroup->bEnabled = 0;
           }
         }
diff --git a/src/test_onefile.c b/src/test_onefile.c
index 6986744..122be70 100644
--- a/src/test_onefile.c
+++ b/src/test_onefile.c
@@ -595,9 +595,9 @@
   int rc = SQLITE_OK;
 
   if( 0==(flags&(SQLITE_OPEN_MAIN_DB|SQLITE_OPEN_MAIN_JOURNAL)) ){
-    tmp_file *p = (tmp_file *)pFile;
-    memset(p, 0, sizeof(*p));
-    p->base.pMethods = &tmp_io_methods;
+    tmp_file *p2 = (tmp_file *)pFile;
+    memset(p2, 0, sizeof(*p2));
+    p2->base.pMethods = &tmp_io_methods;
     return SQLITE_OK;
   }
 
diff --git a/src/test_osinst.c b/src/test_osinst.c
index 1701def..4ae23a8 100644
--- a/src/test_osinst.c
+++ b/src/test_osinst.c
@@ -1131,7 +1131,6 @@
 
   switch( (enum VL_enum)iSub ){
     case VL_ANNOTATE: {
-      int rc;
       char *zVfs;
       char *zMsg;
       if( objc!=4 ){
@@ -1148,7 +1147,6 @@
       break;
     }
     case VL_FINALIZE: {
-      int rc;
       char *zVfs;
       if( objc!=3 ){
         Tcl_WrongNumArgs(interp, 2, objv, "VFS");
@@ -1164,7 +1162,6 @@
     };
 
     case VL_NEW: {
-      int rc;
       char *zVfs;
       char *zParent;
       char *zLog;
diff --git a/src/test_vfs.c b/src/test_vfs.c
index 2277cf7..a8c6ae7 100644
--- a/src/test_vfs.c
+++ b/src/test_vfs.c
@@ -1080,7 +1080,7 @@
   switch( aSubcmd[i].eCmd ){
     case CMD_SHM: {
       Tcl_Obj *pObj;
-      int i, rc;
+      int rc;
       TestvfsBuffer *pBuffer;
       char *zName;
       if( objc!=3 && objc!=4 ){
@@ -1160,7 +1160,6 @@
       };
       Tcl_Obj **apElem = 0;
       int nElem = 0;
-      int i;
       int mask = 0;
       if( objc!=3 ){
         Tcl_WrongNumArgs(interp, 2, objv, "LIST");
diff --git a/src/where.c b/src/where.c
index 3467a68..1b97ebf 100644
--- a/src/where.c
+++ b/src/where.c
@@ -6646,7 +6646,6 @@
   }
 #ifdef WHERETRACE_ENABLED /* !=0 */
   if( sqlite3WhereTrace ){
-    int ii;
     sqlite3DebugPrintf("---- Solution nRow=%d", pWInfo->nRowOut);
     if( pWInfo->nOBSat>0 ){
       sqlite3DebugPrintf(" ORDERBY=%d,0x%llx", pWInfo->nOBSat, pWInfo->revMask);
diff --git a/tool/build-all-msvc.bat b/tool/build-all-msvc.bat
index 7281836..534ea75 100755
--- a/tool/build-all-msvc.bat
+++ b/tool/build-all-msvc.bat
@@ -28,6 +28,11 @@
 REM source tree for SQLite and "C:\Temp" represents the final destination

 REM directory for the generated output files.

 REM

+REM Please note that the SQLite build process performed by the Makefile

+REM associated with this batch script requires both Gawk ^(gawk.exe^) and Tcl

+REM 8.5 ^(tclsh85.exe^) to be present in a directory contained in the PATH

+REM environment variable unless a pre-existing amalgamation file is used.

+REM

 REM There are several environment variables that may be set to modify the

 REM behavior of this batch script and its associated Makefile.  The list of

 REM platforms to build may be overriden by using the PLATFORMS environment

@@ -37,17 +42,58 @@
 REM setting the CONFIGURATIONS environment variable, which should contain a

 REM list of configurations to build ^(e.g. Debug Retail^).  Neither of these

 REM variable values may contain any double quotes, surrounding or embedded.

-REM Finally, the NCRTLIBPATH and NSDKLIBPATH environment variables may be set

-REM to specify the location of the CRT and SDK, respectively, needed to compile

-REM executables native to the architecture of the build machine during any

-REM cross-compilation that may be necessary, depending on the platforms to be

-REM built.  These values in these two variables should be surrounded by double

-REM quotes if they contain spaces.

 REM

-REM Please note that the SQLite build process performed by the Makefile

-REM associated with this batch script requires both Gawk ^(gawk.exe^) and Tcl

-REM 8.5 ^(tclsh85.exe^) to be present in a directory contained in the PATH

-REM environment variable unless a pre-existing amalgamation file is used.

+REM Finally, the NCRTLIBPATH, NUCRTLIBPATH, and NSDKLIBPATH environment

+REM variables may be set to specify the location of the CRT, Universal CRT, and

+REM Windows SDK, respectively, that may be needed to compile executables native

+REM to the architecture of the build machine during any cross-compilation that

+REM may be necessary, depending on the platforms to be built.  These values in

+REM these three variables should be surrounded by double quotes if they contain

+REM spaces.

+REM

+REM There are a few other environment variables that impact the build process

+REM when set ^(to anything^), they are:

+REM

+REM                        NOCLEAN

+REM

+REM When set, the "clean" target will not be used during each build iteration.

+REM However, the target binaries, if any, will still be deleted manually prior

+REM to being rebuilt.  Setting this environment variable is only rarely needed

+REM and could cause issues in some circumstances; therefore, setting it is not

+REM recommended.

+REM

+REM                        NOSYMBOLS

+REM

+REM When set, copying of symbol files ^(*.pdb^) created during the build will

+REM be skipped and they will not appear in the final destination directory.

+REM Setting this environment variable is never strictly needed and could cause

+REM issues in some circumstances; therefore, setting it is not recommended.

+REM

+REM                        BUILD_ALL_SHELL

+REM

+REM When set, the command line shell will be built for each selected platform

+REM and configuration as well.  In addition, the command line shell binaries

+REM will be copied, with their symbols, to the final destination directory.

+REM

+REM                        USE_WINV63_NSDKLIBPATH

+REM

+REM When set, modifies how the NSDKLIBPATH environment variable is built, based

+REM on the WindowsSdkDir environment variable.  It forces this batch script to

+REM assume the Windows 8.1 SDK location should be used.

+REM

+REM                        USE_WINV100_NSDKLIBPATH

+REM

+REM When set, modifies how the NSDKLIBPATH environment variable is built, based

+REM on the WindowsSdkDir environment variable.  It causes this batch script to

+REM assume the Windows 10.0 SDK location should be used.

+REM

+REM                        NMAKE_ARGS

+REM

+REM When set, the value is expanded and passed to the NMAKE command line, after

+REM its other arguments.  This is used to specify additional NMAKE options, for

+REM example:

+REM

+REM                        SET NMAKE_ARGS=FOR_WINRT=1

 REM

 SETLOCAL

 

@@ -217,8 +263,20 @@
 %_VECHO% ToolPath = '%TOOLPATH%'

 

 REM

-REM NOTE: Check for MSVC 2012/2013 because the Windows SDK directory handling

-REM       is slightly different for those versions.

+REM NOTE: Setting the Windows SDK library path is only required for MSVC

+REM       2012, 2013, and 2015.

+REM

+CALL :fn_UnsetVariable SET_NSDKLIBPATH

+

+REM

+REM NOTE: Setting the Universal CRT library path is only required for MSVC

+REM       2015.

+REM

+CALL :fn_UnsetVariable SET_NUCRTLIBPATH

+

+REM

+REM NOTE: Check for MSVC 2012, 2013, and 2015 specially because the Windows

+REM       SDK directory handling is slightly different for those versions.

 REM

 IF "%VisualStudioVersion%" == "11.0" (

   REM

@@ -236,8 +294,22 @@
   IF NOT DEFINED NSDKLIBPATH (

     SET SET_NSDKLIBPATH=1

   )

-) ELSE (

-  CALL :fn_UnsetVariable SET_NSDKLIBPATH

+) ELSE IF "%VisualStudioVersion%" == "14.0" (

+  REM

+  REM NOTE: If the Windows SDK library path has already been set, do not set

+  REM       it to something else later on.

+  REM

+  IF NOT DEFINED NSDKLIBPATH (

+    SET SET_NSDKLIBPATH=1

+  )

+

+  REM

+  REM NOTE: If the Universal CRT library path has already been set, do not set

+  REM       it to something else later on.

+  REM

+  IF NOT DEFINED NUCRTLIBPATH (

+    SET SET_NUCRTLIBPATH=1

+  )

 )

 

 REM

@@ -294,6 +366,7 @@
     CALL :fn_UnsetVariable LIB

     CALL :fn_UnsetVariable LIBPATH

     CALL :fn_UnsetVariable Platform

+    CALL :fn_UnsetVariable UniversalCRTSdkDir

     REM CALL :fn_UnsetVariable VCINSTALLDIR

     CALL :fn_UnsetVariable VSINSTALLDIR

     CALL :fn_UnsetVariable WindowsPhoneKitDir

@@ -385,8 +458,8 @@
         )

 

         REM

-        REM NOTE: When using MSVC 2012 and/or 2013, the native SDK path cannot

-        REM       simply use the "lib" sub-directory beneath the location

+        REM NOTE: When using MSVC 2012, 2013, or 2015, the native SDK path

+        REM       cannot simply be the "lib" sub-directory beneath the location

         REM       specified in the WindowsSdkDir environment variable because

         REM       that location does not actually contain the necessary library

         REM       files for x86.  This must be done for each iteration because

@@ -405,13 +478,17 @@
             CALL :fn_CopyVariable WindowsSdkDir NSDKLIBPATH

 

             REM

-            REM NOTE: The Windows 8.1 SDK has a slightly different directory

-            REM       naming convention.

+            REM NOTE: The Windows 8.x and Windows 10.0 SDKs have a slightly

+            REM       different directory naming conventions.

             REM

-            IF DEFINED USE_WINV63_NSDKLIBPATH (

+            IF DEFINED USE_WINV100_NSDKLIBPATH (

+              CALL :fn_AppendVariable NSDKLIBPATH \..\10\lib\10.0.10030.0\um\x86

+            ) ELSE IF DEFINED USE_WINV63_NSDKLIBPATH (

               CALL :fn_AppendVariable NSDKLIBPATH \lib\winv6.3\um\x86

             ) ELSE IF "%VisualStudioVersion%" == "12.0" (

               CALL :fn_AppendVariable NSDKLIBPATH \..\8.0\lib\win8\um\x86

+            ) ELSE IF "%VisualStudioVersion%" == "14.0" (

+              CALL :fn_AppendVariable NSDKLIBPATH \..\8.0\lib\win8\um\x86

             ) ELSE (

               CALL :fn_AppendVariable NSDKLIBPATH \lib\win8\um\x86

             )

@@ -419,6 +496,20 @@
         )

 

         REM

+        REM NOTE: When using MSVC 2015, setting the Universal CRT library path

+        REM       for x86 may be required as well.  This must also be done for

+        REM       each iteration because it relies upon the UniversalCRTSdkDir

+        REM       environment variable being set by the batch file used to

+        REM       setup the MSVC environment.

+        REM

+        IF DEFINED SET_NUCRTLIBPATH (

+          IF DEFINED UniversalCRTSdkDir (

+            CALL :fn_CopyVariable UniversalCRTSdkDir NUCRTLIBPATH

+            CALL :fn_AppendVariable NUCRTLIBPATH \lib\winv10.0\ucrt\x86

+          )

+        )

+

+        REM

         REM NOTE: Unless prevented from doing so, invoke NMAKE with the MSVC

         REM       makefile to clean any stale build output from previous

         REM       iterations of this loop and/or previous runs of this batch

diff --git a/tool/lemon.c b/tool/lemon.c
index cc3066b..89d992c 100644
--- a/tool/lemon.c
+++ b/tool/lemon.c
@@ -1114,7 +1114,6 @@
   /* Resolve conflicts */
   for(i=0; i<lemp->nstate; i++){
     struct action *ap, *nap;
-    struct state *stp;
     stp = lemp->sorted[i];
     /* assert( stp->ap ); */
     stp->ap = Action_sort(stp->ap);
@@ -3748,9 +3747,9 @@
   /* Generate the include code, if any */
   tplt_print(out,lemp,lemp->include,&lineno);
   if( mhflag ){
-    char *name = file_makename(lemp, ".h");
-    fprintf(out,"#include \"%s\"\n", name); lineno++;
-    free(name);
+    char *incName = file_makename(lemp, ".h");
+    fprintf(out,"#include \"%s\"\n", incName); lineno++;
+    free(incName);
   }
   tplt_xfer(lemp->name,in,out,&lineno);
 
@@ -3791,7 +3790,6 @@
   }
   name = lemp->name ? lemp->name : "Parse";
   if( lemp->arg && lemp->arg[0] ){
-    int i;
     i = lemonStrlen(lemp->arg);
     while( i>=1 && isspace(lemp->arg[i-1]) ) i--;
     while( i>=1 && (isalnum(lemp->arg[i-1]) || lemp->arg[i-1]=='_') ) i--;
@@ -4479,18 +4477,18 @@
   }
   if( x1a->count>=x1a->size ){
     /* Need to make the hash table bigger */
-    int i,size;
+    int i,arrSize;
     struct s_x1 array;
-    array.size = size = x1a->size*2;
+    array.size = arrSize = x1a->size*2;
     array.count = x1a->count;
-    array.tbl = (x1node*)calloc(size, sizeof(x1node) + sizeof(x1node*));
+    array.tbl = (x1node*)calloc(arrSize, sizeof(x1node) + sizeof(x1node*));
     if( array.tbl==0 ) return 0;  /* Fail due to malloc failure */
-    array.ht = (x1node**)&(array.tbl[size]);
-    for(i=0; i<size; i++) array.ht[i] = 0;
+    array.ht = (x1node**)&(array.tbl[arrSize]);
+    for(i=0; i<arrSize; i++) array.ht[i] = 0;
     for(i=0; i<x1a->count; i++){
       x1node *oldnp, *newnp;
       oldnp = &(x1a->tbl[i]);
-      h = strhash(oldnp->data) & (size-1);
+      h = strhash(oldnp->data) & (arrSize-1);
       newnp = &(array.tbl[i]);
       if( array.ht[h] ) array.ht[h]->from = &(newnp->next);
       newnp->next = array.ht[h];
@@ -4646,18 +4644,18 @@
   }
   if( x2a->count>=x2a->size ){
     /* Need to make the hash table bigger */
-    int i,size;
+    int i,arrSize;
     struct s_x2 array;
-    array.size = size = x2a->size*2;
+    array.size = arrSize = x2a->size*2;
     array.count = x2a->count;
-    array.tbl = (x2node*)calloc(size, sizeof(x2node) + sizeof(x2node*));
+    array.tbl = (x2node*)calloc(arrSize, sizeof(x2node) + sizeof(x2node*));
     if( array.tbl==0 ) return 0;  /* Fail due to malloc failure */
-    array.ht = (x2node**)&(array.tbl[size]);
-    for(i=0; i<size; i++) array.ht[i] = 0;
+    array.ht = (x2node**)&(array.tbl[arrSize]);
+    for(i=0; i<arrSize; i++) array.ht[i] = 0;
     for(i=0; i<x2a->count; i++){
       x2node *oldnp, *newnp;
       oldnp = &(x2a->tbl[i]);
-      h = strhash(oldnp->key) & (size-1);
+      h = strhash(oldnp->key) & (arrSize-1);
       newnp = &(array.tbl[i]);
       if( array.ht[h] ) array.ht[h]->from = &(newnp->next);
       newnp->next = array.ht[h];
@@ -4722,12 +4720,12 @@
 struct symbol **Symbol_arrayof()
 {
   struct symbol **array;
-  int i,size;
+  int i,arrSize;
   if( x2a==0 ) return 0;
-  size = x2a->count;
-  array = (struct symbol **)calloc(size, sizeof(struct symbol *));
+  arrSize = x2a->count;
+  array = (struct symbol **)calloc(arrSize, sizeof(struct symbol *));
   if( array ){
-    for(i=0; i<size; i++) array[i] = x2a->tbl[i].data;
+    for(i=0; i<arrSize; i++) array[i] = x2a->tbl[i].data;
   }
   return array;
 }
@@ -4843,18 +4841,18 @@
   }
   if( x3a->count>=x3a->size ){
     /* Need to make the hash table bigger */
-    int i,size;
+    int i,arrSize;
     struct s_x3 array;
-    array.size = size = x3a->size*2;
+    array.size = arrSize = x3a->size*2;
     array.count = x3a->count;
-    array.tbl = (x3node*)calloc(size, sizeof(x3node) + sizeof(x3node*));
+    array.tbl = (x3node*)calloc(arrSize, sizeof(x3node) + sizeof(x3node*));
     if( array.tbl==0 ) return 0;  /* Fail due to malloc failure */
-    array.ht = (x3node**)&(array.tbl[size]);
-    for(i=0; i<size; i++) array.ht[i] = 0;
+    array.ht = (x3node**)&(array.tbl[arrSize]);
+    for(i=0; i<arrSize; i++) array.ht[i] = 0;
     for(i=0; i<x3a->count; i++){
       x3node *oldnp, *newnp;
       oldnp = &(x3a->tbl[i]);
-      h = statehash(oldnp->key) & (size-1);
+      h = statehash(oldnp->key) & (arrSize-1);
       newnp = &(array.tbl[i]);
       if( array.ht[h] ) array.ht[h]->from = &(newnp->next);
       newnp->next = array.ht[h];
@@ -4901,12 +4899,12 @@
 struct state **State_arrayof()
 {
   struct state **array;
-  int i,size;
+  int i,arrSize;
   if( x3a==0 ) return 0;
-  size = x3a->count;
-  array = (struct state **)calloc(size, sizeof(struct state *));
+  arrSize = x3a->count;
+  array = (struct state **)calloc(arrSize, sizeof(struct state *));
   if( array ){
-    for(i=0; i<size; i++) array[i] = x3a->tbl[i].data;
+    for(i=0; i<arrSize; i++) array[i] = x3a->tbl[i].data;
   }
   return array;
 }
@@ -4983,18 +4981,18 @@
   }
   if( x4a->count>=x4a->size ){
     /* Need to make the hash table bigger */
-    int i,size;
+    int i,arrSize;
     struct s_x4 array;
-    array.size = size = x4a->size*2;
+    array.size = arrSize = x4a->size*2;
     array.count = x4a->count;
-    array.tbl = (x4node*)calloc(size, sizeof(x4node) + sizeof(x4node*));
+    array.tbl = (x4node*)calloc(arrSize, sizeof(x4node) + sizeof(x4node*));
     if( array.tbl==0 ) return 0;  /* Fail due to malloc failure */
-    array.ht = (x4node**)&(array.tbl[size]);
-    for(i=0; i<size; i++) array.ht[i] = 0;
+    array.ht = (x4node**)&(array.tbl[arrSize]);
+    for(i=0; i<arrSize; i++) array.ht[i] = 0;
     for(i=0; i<x4a->count; i++){
       x4node *oldnp, *newnp;
       oldnp = &(x4a->tbl[i]);
-      h = confighash(oldnp->data) & (size-1);
+      h = confighash(oldnp->data) & (arrSize-1);
       newnp = &(array.tbl[i]);
       if( array.ht[h] ) array.ht[h]->from = &(newnp->next);
       newnp->next = array.ht[h];
diff --git a/tool/mkvsix.tcl b/tool/mkvsix.tcl
index 208ce2b..15ae2b0 100644
--- a/tool/mkvsix.tcl
+++ b/tool/mkvsix.tcl
@@ -174,6 +174,9 @@
   return ""
 }
 
+#
+# TODO: Modify this procedure when a new version of Visual Studio is released.
+#
 proc getMinVsVersionXmlChunk { vsVersion } {
   switch -exact $vsVersion {
     2012 {
@@ -184,17 +187,26 @@
       return [appendArgs \
           "\r\n    " {MinVSVersion="12.0"}]
     }
+    2015 {
+      return [appendArgs \
+          "\r\n    " {MinVSVersion="14.0"}]
+    }
     default {
       return ""
     }
   }
 }
 
+#
+# TODO: Modify this procedure when a new version of Visual Studio is released.
+#
 proc getMaxPlatformVersionXmlChunk { packageFlavor vsVersion } {
   #
-  # NOTE: Only Visual Studio 2013 supports this SDK manifest attribute.
+  # NOTE: Only Visual Studio 2013 and later support this attribute within the
+  #       SDK manifest.
   #
-  if {![string equal $vsVersion 2013]} then {
+  if {![string equal $vsVersion 2013] && \
+      ![string equal $vsVersion 2015]} then {
     return ""
   }
 
@@ -221,6 +233,9 @@
   }
 }
 
+#
+# TODO: Modify this procedure when a new version of Visual Studio is released.
+#
 proc getExtraFileListXmlChunk { packageFlavor vsVersion } {
   #
   # NOTE: Windows Phone 8.0 does not require any extra attributes in its VSIX
@@ -245,6 +260,14 @@
           "\r\n    " AppliesTo=\" $appliesTo \" \
           "\r\n    " {DependsOn="Microsoft.VCLibs, version=12.0"}]
     }
+    2015 {
+      #
+      # TODO: Is the ".AppLocal" suffix always needed here?
+      #
+      return [appendArgs \
+          "\r\n    " AppliesTo=\" $appliesTo \" \
+          "\r\n    " {DependsOn="Microsoft.VCLibs.AppLocal, version=14.0"}]
+    }
     default {
       return ""
     }
@@ -354,10 +377,11 @@
   fail "invalid Visual Studio version"
 }
 
-if {![string equal $vsVersion 2012] && ![string equal $vsVersion 2013]} then {
+if {![string equal $vsVersion 2012] && ![string equal $vsVersion 2013] && \
+    ![string equal $vsVersion 2015]} then {
   fail [appendArgs \
       "unsupported Visual Studio version, must be one of: " \
-      [list 2012 2013]]
+      [list 2012 2013 2015]]
 }
 
 set shortNames(WinRT,2012) SQLite.WinRT
@@ -368,6 +392,7 @@
 set shortNames(WP81,2013) SQLite.WP81
 set shortNames(Win32,2012) SQLite.Win32
 set shortNames(Win32,2013) SQLite.Win32.2013
+set shortNames(UAP,2015) SQLite.UAP.2015
 
 set displayNames(WinRT,2012) "SQLite for Windows Runtime"
 set displayNames(WinRT,2013) "SQLite for Windows Runtime"
@@ -377,6 +402,7 @@
 set displayNames(WP81,2013) "SQLite for Windows Phone 8.1"
 set displayNames(Win32,2012) "SQLite for Windows"
 set displayNames(Win32,2013) "SQLite for Windows"
+set displayNames(UAP,2015) "SQLite for Universal App Platform"
 
 if {[string equal $packageFlavor WinRT]} then {
   set shortName $shortNames($packageFlavor,$vsVersion)
@@ -432,6 +458,22 @@
   set extraSdkPath "\\..\\$targetPlatformIdentifier"
   set extraFileListAttributes \
       [getExtraFileListXmlChunk $packageFlavor $vsVersion]
+} elseif {[string equal $packageFlavor UAP]} then {
+  if {$vsVersion ne "2015"} then {
+    fail [appendArgs \
+        "unsupported combination, package flavor " $packageFlavor \
+        " is only supported with Visual Studio 2015"]
+  }
+  set shortName $shortNames($packageFlavor,$vsVersion)
+  set displayName $displayNames($packageFlavor,$vsVersion)
+  set targetPlatformIdentifier UAP
+  set targetPlatformVersion v0.8.0.0
+  set minVsVersion [getMinVsVersionXmlChunk $vsVersion]
+  set maxPlatformVersion \
+      [getMaxPlatformVersionXmlChunk $packageFlavor $vsVersion]
+  set extraSdkPath "\\..\\$targetPlatformIdentifier"
+  set extraFileListAttributes \
+      [getExtraFileListXmlChunk $packageFlavor $vsVersion]
 } elseif {[string equal $packageFlavor Win32]} then {
   set shortName $shortNames($packageFlavor,$vsVersion)
   set displayName $displayNames($packageFlavor,$vsVersion)
@@ -446,7 +488,7 @@
 } else {
   fail [appendArgs \
       "unsupported package flavor, must be one of: " \
-      [list WinRT WinRT81 WP80 WP81 Win32]]
+      [list WinRT WinRT81 WP80 WP81 UAP Win32]]
 }
 
 ###############################################################################