diff options
| author | Hans-Christoph Steiner <hans@eds.org> | 2013-01-17 14:18:26 -0500 | 
|---|---|---|
| committer | Hans-Christoph Steiner <hans@eds.org> | 2013-01-17 14:18:26 -0500 | 
| commit | 1b5ba8e022836fa8ab93bc90df1b34a29ea6e134 (patch) | |
| tree | e2a832468ccbf52965f18c37b3c4e692fe97ed06 /tool | |
| parent | 487e15dc239ccdb3344d1c99ce120e872bab4a74 (diff) | |
Imported Upstream version 2.1.1
Diffstat (limited to 'tool')
| -rwxr-xr-x | tool/build-all-msvc.bat | 394 | ||||
| -rw-r--r-- | tool/checkSpacing.c | 84 | ||||
| -rw-r--r-- | tool/lemon.c | 82 | ||||
| -rw-r--r-- | tool/mksqlite3c-noext.tcl | 3 | ||||
| -rw-r--r-- | tool/mksqlite3c.tcl | 5 | ||||
| -rw-r--r-- | tool/mksqlite3internalh.tcl | 1 | ||||
| -rw-r--r-- | tool/mkvsix.tcl | 419 | ||||
| -rw-r--r-- | tool/omittest.tcl | 8 | ||||
| -rw-r--r-- | tool/warnings-clang.sh | 2 | ||||
| -rw-r--r-- | tool/win/sqlite.vsix | bin | 0 -> 32802 bytes | 
10 files changed, 945 insertions, 53 deletions
diff --git a/tool/build-all-msvc.bat b/tool/build-all-msvc.bat new file mode 100755 index 0000000..a2d7dae --- /dev/null +++ b/tool/build-all-msvc.bat @@ -0,0 +1,394 @@ +@ECHO OFF
 +
 +::
 +:: build-all-msvc.bat --
 +::
 +:: Multi-Platform Build Tool for MSVC
 +::
 +
 +SETLOCAL
 +
 +REM SET __ECHO=ECHO
 +REM SET __ECHO2=ECHO
 +IF NOT DEFINED _AECHO (SET _AECHO=REM)
 +IF NOT DEFINED _CECHO (SET _CECHO=REM)
 +IF NOT DEFINED _VECHO (SET _VECHO=REM)
 +
 +%_AECHO% Running %0 %*
 +
 +REM SET DFLAGS=/L
 +
 +%_VECHO% DFlags = '%DFLAGS%'
 +
 +SET FFLAGS=/V /F /G /H /I /R /Y /Z
 +
 +%_VECHO% FFlags = '%FFLAGS%'
 +
 +SET ROOT=%~dp0\..
 +SET ROOT=%ROOT:\\=\%
 +
 +%_VECHO% Root = '%ROOT%'
 +
 +REM
 +REM NOTE: The first and only argument to this batch file should be the output
 +REM       directory where the platform-specific binary directories should be
 +REM       created.
 +REM
 +SET BINARYDIRECTORY=%1
 +
 +IF NOT DEFINED BINARYDIRECTORY (
 +  GOTO usage
 +)
 +
 +%_VECHO% BinaryDirectory = '%BINARYDIRECTORY%'
 +
 +SET DUMMY=%2
 +
 +IF DEFINED DUMMY (
 +  GOTO usage
 +)
 +
 +REM
 +REM NOTE: From this point, we need a clean error level.  Reset it now.
 +REM
 +CALL :fn_ResetErrorLevel
 +
 +REM
 +REM NOTE: Change the current directory to the root of the source tree, saving
 +REM       the current directory on the directory stack.
 +REM
 +%__ECHO2% PUSHD "%ROOT%"
 +
 +IF ERRORLEVEL 1 (
 +  ECHO Could not change directory to "%ROOT%".
 +  GOTO errors
 +)
 +
 +REM
 +REM NOTE: This batch file requires the ComSpec environment variable to be set,
 +REM       typically to something like "C:\Windows\System32\cmd.exe".
 +REM
 +IF NOT DEFINED ComSpec (
 +  ECHO The ComSpec environment variable must be defined.
 +  GOTO errors
 +)
 +
 +REM
 +REM NOTE: This batch file requires the VcInstallDir environment variable to be
 +REM       set.  Tyipcally, this means this batch file needs to be run from an
 +REM       MSVC command prompt.
 +REM
 +IF NOT DEFINED VCINSTALLDIR (
 +  ECHO The VCINSTALLDIR environment variable must be defined.
 +  GOTO errors
 +)
 +
 +REM
 +REM NOTE: If the list of platforms is not already set, use the default list.
 +REM
 +IF NOT DEFINED PLATFORMS (
 +  SET PLATFORMS=x86 x86_amd64 x86_arm
 +)
 +
 +%_VECHO% Platforms = '%PLATFORMS%'
 +
 +REM
 +REM NOTE: Setup environment variables to translate between the MSVC platform
 +REM       names and the names to be used for the platform-specific binary
 +REM       directories.
 +REM
 +SET x86_NAME=x86
 +SET x86_amd64_NAME=x64
 +SET x86_arm_NAME=ARM
 +
 +%_VECHO% x86_Name = '%x86_NAME%'
 +%_VECHO% x86_amd64_Name = '%x86_amd64_NAME%'
 +%_VECHO% x86_arm_Name = '%x86_arm_NAME%'
 +
 +REM
 +REM NOTE: Check for the external tools needed during the build process ^(i.e.
 +REM       those that do not get compiled as part of the build process itself^)
 +REM       along the PATH.
 +REM
 +FOR %%T IN (gawk.exe tclsh85.exe) DO (
 +  SET %%T_PATH=%%~dp$PATH:T
 +)
 +
 +REM
 +REM NOTE: Set the TOOLPATH variable to contain all the directories where the
 +REM       external tools were found in the search above.
 +REM
 +SET TOOLPATH=%gawk.exe_PATH%;%tclsh85.exe_PATH%
 +
 +%_VECHO% ToolPath = '%TOOLPATH%'
 +
 +REM
 +REM NOTE: Check for MSVC 2012 because the Windows SDK directory handling is
 +REM       slightly different for that version.
 +REM
 +IF "%VisualStudioVersion%" == "11.0" (
 +  SET SET_NSDKLIBPATH=1
 +) ELSE (
 +  CALL :fn_UnsetVariable SET_NSDKLIBPATH
 +)
 +
 +REM
 +REM NOTE: This is the outer loop.  There should be exactly one iteration per
 +REM       platform.
 +REM
 +FOR %%P IN (%PLATFORMS%) DO (
 +  REM
 +  REM NOTE: Using the MSVC platform name, lookup the simpler platform name to
 +  REM       be used for the name of the platform-specific binary directory via
 +  REM       the environment variables setup earlier.
 +  REM
 +  CALL :fn_SetVariable %%P_NAME PLATFORMNAME
 +
 +  REM
 +  REM NOTE: This is the inner loop.  There should be exactly one iteration.
 +  REM       This loop is necessary because the PlatformName environment
 +  REM       variable was set above and that value is needed by some of the
 +  REM       commands contained in the inner loop.  If these commands were
 +  REM       directly contained in the outer loop, the PlatformName environment
 +  REM       variable would be stuck with its initial empty value instead.
 +  REM
 +  FOR /F "tokens=2* delims==" %%D IN ('SET PLATFORMNAME') DO (
 +    REM
 +    REM NOTE: Attempt to clean the environment of all variables used by MSVC
 +    REM       and/or Visual Studio.  This block may need to be updated in the
 +    REM       future to account for additional environment variables.
 +    REM
 +    CALL :fn_UnsetVariable DevEnvDir
 +    CALL :fn_UnsetVariable ExtensionSdkDir
 +    CALL :fn_UnsetVariable Framework35Version
 +    CALL :fn_UnsetVariable FrameworkDir
 +    CALL :fn_UnsetVariable FrameworkDir32
 +    CALL :fn_UnsetVariable FrameworkVersion
 +    CALL :fn_UnsetVariable FrameworkVersion32
 +    CALL :fn_UnsetVariable FSHARPINSTALLDIR
 +    CALL :fn_UnsetVariable INCLUDE
 +    CALL :fn_UnsetVariable LIB
 +    CALL :fn_UnsetVariable LIBPATH
 +    CALL :fn_UnsetVariable Platform
 +    REM CALL :fn_UnsetVariable VCINSTALLDIR
 +    CALL :fn_UnsetVariable VSINSTALLDIR
 +    CALL :fn_UnsetVariable WindowsSdkDir
 +    CALL :fn_UnsetVariable WindowsSdkDir_35
 +    CALL :fn_UnsetVariable WindowsSdkDir_old
 +
 +    REM
 +    REM NOTE: Reset the PATH here to the absolute bare minimum required.
 +    REM
 +    SET PATH=%TOOLPATH%;%SystemRoot%\System32;%SystemRoot%
 +
 +    REM
 +    REM NOTE: Launch a nested command shell to perform the following steps:
 +    REM
 +    REM       1. Setup the MSVC environment for this platform using the
 +    REM          official batch file.
 +    REM
 +    REM       2. Make sure that no stale build output files are present.
 +    REM
 +    REM       3. Build the "sqlite3.dll" and "sqlite3.lib" binaries for this
 +    REM          platform.
 +    REM
 +    REM       4. Copy the "sqlite3.dll" and "sqlite3.lib" binaries for this
 +    REM          platform to the platform-specific directory beneath the
 +    REM          binary directory.
 +    REM
 +    "%ComSpec%" /C (
 +      REM
 +      REM NOTE: Attempt to setup the MSVC environment for this platform.
 +      REM
 +      %__ECHO% CALL "%VCINSTALLDIR%\vcvarsall.bat" %%P
 +
 +      IF ERRORLEVEL 1 (
 +        ECHO Failed to call "%VCINSTALLDIR%\vcvarsall.bat" for platform %%P.
 +        GOTO errors
 +      )
 +
 +      REM
 +      REM NOTE: If this batch file is not running in "what-if" mode, check to
 +      REM       be sure we were actually able to setup the MSVC environment as
 +      REM       current versions of their official batch file do not set the
 +      REM       exit code upon failure.
 +      REM
 +      IF NOT DEFINED __ECHO (
 +        IF NOT DEFINED WindowsSdkDir (
 +          ECHO Cannot build, Windows SDK not found for platform %%P.
 +          GOTO errors
 +        )
 +      )
 +
 +      REM
 +      REM NOTE: When using MSVC 2012, the native SDK path cannot simply use
 +      REM       the "lib" sub-directory beneath the location specified in the
 +      REM       WindowsSdkDir environment variable because that location does
 +      REM       not actually contain the necessary library files for x86.
 +      REM       This must be done for each iteration because it relies upon
 +      REM       the WindowsSdkDir environment variable being set by the batch
 +      REM       file used to setup the MSVC environment.
 +      REM
 +      IF DEFINED SET_NSDKLIBPATH (
 +        CALL :fn_SetVariable WindowsSdkDir NSDKLIBPATH
 +        CALL :fn_AppendVariable NSDKLIBPATH \lib\win8\um\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
 +      REM       file, etc.
 +      REM
 +      IF NOT DEFINED NOCLEAN (
 +        %__ECHO% nmake -f Makefile.msc clean
 +
 +        IF ERRORLEVEL 1 (
 +          ECHO Failed to clean for platform %%P.
 +          GOTO errors
 +        )
 +      ) ELSE (
 +        REM
 +        REM NOTE: Even when the cleaning step has been disabled, we still need
 +        REM       to remove the build output for the files we are specifically
 +        REM       wanting to build for each platform.
 +        REM
 +        %__ECHO% DEL /Q sqlite3.dll sqlite3.lib sqlite3.pdb
 +      )
 +
 +      REM
 +      REM NOTE: Invoke NMAKE with the MSVC makefile to build the "sqlite3.dll"
 +      REM       binary.  The x86 compiler will be used to compile the native
 +      REM       command line tools needed during the build process itself.
 +      REM       Also, disable looking for and/or linking to the native Tcl
 +      REM       runtime library.
 +      REM
 +      %__ECHO% nmake -f Makefile.msc sqlite3.dll "NCC=""%VCINSTALLDIR%\bin\cl.exe""" USE_NATIVE_LIBPATHS=1 NO_TCL=1 %NMAKE_ARGS%
 +
 +      IF ERRORLEVEL 1 (
 +        ECHO Failed to build "sqlite3.dll" for platform %%P.
 +        GOTO errors
 +      )
 +
 +      REM
 +      REM NOTE: Copy the "sqlite3.dll" file to the platform-specific directory
 +      REM       beneath the binary directory.
 +      REM
 +      %__ECHO% XCOPY sqlite3.dll "%BINARYDIRECTORY%\%%D\" %FFLAGS% %DFLAGS%
 +
 +      IF ERRORLEVEL 1 (
 +        ECHO Failed to copy "sqlite3.dll" to "%BINARYDIRECTORY%\%%D\".
 +        GOTO errors
 +      )
 +
 +      REM
 +      REM NOTE: Copy the "sqlite3.lib" file to the platform-specific directory
 +      REM       beneath the binary directory.
 +      REM
 +      %__ECHO% XCOPY sqlite3.lib "%BINARYDIRECTORY%\%%D\" %FFLAGS% %DFLAGS%
 +
 +      IF ERRORLEVEL 1 (
 +        ECHO Failed to copy "sqlite3.lib" to "%BINARYDIRECTORY%\%%D\".
 +        GOTO errors
 +      )
 +
 +      REM
 +      REM NOTE: Copy the "sqlite3.pdb" file to the platform-specific directory
 +      REM       beneath the binary directory unless we are prevented from doing
 +      REM       so.
 +      REM
 +      IF NOT DEFINED NOSYMBOLS (
 +        %__ECHO% XCOPY sqlite3.pdb "%BINARYDIRECTORY%\%%D\" %FFLAGS% %DFLAGS%
 +
 +        IF ERRORLEVEL 1 (
 +          ECHO Failed to copy "sqlite3.pdb" to "%BINARYDIRECTORY%\%%D\".
 +          GOTO errors
 +        )
 +      )
 +    )
 +  )
 +
 +  REM
 +  REM NOTE: Handle any errors generated during the nested command shell.
 +  REM
 +  IF ERRORLEVEL 1 (
 +    GOTO errors
 +  )
 +)
 +
 +REM
 +REM NOTE: Restore the saved current directory from the directory stack.
 +REM
 +%__ECHO2% POPD
 +
 +IF ERRORLEVEL 1 (
 +  ECHO Could not restore directory.
 +  GOTO errors
 +)
 +
 +REM
 +REM NOTE: If we get to this point, we have succeeded.
 +REM
 +GOTO no_errors
 +
 +:fn_ResetErrorLevel
 +  VERIFY > NUL
 +  GOTO :EOF
 +
 +:fn_SetErrorLevel
 +  VERIFY MAYBE 2> NUL
 +  GOTO :EOF
 +
 +:fn_SetVariable
 +  SETLOCAL
 +  IF NOT DEFINED %1 GOTO :EOF
 +  IF "%2" == "" GOTO :EOF
 +  SET __ECHO_CMD=ECHO %%%1%%
 +  FOR /F "delims=" %%V IN ('%__ECHO_CMD%') DO (
 +    SET VALUE=%%V
 +  )
 +  ENDLOCAL && SET %2=%VALUE%
 +  GOTO :EOF
 +
 +:fn_UnsetVariable
 +  IF NOT "%1" == "" (
 +    SET %1=
 +    CALL :fn_ResetErrorLevel
 +  )
 +  GOTO :EOF
 +
 +:fn_AppendVariable
 +  SET __ECHO_CMD=ECHO %%%1%%
 +  IF DEFINED %1 (
 +    FOR /F "delims=" %%V IN ('%__ECHO_CMD%') DO (
 +      SET %1=%%V%~2
 +    )
 +  ) ELSE (
 +    SET %1=%~2
 +  )
 +  SET __ECHO_CMD=
 +  CALL :fn_ResetErrorLevel
 +  GOTO :EOF
 +
 +:usage
 +  ECHO.
 +  ECHO Usage: %~nx0 ^<binaryDirectory^>
 +  ECHO.
 +  GOTO errors
 +
 +:errors
 +  CALL :fn_SetErrorLevel
 +  ENDLOCAL
 +  ECHO.
 +  ECHO Failure, errors were encountered.
 +  GOTO end_of_file
 +
 +:no_errors
 +  CALL :fn_ResetErrorLevel
 +  ENDLOCAL
 +  ECHO.
 +  ECHO Success, no errors were encountered.
 +  GOTO end_of_file
 +
 +:end_of_file
 +%__ECHO% EXIT /B %ERRORLEVEL%
 diff --git a/tool/checkSpacing.c b/tool/checkSpacing.c new file mode 100644 index 0000000..ce38b08 --- /dev/null +++ b/tool/checkSpacing.c @@ -0,0 +1,84 @@ +/* +** This program checks for formatting problems in source code: +** +**    *  Any use of tab characters +**    *  White space at the end of a line +**    *  Blank lines at the end of a file +** +** Any violations are reported. +*/ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#define CR_OK      0x001 +#define WSEOL_OK   0x002 + +static void checkSpacing(const char *zFile, unsigned flags){ +  FILE *in = fopen(zFile, "rb"); +  int i; +  int seenSpace; +  int seenTab; +  int ln = 0; +  int lastNonspace = 0; +  char zLine[2000]; +  if( in==0 ){ +    printf("cannot open %s\n", zFile); +    return; +  } +  while( fgets(zLine, sizeof(zLine), in) ){ +    seenSpace = 0; +    seenTab = 0; +    ln++; +    for(i=0; zLine[i]; i++){ +      if( zLine[i]=='\t' && seenTab==0 ){ +        printf("%s:%d: tab (\\t) character\n", zFile, ln); +        seenTab = 1; +      }else if( zLine[i]=='\r' ){ +        if( (flags & CR_OK)==0 ){ +          printf("%s:%d: carriage-return (\\r) character\n", zFile, ln); +        } +      }else if( zLine[i]==' ' ){ +        seenSpace = 1; +      }else if( zLine[i]!='\n' ){ +        lastNonspace = ln; +        seenSpace = 0; +      } +    } +    if( seenSpace && (flags & WSEOL_OK)==0 ){ +      printf("%s:%d: whitespace at end-of-line\n", zFile, ln); +    } +  } +  fclose(in); +  if( lastNonspace<ln ){ +    printf("%s:%d: blank lines at end of file (%d)\n", +        zFile, ln, ln - lastNonspace); +  } +} + +int main(int argc, char **argv){ +  int i; +  unsigned flags = WSEOL_OK; +  for(i=1; i<argc; i++){ +    const char *z = argv[i]; +    if( z[0]=='-' ){ +      while( z[0]=='-' ) z++; +      if( strcmp(z,"crok")==0 ){ +        flags |= CR_OK; +      }else if( strcmp(z, "wseol")==0 ){ +        flags &= ~WSEOL_OK; +      }else if( strcmp(z, "help")==0 ){ +        printf("Usage: %s [options] FILE ...\n", argv[0]); +        printf("  --crok      Do not report on carriage-returns\n"); +        printf("  --wseol     Complain about whitespace at end-of-line\n"); +        printf("  --help      This message\n"); +      }else{ +        printf("unknown command-line option: [%s]\n", argv[i]); +        printf("use --help for additional information\n"); +      } +    }else{ +      checkSpacing(argv[i], flags); +    } +  } +  return 0; +} diff --git a/tool/lemon.c b/tool/lemon.c index 5d96995..f63e76f 100644 --- a/tool/lemon.c +++ b/tool/lemon.c @@ -15,7 +15,7 @@  #ifndef __WIN32__  #   if defined(_WIN32) || defined(WIN32) -#	define __WIN32__ +#       define __WIN32__  #   endif  #endif @@ -653,7 +653,7 @@ void FindRulePrecedences(struct lemon *xp)            }          }else if( sp->prec>=0 ){            rp->precsym = rp->rhs[i]; -	} +        }        }      }    } @@ -711,12 +711,12 @@ void FindFirstSets(struct lemon *lemp)              progress += SetAdd(s1->firstset,s2->subsym[j]->index);            }            break; -	}else if( s1==s2 ){ +        }else if( s1==s2 ){            if( s1->lambda==LEMON_FALSE ) break; -	}else{ +        }else{            progress += SetUnion(s1->firstset,s2->firstset);            if( s2->lambda==LEMON_FALSE ) break; -	} +        }        }      }    }while( progress ); @@ -959,8 +959,8 @@ void FindFollowSets(struct lemon *lemp)            if( change ){              plp->cfp->status = INCOMPLETE;              progress = 1; -	  } -	} +          } +        }          cfp->status = COMPLETE;        }      } @@ -993,7 +993,7 @@ void FindActions(struct lemon *lemp)              ** rule "cfp->rp" if the lookahead symbol is "lemp->symbols[j]" */              Action_add(&stp->ap,REDUCE,lemp->symbols[j],(char *)cfp->rp);            } -	} +        }        }      }    } @@ -1262,11 +1262,11 @@ void Configlist_closure(struct lemon *lemp)                SetAdd(newcfp->fws, xsp->subsym[k]->index);              }              break; -	  }else{ +          }else{              SetUnion(newcfp->fws,xsp->firstset);              if( xsp->lambda==LEMON_FALSE ) break; -	  } -	} +          } +        }          if( i==rp->nrhs ) Plink_add(&cfp->fplp,newcfp);        }      } @@ -1996,7 +1996,7 @@ static void parseonetoken(struct pstate *psp)  "There is no prior rule upon which to attach the code \  fragment which begins on this line.");            psp->errorcnt++; -	}else if( psp->prevrule->code!=0 ){ +        }else if( psp->prevrule->code!=0 ){            ErrorMsg(psp->filename,psp->tokenlineno,  "Code fragment beginning on this line is not the first \  to follow the previous rule."); @@ -2004,7 +2004,7 @@ to follow the previous rule.");          }else{            psp->prevrule->line = psp->tokenlineno;            psp->prevrule->code = &x[1]; -	} +        }        }else if( x[0]=='[' ){          psp->state = PRECEDENCE_MARK_1;        }else{ @@ -2097,7 +2097,7 @@ to follow the previous rule.");              "Can't allocate enough memory for this rule.");            psp->errorcnt++;            psp->prevrule = 0; -	}else{ +        }else{            int i;            rp->ruleline = psp->tokenlineno;            rp->rhs = (struct symbol**)&rp[1]; @@ -2105,7 +2105,7 @@ to follow the previous rule.");            for(i=0; i<psp->nrhs; i++){              rp->rhs[i] = psp->rhs[i];              rp->rhsalias[i] = psp->alias[i]; -	  } +          }            rp->lhs = psp->lhs;            rp->lhsalias = psp->lhsalias;            rp->nrhs = psp->nrhs; @@ -2117,12 +2117,12 @@ to follow the previous rule.");            rp->next = 0;            if( psp->firstrule==0 ){              psp->firstrule = psp->lastrule = rp; -	  }else{ +          }else{              psp->lastrule->next = rp;              psp->lastrule = rp; -	  } +          }            psp->prevrule = rp; -	} +        }          psp->state = WAITING_FOR_DECL_OR_RULE;        }else if( isalpha(x[0]) ){          if( psp->nrhs>=MAXRHS ){ @@ -2131,11 +2131,11 @@ to follow the previous rule.");              x);            psp->errorcnt++;            psp->state = RESYNC_AFTER_RULE_ERROR; -	}else{ +        }else{            psp->rhs[psp->nrhs] = Symbol_new(x);            psp->alias[psp->nrhs] = 0;            psp->nrhs++; -	} +        }        }else if( (x[0]=='|' || x[0]=='/') && psp->nrhs>0 ){          struct symbol *msp = psp->rhs[psp->nrhs-1];          if( msp->type!=MULTITERMINAL ){ @@ -2199,24 +2199,24 @@ to follow the previous rule.");          if( strcmp(x,"name")==0 ){            psp->declargslot = &(psp->gp->name);            psp->insertLineMacro = 0; -	}else if( strcmp(x,"include")==0 ){ +        }else if( strcmp(x,"include")==0 ){            psp->declargslot = &(psp->gp->include); -	}else if( strcmp(x,"code")==0 ){ +        }else if( strcmp(x,"code")==0 ){            psp->declargslot = &(psp->gp->extracode); -	}else if( strcmp(x,"token_destructor")==0 ){ +        }else if( strcmp(x,"token_destructor")==0 ){            psp->declargslot = &psp->gp->tokendest; -	}else if( strcmp(x,"default_destructor")==0 ){ +        }else if( strcmp(x,"default_destructor")==0 ){            psp->declargslot = &psp->gp->vardest; -	}else if( strcmp(x,"token_prefix")==0 ){ +        }else if( strcmp(x,"token_prefix")==0 ){            psp->declargslot = &psp->gp->tokenprefix;            psp->insertLineMacro = 0; -	}else if( strcmp(x,"syntax_error")==0 ){ +        }else if( strcmp(x,"syntax_error")==0 ){            psp->declargslot = &(psp->gp->error); -	}else if( strcmp(x,"parse_accept")==0 ){ +        }else if( strcmp(x,"parse_accept")==0 ){            psp->declargslot = &(psp->gp->accept); -	}else if( strcmp(x,"parse_failure")==0 ){ +        }else if( strcmp(x,"parse_failure")==0 ){            psp->declargslot = &(psp->gp->failure); -	}else if( strcmp(x,"stack_overflow")==0 ){ +        }else if( strcmp(x,"stack_overflow")==0 ){            psp->declargslot = &(psp->gp->overflow);          }else if( strcmp(x,"extra_argument")==0 ){            psp->declargslot = &(psp->gp->arg); @@ -2245,9 +2245,9 @@ to follow the previous rule.");            psp->preccounter++;            psp->declassoc = NONE;            psp->state = WAITING_FOR_PRECEDENCE_SYMBOL; -	}else if( strcmp(x,"destructor")==0 ){ +        }else if( strcmp(x,"destructor")==0 ){            psp->state = WAITING_FOR_DESTRUCTOR_SYMBOL; -	}else if( strcmp(x,"type")==0 ){ +        }else if( strcmp(x,"type")==0 ){            psp->state = WAITING_FOR_DATATYPE_SYMBOL;          }else if( strcmp(x,"fallback")==0 ){            psp->fallback = 0; @@ -2259,7 +2259,7 @@ to follow the previous rule.");              "Unknown declaration keyword: \"%%%s\".",x);            psp->errorcnt++;            psp->state = RESYNC_AFTER_DECL_ERROR; -	} +        }        }else{          ErrorMsg(psp->filename,psp->tokenlineno,            "Illegal declaration keyword: \"%s\".",x); @@ -2314,10 +2314,10 @@ to follow the previous rule.");            ErrorMsg(psp->filename,psp->tokenlineno,              "Symbol \"%s\" has already be given a precedence.",x);            psp->errorcnt++; -	}else{ +        }else{            sp->prec = psp->preccounter;            sp->assoc = psp->declassoc; -	} +        }        }else{          ErrorMsg(psp->filename,psp->tokenlineno,            "Can't assign a precedence to \"%s\".",x); @@ -2587,12 +2587,12 @@ void Parse(struct lemon *gp)              if( c=='\n' ) lineno++;              prevc = c;              cp++; -	  } -	}else if( c=='/' && cp[1]=='/' ){  /* Skip C++ style comments too */ +          } +        }else if( c=='/' && cp[1]=='/' ){  /* Skip C++ style comments too */            cp = &cp[2];            while( (c= *cp)!=0 && c!='\n' ) cp++;            if( c ) lineno++; -	}else if( c=='\'' || c=='\"' ){    /* String a character literals */ +        }else if( c=='\'' || c=='\"' ){    /* String a character literals */            int startchar, prevc;            startchar = c;            prevc = 0; @@ -2600,8 +2600,8 @@ void Parse(struct lemon *gp)              if( c=='\n' ) lineno++;              if( prevc=='\\' ) prevc = 0;              else              prevc = c; -	  } -	} +          } +        }        }        if( c==0 ){          ErrorMsg(ps.filename,ps.tokenlineno, @@ -4021,12 +4021,14 @@ void ReportHeader(struct lemon *lemp)    else                    prefix = "";    in = file_open(lemp,".h","rb");    if( in ){ +    int nextChar;      for(i=1; i<lemp->nterminal && fgets(line,LINESIZE,in); i++){        sprintf(pattern,"#define %s%-30s %2d\n",prefix,lemp->symbols[i]->name,i);        if( strcmp(line,pattern) ) break;      } +    nextChar = fgetc(in);      fclose(in); -    if( i==lemp->nterminal ){ +    if( i==lemp->nterminal && nextChar==EOF ){        /* No change in the file.  Don't rewrite it. */        return;      } diff --git a/tool/mksqlite3c-noext.tcl b/tool/mksqlite3c-noext.tcl index 6ad3023..017ad62 100644 --- a/tool/mksqlite3c-noext.tcl +++ b/tool/mksqlite3c-noext.tcl @@ -100,7 +100,6 @@ foreach hdr {     opcodes.h     os_common.h     os.h -   os_os2.h     pager.h     parse.h     pcache.h @@ -233,7 +232,6 @@ foreach file {     mem5.c     mutex.c     mutex_noop.c -   mutex_os2.c     mutex_unix.c     mutex_w32.c     malloc.c @@ -244,7 +242,6 @@ foreach file {     hash.c     opcodes.c -   os_os2.c     os_unix.c     os_win.c diff --git a/tool/mksqlite3c.tcl b/tool/mksqlite3c.tcl index 09ebb7c..deb20a9 100644 --- a/tool/mksqlite3c.tcl +++ b/tool/mksqlite3c.tcl @@ -105,7 +105,6 @@ foreach hdr {     opcodes.h     os_common.h     os.h -   os_os2.h     pager.h     parse.h     pcache.h @@ -242,7 +241,6 @@ foreach file {     mem5.c     mutex.c     mutex_noop.c -   mutex_os2.c     mutex_unix.c     mutex_w32.c     malloc.c @@ -253,7 +251,6 @@ foreach file {     hash.c     opcodes.c -   os_os2.c     os_unix.c     os_win.c @@ -320,6 +317,8 @@ foreach file {     fts3_tokenizer1.c     fts3_write.c     fts3_snippet.c +   fts3_unicode.c +   fts3_unicode2.c     rtree.c     icu.c diff --git a/tool/mksqlite3internalh.tcl b/tool/mksqlite3internalh.tcl index f02a62d..406ef5c 100644 --- a/tool/mksqlite3internalh.tcl +++ b/tool/mksqlite3internalh.tcl @@ -61,7 +61,6 @@ foreach hdr {     opcodes.h     os_common.h     os.h -   os_os2.h     pager.h     parse.h     sqlite3ext.h diff --git a/tool/mkvsix.tcl b/tool/mkvsix.tcl new file mode 100644 index 0000000..a751778 --- /dev/null +++ b/tool/mkvsix.tcl @@ -0,0 +1,419 @@ +#!/usr/bin/tclsh +# +# This script is used to generate a VSIX (Visual Studio Extension) file for +# SQLite usable by Visual Studio. + +proc fail { {error ""} {usage false} } { +  if {[string length $error] > 0} then { +    puts stdout $error +    if {!$usage} then {exit 1} +  } + +  puts stdout "usage:\ +[file tail [info nameofexecutable]]\ +[file tail [info script]] <binaryDirectory> \[sourceDirectory\]" + +  exit 1 +} + +proc getEnvironmentVariable { name } { +  # +  # NOTE: Returns the value of the specified environment variable or an empty +  #       string for environment variables that do not exist in the current +  #       process environment. +  # +  return [expr {[info exists ::env($name)] ? $::env($name) : ""}] +} + +proc getTemporaryPath {} { +  # +  # NOTE: Returns the normalized path to the first temporary directory found +  #       in the typical set of environment variables used for that purpose +  #       or an empty string to signal a failure to locate such a directory. +  # +  set names [list] + +  foreach name [list TEMP TMP] { +    lappend names [string toupper $name] [string tolower $name] \ +        [string totitle $name] +  } + +  foreach name $names { +    set value [getEnvironmentVariable $name] + +    if {[string length $value] > 0} then { +      return [file normalize $value] +    } +  } + +  return "" +} + +proc appendArgs { args } { +  # +  # NOTE: Returns all passed arguments joined together as a single string with +  #       no intervening spaces between arguments. +  # +  eval append result $args +} + +proc readFile { fileName } { +  # +  # NOTE: Reads and returns the entire contents of the specified file, which +  #       may contain binary data. +  # +  set file_id [open $fileName RDONLY] +  fconfigure $file_id -encoding binary -translation binary +  set result [read $file_id] +  close $file_id +  return $result +} + +proc writeFile { fileName data } { +  # +  # NOTE: Writes the entire contents of the specified file, which may contain +  #       binary data. +  # +  set file_id [open $fileName {WRONLY CREAT TRUNC}] +  fconfigure $file_id -encoding binary -translation binary +  puts -nonewline $file_id $data +  close $file_id +  return "" +} + +proc substFile { fileName } { +  # +  # NOTE: Performs all Tcl command, variable, and backslash substitutions in +  #       the specified file and then re-writes the contents of that same file +  #       with the substituted data. +  # +  return [writeFile $fileName [uplevel 1 [list subst [readFile $fileName]]]] +} + +proc replacePlatform { fileName platformName } { +  # +  # NOTE: Returns the specified file name containing the platform name instead +  #       of platform placeholder tokens. +  # +  return [string map [list <platform> $platformName] $fileName] +} + +set script [file normalize [info script]] + +if {[string length $script] == 0} then { +  fail "script file currently being evaluated is unknown" true +} + +set path [file dirname $script] +set rootName [file rootname [file tail $script]] + +############################################################################### + +# +# NOTE: Process and verify all the command line arguments. +# +set argc [llength $argv] +if {$argc != 1 && $argc != 2} then {fail} + +set binaryDirectory [lindex $argv 0] + +if {[string length $binaryDirectory] == 0} then { +  fail "invalid binary directory" +} + +if {![file exists $binaryDirectory] || \ +    ![file isdirectory $binaryDirectory]} then { +  fail "binary directory does not exist" +} + +if {$argc == 2} then { +  set sourceDirectory [lindex $argv 1] +} else { +  # +  # NOTE: Assume that the source directory is the parent directory of the one +  #       that contains this script file. +  # +  set sourceDirectory [file dirname $path] +} + +if {[string length $sourceDirectory] == 0} then { +  fail "invalid source directory" +} + +if {![file exists $sourceDirectory] || \ +    ![file isdirectory $sourceDirectory]} then { +  fail "source directory does not exist" +} + +############################################################################### + +# +# NOTE: Evaluate the user-specific customizations file, if it exists. +# +set userFile [file join $path [appendArgs \ +    $rootName . $tcl_platform(user) .tcl]] + +if {[file exists $userFile] && \ +    [file isfile $userFile]} then { +  source $userFile +} + +############################################################################### + +set templateFile [file join $path win sqlite.vsix] + +if {![file exists $templateFile] || \ +    ![file isfile $templateFile]} then { +  fail [appendArgs "template file \"" $templateFile "\" does not exist"] +} + +set currentDirectory [pwd] +set outputFile [file join $currentDirectory sqlite-output.vsix] + +if {[file exists $outputFile]} then { +  fail [appendArgs "output file \"" $outputFile "\" already exists"] +} + +############################################################################### + +# +# NOTE: Make sure that a valid temporary directory exists. +# +set temporaryDirectory [getTemporaryPath] + +if {[string length $temporaryDirectory] == 0 || \ +    ![file exists $temporaryDirectory] || \ +    ![file isdirectory $temporaryDirectory]} then { +  fail "cannot locate a usable temporary directory" +} + +# +# NOTE: Setup the staging directory to have a unique name inside of the +#       configured temporary directory. +# +set stagingDirectory [file normalize [file join $temporaryDirectory \ +    [appendArgs $rootName . [pid]]]] + +############################################################################### + +# +# NOTE: Configure the external zipping tool.  First, see if it has already +#       been pre-configured.  If not, try to query it from the environment. +#       Finally, fallback on the default of simply "zip", which will then +#       be assumed to exist somewhere along the PATH. +# +if {![info exists zip]} then { +  if {[info exists env(ZipTool)]} then { +    set zip $env(ZipTool) +  } +  if {![info exists zip] || ![file exists $zip]} then { +    set zip zip +  } +} + +# +# NOTE: Configure the external unzipping tool.  First, see if it has already +#       been pre-configured.  If not, try to query it from the environment. +#       Finally, fallback on the default of simply "unzip", which will then +#       be assumed to exist somewhere along the PATH. +# +if {![info exists unzip]} then { +  if {[info exists env(UnZipTool)]} then { +    set unzip $env(UnZipTool) +  } +  if {![info exists unzip] || ![file exists $unzip]} then { +    set unzip unzip +  } +} + +############################################################################### + +# +# NOTE: Attempt to extract the SQLite version from the "sqlite3.h" header file +#       in the source directory.  This script assumes that the header file has +#       already been generated by the build process. +# +set pattern {^#define\s+SQLITE_VERSION\s+"(.*)"$} +set data [readFile [file join $sourceDirectory sqlite3.h]] + +if {![regexp -line -- $pattern $data dummy version]} then { +  fail [appendArgs "cannot locate SQLITE_VERSION value in \"" \ +      [file join $sourceDirectory sqlite3.h] \"] +} + +############################################################################### + +# +# NOTE: Setup the master file list data, including the necessary flags. +# +if {![info exists fileNames(source)]} then { +  set fileNames(source) [list "" "" "" \ +      [file join $sourceDirectory sqlite3.h] \ +      [file join $binaryDirectory <platform> sqlite3.lib] \ +      [file join $binaryDirectory <platform> sqlite3.dll]] + +  if {![info exists no(symbols)]} then { +    lappend fileNames(source) \ +        [file join $binaryDirectory <platform> sqlite3.pdb] +  } +} + +if {![info exists fileNames(destination)]} then { +  set fileNames(destination) [list \ +      [file join $stagingDirectory extension.vsixmanifest] \ +      [file join $stagingDirectory SDKManifest.xml] \ +      [file join $stagingDirectory DesignTime CommonConfiguration \ +          <platform> SQLite.WinRT.props] \ +      [file join $stagingDirectory DesignTime CommonConfiguration \ +          <platform> sqlite3.h] \ +      [file join $stagingDirectory DesignTime CommonConfiguration \ +          <platform> sqlite3.lib] \ +      [file join $stagingDirectory Redist CommonConfiguration \ +          <platform> sqlite3.dll]] + +  if {![info exists no(symbols)]} then { +    lappend fileNames(destination) \ +        [file join $stagingDirectory Redist Debug \ +            <platform> sqlite3.pdb] +  } +} + +if {![info exists fileNames(neutral)]} then { +  set fileNames(neutral) [list 1 1 1 1 0 0] + +  if {![info exists no(symbols)]} then { +    lappend fileNames(neutral) 0 +  } +} + +if {![info exists fileNames(subst)]} then { +  set fileNames(subst) [list 1 1 1 0 0 0] + +  if {![info exists no(symbols)]} then { +    lappend fileNames(subst) 0 +  } +} + +############################################################################### + +# +# NOTE: Setup the list of platforms supported by this script. +# +if {![info exists platformNames]} then { +  set platformNames [list x86 x64 ARM] +} + +############################################################################### + +# +# NOTE: Make sure the staging directory exists, creating it if necessary. +# +file mkdir $stagingDirectory + +# +# NOTE: Build the Tcl command used to extract the template package to the +#       staging directory. +# +set extractCommand [list exec -- $unzip $templateFile -d $stagingDirectory] + +# +# NOTE: Extract the template package to the staging directory. +# +eval $extractCommand + +############################################################################### + +# +# NOTE: Process each file in the master file list.  There are actually four +#       parallel lists that contain the source file names, destination file +#       names, the platform-neutral flags, and the use-subst flags.  When the +#       platform-neutral flag is non-zero, the file is not platform-specific. +#       When the use-subst flag is non-zero, the file is considered to be a +#       text file that may contain Tcl variable and/or command replacements, +#       to be dynamically replaced during processing.  If the source file name +#       is an empty string, then the destination file name will be assumed to +#       already exist in the staging directory and will not be copied; however, +#       dynamic replacements may still be performed on the destination file +#       prior to the package being re-zipped. +# +foreach sourceFileName $fileNames(source) \ +    destinationFileName $fileNames(destination) \ +    isNeutral $fileNames(neutral) useSubst $fileNames(subst) { +  # +  # NOTE: If the current file is platform-neutral, then only one platform will +  #       be processed for it, namely "neutral"; otherwise, each supported +  #       platform will be processed for it individually. +  # +  foreach platformName [expr {$isNeutral ? [list neutral] : $platformNames}] { +    # +    # NOTE: Use the actual platform name in the destination file name. +    # +    set newDestinationFileName [replacePlatform $destinationFileName \ +        $platformName] + +    # +    # NOTE: Does the source file need to be copied to the destination file? +    # +    if {[string length $sourceFileName] > 0} then { +      # +      # NOTE: First, make sure the destination directory exists. +      # +      file mkdir [file dirname $newDestinationFileName] + +      # +      # NOTE: Then, copy the source file to the destination file verbatim. +      # +      file copy [replacePlatform $sourceFileName $platformName] \ +          $newDestinationFileName +    } + +    # +    # NOTE: Does the destination file contain dynamic replacements that must +    #       be processed now? +    # +    if {$useSubst} then { +      # +      # NOTE: Perform any dynamic replacements contained in the destination +      #       file and then re-write it in-place. +      # +      substFile $newDestinationFileName +    } +  } +} + +############################################################################### + +# +# NOTE: Change the current directory to the staging directory so that the +#       external archive building tool can pickup the necessary files using +#       relative paths. +# +cd $stagingDirectory + +# +# NOTE: Build the Tcl command used to archive the final package in the +#       output directory. +# +set archiveCommand [list exec -- $zip -r $outputFile *] + +# +# NOTE: Build the final package archive in the output directory. +# +eval $archiveCommand + +# +# NOTE: Change back to the previously saved current directory. +# +cd $currentDirectory + +# +# NOTE: Cleanup the temporary staging directory. +# +file delete -force $stagingDirectory + +############################################################################### + +# +# NOTE: Success, emit the fully qualified path of the generated VSIX file. +# +puts stdout $outputFile diff --git a/tool/omittest.tcl b/tool/omittest.tcl index 7f13a4c..3351b96 100644 --- a/tool/omittest.tcl +++ b/tool/omittest.tcl @@ -53,8 +53,6 @@ proc run_quick_test {dir omit_symbol_list} {    if {$::tcl_platform(platform)=="windows"} {      append opts "OPTS += -DSQLITE_OS_WIN=1\n"      set target "testfixture.exe" -  } elseif {$::tcl_platform(platform)=="os2"} { -    append opts "OPTS += -DSQLITE_OS_OS2=1\n"    } else {      append opts "OPTS += -DSQLITE_OS_UNIX=1\n"    } @@ -93,7 +91,7 @@ proc run_quick_test {dir omit_symbol_list} {    # of trying to build the sqlite shell. The sqlite shell won't build     # with some of the OMIT options (i.e OMIT_COMPLETE).    set sqlite3_dummy $dir/sqlite3 -  if {$::tcl_platform(platform)=="windows" || $::tcl_platform(platform)=="os2"} { +  if {$::tcl_platform(platform)=="windows"} {      append sqlite3_dummy ".exe"    }    if {![file exists $sqlite3_dummy]} { @@ -127,8 +125,8 @@ proc run_quick_test {dir omit_symbol_list} {  #  proc process_options {argv} {    set ::MAKEBIN make                        ;# Default value -  if {$::tcl_platform(platform)=="windows" || $::tcl_platform(platform)=="os2"} { -    set ::MAKEFILE ./Makefile               ;# Default value on Windows and OS2 +  if {$::tcl_platform(platform)=="windows"} { +    set ::MAKEFILE ./Makefile               ;# Default value on Windows    } else {      set ::MAKEFILE ./Makefile.linux-gcc     ;# Default value    } diff --git a/tool/warnings-clang.sh b/tool/warnings-clang.sh index b0d2fb6..7a0aa4b 100644 --- a/tool/warnings-clang.sh +++ b/tool/warnings-clang.sh @@ -7,7 +7,7 @@ rm -f sqlite3.c  make sqlite3.c  echo '************* FTS4 and RTREE ****************'  scan-build gcc -c -DHAVE_STDINT_H -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_RTREE \ -      -DSQLITE_DEBUG sqlite3.c 2>&1 | grep -v 'ANALYZE:' +      -DSQLITE_DEBUG -DSQLITE_ENABLE_STAT3 sqlite3.c 2>&1 | grep -v 'ANALYZE:'  echo '********** ENABLE_STAT3. THREADSAFE=0 *******'  scan-build gcc -c -I. -DSQLITE_ENABLE_STAT3 -DSQLITE_THREADSAFE=0 \        -DSQLITE_DEBUG \ diff --git a/tool/win/sqlite.vsix b/tool/win/sqlite.vsix Binary files differnew file mode 100644 index 0000000..4bdfda5 --- /dev/null +++ b/tool/win/sqlite.vsix  | 
