Fossil: Check-in [c2faa14d85]

Fossil SCM

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

Overview
Comment:Proposed fix for compiler warning: passing argument 4 of ‘sqlite3_result_text’ from incompatible pointer type
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | svn-import
Files: files | file ages | folders
SHA1:c2faa14d85ba236babb10a752f440b6b24db68ee
User & Date: jan.nijtmans 2014-11-07 11:52:56
Context
2014-12-09
10:34
merge trunk check-in: c9dae7ab66 user: jan.nijtmans tags: svn-import
2014-11-07
11:52
Proposed fix for compiler warning: passing argument 4 of ‘sqlite3_result_text’ from incompatible pointer type check-in: c2faa14d85 user: jan.nijtmans tags: svn-import
2014-11-06
15:38
fix some memory leaks check-in: 412030b145 user: baruch tags: svn-import
Changes

Changes to src/import.c.

718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
...
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
...
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
....
1184
1185
1186
1187
1188
1189
1190

1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
....
1229
1230
1231
1232
1233
1234
1235

1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
  fossil_fatal("bad fast-import line: [%s]", zLine);
  return;
}

static struct{
  int rev;                    /* SVN revision number */
  int parentRev;              /* SVN revision number of parent check-in */
  const char *zParentBranch;  /* Name of branch of parent check-in */
  const char *zBranch;        /* Name of a branch for a commit */
  const char *zDate;          /* Date/time stamp */
  const char *zUser;          /* User name */
  const char *zComment;       /* Comment of a commit */
  int flatFlag;               /* True if whole repo is a single file tree */
  const char *zTrunk;         /* Name of trunk folder in repo root */
  int lenTrunk;               /* String length of zTrunk */
  const char *zBranches;      /* Name of branches folder in repo root */
  int lenBranches;            /* String length of zBranches */
  const char *zTags;          /* Name of tags folder in repo root */
  int lenTags;                /* String length of zTags */
  Blob filter;                /* Path to repo root */
} gsvn;
typedef struct {
  const char *zKey;
  const char *zVal;
} KeyVal;
typedef struct {
  KeyVal *aHeaders;
  int nHeaders;
  char *pRawProps;
  KeyVal *aProps;
................................................................................
  static Stmt qParent;
  static Stmt qParent2;
  static Stmt qFiles;
  static Stmt qTags;
  int nBaseFilter;
  int nFilter;
  int rid;
  const char *zParentBranch = 0;
  Blob mcksum;

  blob_zero(&manifest);
  nBaseFilter = blob_size(&gsvn.filter);
  if( !gsvn.flatFlag ){
    if( gsvn.zBranch==0 ){ return; }
    if( strncmp(gsvn.zBranch, gsvn.zTrunk, gsvn.lenTrunk-1)==0 ){
................................................................................
  }
  nFilter = blob_size(&gsvn.filter)-1;
  db_bind_text(&qFiles, ":filter", blob_str(&gsvn.filter));
  while( db_step(&qFiles)==SQLITE_ROW ){
    const char *zFile = db_column_text(&qFiles, 0);
    int rid = db_column_int(&qFiles, 1);
    const char *zPerm = db_column_text(&qFiles, 2);
    const char *zUuid;
    zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid);
    blob_appendf(&manifest, "F %F %s %s\n", zFile+nFilter, zUuid, zPerm);
    fossil_free(zUuid);
  }
  db_reset(&qFiles);
  if( gsvn.parentRev>=0 ){
    const char *zParentUuid;
................................................................................
    " SELECT :rev, tpath, NULL, NULL"
    " FROM xfiles WHERE (tpath>:path||'/' AND tpath<:path||'0') OR tpath=:path"
  );
  gsvn.rev = -1;
  while( svn_read_rec(pIn, &rec) ){
    if( (zTemp = svn_find_header(rec, "Revision-number")) ){ /* revision node */
      /* finish previous revision */

      if( bHasFiles ){
        svn_create_manifest();
      }
      fossil_free(gsvn.zUser);
      fossil_free(gsvn.zComment);
      fossil_free(gsvn.zDate);
      fossil_free(gsvn.zBranch);
      fossil_free(gsvn.zParentBranch);
      /* start new revision */
      gsvn.rev = atoi(zTemp);
      gsvn.zUser = mprintf("%s", svn_find_prop(rec, "svn:author"));
      gsvn.zComment = mprintf("%s", svn_find_prop(rec, "svn:log"));
      gsvn.zDate = svn_find_prop(rec, "svn:date");
      if( gsvn.zDate ){
        gsvn.zDate = date_in_standard_format(gsvn.zDate);
      }
      gsvn.parentRev = -1;
      gsvn.zParentBranch = 0;
      gsvn.zBranch = 0;
      bHasFiles = 0;
      fossil_print("\rImporting SVN revision: %d", gsvn.rev);
      db_bind_int(&addHist, ":rev", gsvn.rev);
................................................................................
        if( zTemp ){
          srcRev = atoi(zTemp);
        }else{
          fossil_fatal("Missing copyfrom-rev");
        }
      }
      if( !gsvn.flatFlag ){

        if( (zTemp=svn_extract_branch(zPath))!=0 ){
          if( gsvn.zBranch!=0 ){
            if( strcmp(zTemp, gsvn.zBranch)!=0
             && strncmp(zAction, "delete", 6)!=0)
            {
              fossil_fatal("Commit to multiple branches");
            }
            fossil_free(zTemp);
          }else{
            gsvn.zBranch = zTemp;
          }
        }
      }
      if( strncmp(zAction, "delete", 6)==0
       || strncmp(zAction, "replace", 7)==0 )
      {
        db_bind_text(&delPath, ":path", zPath);







|
|
|
|
|










|







 







|







 







|







 







>












|
|
|







 







>
|

|




|

|







718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
...
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
...
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
....
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
....
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
  fossil_fatal("bad fast-import line: [%s]", zLine);
  return;
}

static struct{
  int rev;                    /* SVN revision number */
  int parentRev;              /* SVN revision number of parent check-in */
  char *zParentBranch;        /* Name of branch of parent check-in */
  char *zBranch;              /* Name of a branch for a commit */
  char *zDate;                /* Date/time stamp */
  char *zUser;                /* User name */
  char *zComment;             /* Comment of a commit */
  int flatFlag;               /* True if whole repo is a single file tree */
  const char *zTrunk;         /* Name of trunk folder in repo root */
  int lenTrunk;               /* String length of zTrunk */
  const char *zBranches;      /* Name of branches folder in repo root */
  int lenBranches;            /* String length of zBranches */
  const char *zTags;          /* Name of tags folder in repo root */
  int lenTags;                /* String length of zTags */
  Blob filter;                /* Path to repo root */
} gsvn;
typedef struct {
  char *zKey;
  const char *zVal;
} KeyVal;
typedef struct {
  KeyVal *aHeaders;
  int nHeaders;
  char *pRawProps;
  KeyVal *aProps;
................................................................................
  static Stmt qParent;
  static Stmt qParent2;
  static Stmt qFiles;
  static Stmt qTags;
  int nBaseFilter;
  int nFilter;
  int rid;
  char *zParentBranch = 0;
  Blob mcksum;

  blob_zero(&manifest);
  nBaseFilter = blob_size(&gsvn.filter);
  if( !gsvn.flatFlag ){
    if( gsvn.zBranch==0 ){ return; }
    if( strncmp(gsvn.zBranch, gsvn.zTrunk, gsvn.lenTrunk-1)==0 ){
................................................................................
  }
  nFilter = blob_size(&gsvn.filter)-1;
  db_bind_text(&qFiles, ":filter", blob_str(&gsvn.filter));
  while( db_step(&qFiles)==SQLITE_ROW ){
    const char *zFile = db_column_text(&qFiles, 0);
    int rid = db_column_int(&qFiles, 1);
    const char *zPerm = db_column_text(&qFiles, 2);
    char *zUuid;
    zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid);
    blob_appendf(&manifest, "F %F %s %s\n", zFile+nFilter, zUuid, zPerm);
    fossil_free(zUuid);
  }
  db_reset(&qFiles);
  if( gsvn.parentRev>=0 ){
    const char *zParentUuid;
................................................................................
    " SELECT :rev, tpath, NULL, NULL"
    " FROM xfiles WHERE (tpath>:path||'/' AND tpath<:path||'0') OR tpath=:path"
  );
  gsvn.rev = -1;
  while( svn_read_rec(pIn, &rec) ){
    if( (zTemp = svn_find_header(rec, "Revision-number")) ){ /* revision node */
      /* finish previous revision */
      const char *zDate = NULL;
      if( bHasFiles ){
        svn_create_manifest();
      }
      fossil_free(gsvn.zUser);
      fossil_free(gsvn.zComment);
      fossil_free(gsvn.zDate);
      fossil_free(gsvn.zBranch);
      fossil_free(gsvn.zParentBranch);
      /* start new revision */
      gsvn.rev = atoi(zTemp);
      gsvn.zUser = mprintf("%s", svn_find_prop(rec, "svn:author"));
      gsvn.zComment = mprintf("%s", svn_find_prop(rec, "svn:log"));
      zDate = svn_find_prop(rec, "svn:date");
      if( zDate ){
        gsvn.zDate = date_in_standard_format(zDate);
      }
      gsvn.parentRev = -1;
      gsvn.zParentBranch = 0;
      gsvn.zBranch = 0;
      bHasFiles = 0;
      fossil_print("\rImporting SVN revision: %d", gsvn.rev);
      db_bind_int(&addHist, ":rev", gsvn.rev);
................................................................................
        if( zTemp ){
          srcRev = atoi(zTemp);
        }else{
          fossil_fatal("Missing copyfrom-rev");
        }
      }
      if( !gsvn.flatFlag ){
        char *zBranch;
        if( (zBranch=svn_extract_branch(zPath))!=0 ){
          if( gsvn.zBranch!=0 ){
            if( strcmp(zBranch, gsvn.zBranch)!=0
             && strncmp(zAction, "delete", 6)!=0)
            {
              fossil_fatal("Commit to multiple branches");
            }
            fossil_free(zBranch);
          }else{
            gsvn.zBranch = zBranch;
          }
        }
      }
      if( strncmp(zAction, "delete", 6)==0
       || strncmp(zAction, "replace", 7)==0 )
      {
        db_bind_text(&delPath, ":path", zPath);

Changes to src/util.c.

46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
** Malloc and free routines that cannot fail
*/
void *fossil_malloc(size_t n){
  void *p = malloc(n==0 ? 1 : n);
  if( p==0 ) fossil_panic("out of memory");
  return p;
}
void fossil_free(const void *p){
  free((void*)p);
}
void *fossil_realloc(void *p, size_t n){
  p = realloc(p, n);
  if( p==0 ) fossil_panic("out of memory");
  return p;
}








|
|







46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
** Malloc and free routines that cannot fail
*/
void *fossil_malloc(size_t n){
  void *p = malloc(n==0 ? 1 : n);
  if( p==0 ) fossil_panic("out of memory");
  return p;
}
void fossil_free(void *p){
  free(p);
}
void *fossil_realloc(void *p, size_t n){
  p = realloc(p, n);
  if( p==0 ) fossil_panic("out of memory");
  return p;
}