Fossil

Check-in [233463c4]
Login

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

Overview
Comment:gcc warnings:
src/merge3.c: In function ‘merge_3way’:
src/merge3.c:445:9: warning: ‘zPivot’ may be used uninitialized in this function
src/merge3.c:446:9: warning: ‘zOrig’ may be used uninitialized in this function
src/merge3.c:447:9: warning: ‘zOther’ may be used uninitialized in this function
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 233463c4ec13c1be7e89748caf034cd5e293c5ab
User & Date: jan.nijtmans 2012-11-06 12:20:47
Context
2012-11-06
16:35
When one version of a file ends in a newline and the other does not, be sure to show that difference. Ticket [7541963870703f0]. check-in: d764f449 user: drh tags: trunk
12:20
gcc warnings:
src/merge3.c: In function ‘merge_3way’:
src/merge3.c:445:9: warning: ‘zPivot’ may be used uninitialized in this function
src/merge3.c:446:9: warning: ‘zOrig’ may be used uninitialized in this function
src/merge3.c:447:9: warning: ‘zOther’ may be used uninitialized in this function
check-in: 233463c4 user: jan.nijtmans tags: trunk
08:44
3 minor violations against html5 check-in: c5e08c3f user: jan.nijtmans tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/merge3.c.

57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
...
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
...
438
439
440
441
442
443
444
445
446
447
448
449
450
451




452
453
454
455
456
457
458
459

460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
  return 0;
}

/*
** Look at the next edit triple in both aC1 and aC2.  (An "edit triple" is
** three integers describing the number of copies, deletes, and inserts in
** moving from the original to the edited copy of the file.) If the three
** integers of the edit triples describe an identical edit, then return 1.  
** If the edits are different, return 0.
*/
static int sameEdit(
  int *aC1,      /* Array of edit integers for file 1 */
  int *aC2,      /* Array of edit integers for file 2 */
  Blob *pV1,     /* Text of file 1 */
  Blob *pV2      /* Text of file 2 */
................................................................................
**
** The merge is an edit against pV2.  Both pV1 and pV2 have a
** common origin at pPivot.  Apply the changes of pPivot ==> pV1
** to pV2.
**
** The return is 0 upon complete success. If any input file is binary,
** -1 is returned and pOut is unmodified.  If there are merge
** conflicts, the merge proceeds as best as it can and the number 
** of conflicts is returns
*/
static int blob_merge(Blob *pPivot, Blob *pV1, Blob *pV2, Blob *pOut){
  int *aC1;              /* Changes from pPivot to pV1 */
  int *aC2;              /* Changes from pPivot to pV2 */
  int i1, i2;            /* Index into aC1[] and aC2[] */
  int nCpy, nDel, nIns;  /* Number of lines to copy, delete, or insert */
................................................................................
  const char *zV1,    /* Name of file for version merging into (mine) */
  Blob *pV2,          /* Version merging from (yours) */
  Blob *pOut,         /* Output written here */
  unsigned mergeFlags /* Flags that control operation */
){
  Blob v1;            /* Content of zV1 */
  int rc;             /* Return code of subroutines and this routine */
  char *zPivot;       /* Name of the pivot file */
  char *zOrig;        /* Name of the original content file */
  char *zOther;       /* Name of the merge file */

  blob_read_from_file(&v1, zV1);
  rc = blob_merge(pPivot, &v1, pV2, pOut);
  if( rc!=0 && (mergeFlags & MERGE_DRYRUN)==0 ){




    zPivot = file_newname(zV1, "baseline", 1);
    blob_write_to_file(pPivot, zPivot);
    zOrig = file_newname(zV1, "original", 1);
    blob_write_to_file(&v1, zOrig);
    zOther = file_newname(zV1, "merge", 1);
    blob_write_to_file(pV2, zOther);
  }
  if( rc>0 && (mergeFlags & MERGE_DRYRUN)==0 ){

    const char *zGMerge;   /* Name of the gmerge command */

    zGMerge = db_get("gmerge-command", 0);
    if( zGMerge && zGMerge[0] ){
      char *zOut;     /* Temporary output file */
      char *zCmd;     /* Command to invoke */
      const char *azSubst[8];  /* Strings to be substituted */

      zOut = file_newname(zV1, "output", 1);
      azSubst[0] = "%baseline";  azSubst[1] = zPivot;
      azSubst[2] = "%original";  azSubst[3] = zOrig;
      azSubst[4] = "%merge";     azSubst[5] = zOther;
      azSubst[6] = "%output";    azSubst[7] = zOut;
      zCmd = string_subst(zGMerge, 8, azSubst);
      printf("%s\n", zCmd); fflush(stdout);
      fossil_system(zCmd);
      if( file_wd_size(zOut)>=0 ){
        blob_read_from_file(pOut, zOut);
        file_delete(zPivot);
        file_delete(zOrig);
        file_delete(zOther);
        file_delete(zOut);
      }
      fossil_free(zCmd);
      fossil_free(zOut);
    }
  }
  if( rc!=0 && (mergeFlags & MERGE_DRYRUN)==0 ){
    fossil_free(zPivot);
    fossil_free(zOrig);
    fossil_free(zOther);
  }
  blob_reset(&v1);
  return rc;
}







|







 







|







 







<
<
<




>
>
>
>






<
<
>
|

|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<







57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
...
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
...
438
439
440
441
442
443
444



445
446
447
448
449
450
451
452
453
454
455
456
457
458


459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486

487
488
489
490
491
492
493
  return 0;
}

/*
** Look at the next edit triple in both aC1 and aC2.  (An "edit triple" is
** three integers describing the number of copies, deletes, and inserts in
** moving from the original to the edited copy of the file.) If the three
** integers of the edit triples describe an identical edit, then return 1.
** If the edits are different, return 0.
*/
static int sameEdit(
  int *aC1,      /* Array of edit integers for file 1 */
  int *aC2,      /* Array of edit integers for file 2 */
  Blob *pV1,     /* Text of file 1 */
  Blob *pV2      /* Text of file 2 */
................................................................................
**
** The merge is an edit against pV2.  Both pV1 and pV2 have a
** common origin at pPivot.  Apply the changes of pPivot ==> pV1
** to pV2.
**
** The return is 0 upon complete success. If any input file is binary,
** -1 is returned and pOut is unmodified.  If there are merge
** conflicts, the merge proceeds as best as it can and the number
** of conflicts is returns
*/
static int blob_merge(Blob *pPivot, Blob *pV1, Blob *pV2, Blob *pOut){
  int *aC1;              /* Changes from pPivot to pV1 */
  int *aC2;              /* Changes from pPivot to pV2 */
  int i1, i2;            /* Index into aC1[] and aC2[] */
  int nCpy, nDel, nIns;  /* Number of lines to copy, delete, or insert */
................................................................................
  const char *zV1,    /* Name of file for version merging into (mine) */
  Blob *pV2,          /* Version merging from (yours) */
  Blob *pOut,         /* Output written here */
  unsigned mergeFlags /* Flags that control operation */
){
  Blob v1;            /* Content of zV1 */
  int rc;             /* Return code of subroutines and this routine */




  blob_read_from_file(&v1, zV1);
  rc = blob_merge(pPivot, &v1, pV2, pOut);
  if( rc!=0 && (mergeFlags & MERGE_DRYRUN)==0 ){
    char *zPivot;       /* Name of the pivot file */
    char *zOrig;        /* Name of the original content file */
    char *zOther;       /* Name of the merge file */

    zPivot = file_newname(zV1, "baseline", 1);
    blob_write_to_file(pPivot, zPivot);
    zOrig = file_newname(zV1, "original", 1);
    blob_write_to_file(&v1, zOrig);
    zOther = file_newname(zV1, "merge", 1);
    blob_write_to_file(pV2, zOther);


    if( rc>0 ){
      const char *zGMerge;   /* Name of the gmerge command */

      zGMerge = db_get("gmerge-command", 0);
      if( zGMerge && zGMerge[0] ){
        char *zOut;     /* Temporary output file */
        char *zCmd;     /* Command to invoke */
        const char *azSubst[8];  /* Strings to be substituted */

        zOut = file_newname(zV1, "output", 1);
        azSubst[0] = "%baseline";  azSubst[1] = zPivot;
        azSubst[2] = "%original";  azSubst[3] = zOrig;
        azSubst[4] = "%merge";     azSubst[5] = zOther;
        azSubst[6] = "%output";    azSubst[7] = zOut;
        zCmd = string_subst(zGMerge, 8, azSubst);
        printf("%s\n", zCmd); fflush(stdout);
        fossil_system(zCmd);
        if( file_wd_size(zOut)>=0 ){
          blob_read_from_file(pOut, zOut);
          file_delete(zPivot);
          file_delete(zOrig);
          file_delete(zOther);
          file_delete(zOut);
        }
        fossil_free(zCmd);
        fossil_free(zOut);
      }
    }

    fossil_free(zPivot);
    fossil_free(zOrig);
    fossil_free(zOther);
  }
  blob_reset(&v1);
  return rc;
}