Hi,
I just noticed by code review small and easy to fix bug in -vfs option 
handling code.
sqlite3 Tcl command line syntax is following:
sqlite3 HANDLE ?FILENAME ?-vfs VFSNAME? ?-readonly BOOLEAN? ?-create 
BOOLEAN? ?-nomutex BOOLEAN? ?-fullmutex BOOLEAN?
But if -vfs option is in the middle, the following options will not be parsed 
correctly. Here is proposed fix:
- tclsqlite.c / DbMain().
  Wrong code:
    // . . .
    for(i=2; i+1<objc; i+=2){
    zArg = Tcl_GetString(objv[i]);
    if( strcmp(zArg,"-key")==0 ){
      pKey = Tcl_GetByteArrayFromObj(objv[i+1], &nKey);
    }else if( strcmp(zArg, "-vfs")==0 ){
      i++;
      zVfs = Tcl_GetString(objv[i]);
    }else if( strcmp(zArg, "-readonly")==0 ){
    // . . .
  Fixed code:
    // . . .
    for(i=2; i+1<objc; i+=2){
    zArg = Tcl_GetString(objv[i]);
    if( strcmp(zArg,"-key")==0 ){
      pKey = Tcl_GetByteArrayFromObj(objv[i+1], &nKey);
    }else if( strcmp(zArg, "-vfs")==0 ){
      zVfs = Tcl_GetString(objv[i+1]);
    }else if( strcmp(zArg, "-readonly")==0 ){
    // . . .

-----
The other very small bug is in the same place is that -version and -has-codec 
options are not covered by 'usage' message:
- tclsqlite.c / DbMain().
  if( objc<2 ){
    Tcl_WrongNumArgs(interp, 1, objv, 
      "HANDLE ?FILENAME ?-vfs VFSNAME? ?-readonly BOOLEAN? ?-create BOOLEAN?"
      " ?-nomutex BOOLEAN? ?-fullmutex BOOLEAN? ?-gdms-fti BOOLEAN?"
#ifdef SQLITE_HAS_CODEC
      " ?-key CODECKEY?\n"
#else                                    // ADDED BY ME
      "\n"                                  // ADDED BY ME
#endif
      "or\n"                               // ADDED BY ME
      "?-version ?-has-codec"  // ADDED BY ME
    );
    return TCL_ERROR;
  }

Thanks,
Grzegorz W.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to