/ Check-in [f6ebe1c2]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Work around lack of a C99 feature in MSVC.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | msvc
Files: files | file ages | folders
SHA3-256: f6ebe1c2be91f1f02b2a68fa11d6da981d35771b5ad422e72a64a66ee1084f0d
User & Date: mistachkin 2019-04-17 23:32:17
Context
2019-04-17
23:56
Fix a couple minor test issues. check-in: 1f1866d1 user: mistachkin tags: msvc
23:32
Work around lack of a C99 feature in MSVC. check-in: f6ebe1c2 user: mistachkin tags: msvc
21:12
Small performance and size optimization in sqlite3WalFindFrame(). check-in: 03f2e788 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/shell.c.in.

3854
3855
3856
3857
3858
3859
3860

3861



3862
3863
3864
3865
3866
3867
3868
....
3899
3900
3901
3902
3903
3904
3905

3906






3907
3908
3909
3910
3911
3912
3913
  int nLine;
  int n = 0;
  int pgsz = 0;
  int iOffset = 0;
  int j, k;
  int rc;
  FILE *in;

  unsigned char x[16];



  char zLine[1000];
  if( p->zDbFilename ){
    in = fopen(p->zDbFilename, "r");
    if( in==0 ){
      utf8_printf(stderr, "cannot open \"%s\" for reading\n", p->zDbFilename);
      return 0;
    }
................................................................................
    rc = sscanf(zLine,"| %d: %hhx %hhx %hhx %hhx %hhx %hhx %hhx %hhx"
                      "  %hhx %hhx %hhx %hhx %hhx %hhx %hhx %hhx",
                &j, &x[0], &x[1], &x[2], &x[3], &x[4], &x[5], &x[6], &x[7],
                &x[8], &x[9], &x[10], &x[11], &x[12], &x[13], &x[14], &x[15]);
    if( rc==17 ){
      k = iOffset+j;
      if( k+16<=n ){

        memcpy(a+k, x, 16);






      }
    }
  }
  *pnData = n;
  if( in!=p->in ){
    fclose(in);
  }else{







>

>
>
>







 







>

>
>
>
>
>
>







3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
....
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
  int nLine;
  int n = 0;
  int pgsz = 0;
  int iOffset = 0;
  int j, k;
  int rc;
  FILE *in;
#if !defined(_MSC_VER) || _MSC_VER>=1900
  unsigned char x[16];
#else
  unsigned int x[16];
#endif
  char zLine[1000];
  if( p->zDbFilename ){
    in = fopen(p->zDbFilename, "r");
    if( in==0 ){
      utf8_printf(stderr, "cannot open \"%s\" for reading\n", p->zDbFilename);
      return 0;
    }
................................................................................
    rc = sscanf(zLine,"| %d: %hhx %hhx %hhx %hhx %hhx %hhx %hhx %hhx"
                      "  %hhx %hhx %hhx %hhx %hhx %hhx %hhx %hhx",
                &j, &x[0], &x[1], &x[2], &x[3], &x[4], &x[5], &x[6], &x[7],
                &x[8], &x[9], &x[10], &x[11], &x[12], &x[13], &x[14], &x[15]);
    if( rc==17 ){
      k = iOffset+j;
      if( k+16<=n ){
#if !defined(_MSC_VER) || _MSC_VER>=1900
        memcpy(a+k, x, 16);
#else
        int ii;
        for(ii=0; ii<16; ii++){
          a[k+ii] = (unsigned char)x[ii];
        }
#endif
      }
    }
  }
  *pnData = n;
  if( in!=p->in ){
    fclose(in);
  }else{

Changes to src/test1.c.

7695
7696
7697
7698
7699
7700
7701

7702



7703
7704
7705
7706
7707
7708
7709
....
7734
7735
7736
7737
7738
7739
7740

7741






7742
7743
7744
7745
7746
7747
7748
  unsigned char *a = 0;
  int n = 0;
  int lineno = 0;
  int i, iNext;
  int iOffset = 0;
  int j, k;
  int rc;

  unsigned char x[16];



  if( objc!=2 ){
    Tcl_WrongNumArgs(interp, 1, objv, "HEXDB");
    return TCL_ERROR;
  }
  zIn = Tcl_GetString(objv[1]);
  for(i=0; zIn[i]; i=iNext){
    lineno++;
................................................................................
    rc = sscanf(zIn+i,"| %d: %hhx %hhx %hhx %hhx %hhx %hhx %hhx %hhx"
                      "  %hhx %hhx %hhx %hhx %hhx %hhx %hhx %hhx",
                &j, &x[0], &x[1], &x[2], &x[3], &x[4], &x[5], &x[6], &x[7],
                &x[8], &x[9], &x[10], &x[11], &x[12], &x[13], &x[14], &x[15]);
    if( rc==17 ){
      k = iOffset+j;
      if( k+16<=n ){

        memcpy(a+k, x, 16);






      }
      continue;
    }
  }
  Tcl_SetObjResult(interp, Tcl_NewByteArrayObj(a, n));
  free(a);
  return TCL_OK;







>

>
>
>







 







>

>
>
>
>
>
>







7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
....
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
  unsigned char *a = 0;
  int n = 0;
  int lineno = 0;
  int i, iNext;
  int iOffset = 0;
  int j, k;
  int rc;
#if !defined(_MSC_VER) || _MSC_VER>=1900
  unsigned char x[16];
#else
  unsigned int x[16];
#endif
  if( objc!=2 ){
    Tcl_WrongNumArgs(interp, 1, objv, "HEXDB");
    return TCL_ERROR;
  }
  zIn = Tcl_GetString(objv[1]);
  for(i=0; zIn[i]; i=iNext){
    lineno++;
................................................................................
    rc = sscanf(zIn+i,"| %d: %hhx %hhx %hhx %hhx %hhx %hhx %hhx %hhx"
                      "  %hhx %hhx %hhx %hhx %hhx %hhx %hhx %hhx",
                &j, &x[0], &x[1], &x[2], &x[3], &x[4], &x[5], &x[6], &x[7],
                &x[8], &x[9], &x[10], &x[11], &x[12], &x[13], &x[14], &x[15]);
    if( rc==17 ){
      k = iOffset+j;
      if( k+16<=n ){
#if !defined(_MSC_VER) || _MSC_VER>=1900
        memcpy(a+k, x, 16);
#else
        int ii;
        for(ii=0; ii<16; ii++){
          a[k+ii] = (unsigned char)x[ii];
        }
#endif
      }
      continue;
    }
  }
  Tcl_SetObjResult(interp, Tcl_NewByteArrayObj(a, n));
  free(a);
  return TCL_OK;