Fossil SCM
Change to a better, cleaner way to fail the graph generation.
Commit
cae94fe2c7b61b7c7cf3a054403fac184149894c
Parent
cbafc702a99d18f…
1 file changed
+10
-8
+10
-8
| --- src/graph.c | ||
| +++ src/graph.c | ||
| @@ -319,10 +319,11 @@ | ||
| 319 | 319 | u32 inUse; |
| 320 | 320 | int hasDup = 0; /* True if one or more isDup entries */ |
| 321 | 321 | const char *zTrunk; |
| 322 | 322 | |
| 323 | 323 | if( p==0 || p->pFirst==0 || p->nErr ) return; |
| 324 | + p->nErr = 1; /* Assume an error until proven otherwise */ | |
| 324 | 325 | |
| 325 | 326 | /* Initialize all rows */ |
| 326 | 327 | p->nHash = p->nRow*2 + 1; |
| 327 | 328 | p->apHash = safeMalloc( sizeof(p->apHash[0])*p->nHash ); |
| 328 | 329 | for(pRow=p->pFirst; pRow; pRow=pRow->pNext){ |
| @@ -400,11 +401,11 @@ | ||
| 400 | 401 | if( omitDescenders ){ |
| 401 | 402 | pRow->iRail = findFreeRail(p, pRow->idxTop, pRow->idx, 0, 0); |
| 402 | 403 | }else{ |
| 403 | 404 | pRow->iRail = ++p->mxRail; |
| 404 | 405 | } |
| 405 | - if( p->mxRail>=GR_MAX_RAIL ){ graph_clear(p); return; } | |
| 406 | + if( p->mxRail>=GR_MAX_RAIL ) return; | |
| 406 | 407 | mask = 1<<(pRow->iRail); |
| 407 | 408 | if( !omitDescenders ){ |
| 408 | 409 | pRow->bDescender = pRow->nParent>0; |
| 409 | 410 | for(pLoop=pRow; pLoop; pLoop=pLoop->pNext){ |
| 410 | 411 | pLoop->railInUse |= mask; |
| @@ -435,36 +436,36 @@ | ||
| 435 | 436 | } |
| 436 | 437 | continue; |
| 437 | 438 | } |
| 438 | 439 | if( pRow->isDup ){ |
| 439 | 440 | pRow->iRail = findFreeRail(p, pRow->idx, pRow->idx, inUse, 0); |
| 440 | - if( p->mxRail>=GR_MAX_RAIL ){ graph_clear(p); return; } | |
| 441 | + if( p->mxRail>=GR_MAX_RAIL ) return; | |
| 441 | 442 | pDesc = pRow; |
| 442 | 443 | pParent = 0; |
| 443 | 444 | }else{ |
| 444 | 445 | assert( pRow->nParent>0 ); |
| 445 | 446 | parentRid = pRow->aParent[0]; |
| 446 | 447 | pParent = hashFind(p, parentRid); |
| 447 | 448 | if( pParent==0 ){ |
| 448 | 449 | pRow->iRail = ++p->mxRail; |
| 449 | - if( p->mxRail>=GR_MAX_RAIL ){ graph_clear(p); return; } | |
| 450 | + if( p->mxRail>=GR_MAX_RAIL ) return; | |
| 450 | 451 | pRow->railInUse = 1<<pRow->iRail; |
| 451 | 452 | continue; |
| 452 | 453 | } |
| 453 | 454 | if( pParent->idx>pRow->idx ){ |
| 454 | 455 | /* Common case: Child occurs after parent and is above the |
| 455 | 456 | ** parent in the timeline */ |
| 456 | 457 | pRow->iRail = findFreeRail(p, 0, pParent->idx, inUse, pParent->iRail); |
| 457 | - if( p->mxRail>=GR_MAX_RAIL ){ graph_clear(p); return; } | |
| 458 | + if( p->mxRail>=GR_MAX_RAIL ) return; | |
| 458 | 459 | pParent->aiRiser[pRow->iRail] = pRow->idx; |
| 459 | 460 | }else{ |
| 460 | 461 | /* Timewarp case: Child occurs earlier in time than parent and |
| 461 | 462 | ** appears below the parent in the timeline. */ |
| 462 | 463 | int iDownRail = ++p->mxRail; |
| 463 | 464 | if( iDownRail<1 ) iDownRail = ++p->mxRail; |
| 464 | 465 | pRow->iRail = ++p->mxRail; |
| 465 | - if( p->mxRail>=GR_MAX_RAIL ){ graph_clear(p); return; } | |
| 466 | + if( p->mxRail>=GR_MAX_RAIL ) return; | |
| 466 | 467 | pRow->railInUse = 1<<pRow->iRail; |
| 467 | 468 | pParent->aiRiser[iDownRail] = pRow->idx; |
| 468 | 469 | mask = 1<<iDownRail; |
| 469 | 470 | inUse |= mask; |
| 470 | 471 | for(pLoop=p->pFirst; pLoop; pLoop=pLoop->pNext){ |
| @@ -495,21 +496,21 @@ | ||
| 495 | 496 | int parentRid = pRow->aParent[i]; |
| 496 | 497 | pDesc = hashFind(p, parentRid); |
| 497 | 498 | if( pDesc==0 ){ |
| 498 | 499 | /* Merge from a node that is off-screen */ |
| 499 | 500 | int iMrail = findFreeRail(p, pRow->idx, p->nRow, 0, 0); |
| 500 | - if( p->mxRail>=GR_MAX_RAIL ){ graph_clear(p); return; } | |
| 501 | + if( p->mxRail>=GR_MAX_RAIL ) return; | |
| 501 | 502 | mask = 1<<iMrail; |
| 502 | 503 | pRow->mergeIn[iMrail] = 2; |
| 503 | 504 | pRow->mergeDown |= mask; |
| 504 | 505 | for(pLoop=pRow->pNext; pLoop; pLoop=pLoop->pNext){ |
| 505 | 506 | pLoop->railInUse |= mask; |
| 506 | 507 | } |
| 507 | 508 | }else{ |
| 508 | 509 | /* Merge from an on-screen node */ |
| 509 | 510 | createMergeRiser(p, pDesc, pRow); |
| 510 | - if( p->mxRail>=GR_MAX_RAIL ){ graph_clear(p); return; } | |
| 511 | + if( p->mxRail>=GR_MAX_RAIL ) return; | |
| 511 | 512 | } |
| 512 | 513 | } |
| 513 | 514 | } |
| 514 | 515 | |
| 515 | 516 | /* |
| @@ -520,11 +521,11 @@ | ||
| 520 | 521 | if( !pRow->isDup ) continue; |
| 521 | 522 | pDesc = hashFind(p, pRow->rid); |
| 522 | 523 | assert( pDesc!=0 && pDesc!=pRow ); |
| 523 | 524 | createMergeRiser(p, pDesc, pRow); |
| 524 | 525 | } |
| 525 | - if( p->mxRail>=GR_MAX_RAIL ){ graph_clear(p); return; } | |
| 526 | + if( p->mxRail>=GR_MAX_RAIL ) return; | |
| 526 | 527 | } |
| 527 | 528 | |
| 528 | 529 | /* |
| 529 | 530 | ** Find the maximum rail number. |
| 530 | 531 | */ |
| @@ -534,6 +535,7 @@ | ||
| 534 | 535 | if( pRow->mergeOut/4>p->mxRail ) p->mxRail = pRow->mergeOut/4; |
| 535 | 536 | while( p->mxRail<GR_MAX_RAIL && pRow->mergeDown>((1<<(p->mxRail+1))-1) ){ |
| 536 | 537 | p->mxRail++; |
| 537 | 538 | } |
| 538 | 539 | } |
| 540 | + p->nErr = 0; | |
| 539 | 541 | } |
| 540 | 542 |
| --- src/graph.c | |
| +++ src/graph.c | |
| @@ -319,10 +319,11 @@ | |
| 319 | u32 inUse; |
| 320 | int hasDup = 0; /* True if one or more isDup entries */ |
| 321 | const char *zTrunk; |
| 322 | |
| 323 | if( p==0 || p->pFirst==0 || p->nErr ) return; |
| 324 | |
| 325 | /* Initialize all rows */ |
| 326 | p->nHash = p->nRow*2 + 1; |
| 327 | p->apHash = safeMalloc( sizeof(p->apHash[0])*p->nHash ); |
| 328 | for(pRow=p->pFirst; pRow; pRow=pRow->pNext){ |
| @@ -400,11 +401,11 @@ | |
| 400 | if( omitDescenders ){ |
| 401 | pRow->iRail = findFreeRail(p, pRow->idxTop, pRow->idx, 0, 0); |
| 402 | }else{ |
| 403 | pRow->iRail = ++p->mxRail; |
| 404 | } |
| 405 | if( p->mxRail>=GR_MAX_RAIL ){ graph_clear(p); return; } |
| 406 | mask = 1<<(pRow->iRail); |
| 407 | if( !omitDescenders ){ |
| 408 | pRow->bDescender = pRow->nParent>0; |
| 409 | for(pLoop=pRow; pLoop; pLoop=pLoop->pNext){ |
| 410 | pLoop->railInUse |= mask; |
| @@ -435,36 +436,36 @@ | |
| 435 | } |
| 436 | continue; |
| 437 | } |
| 438 | if( pRow->isDup ){ |
| 439 | pRow->iRail = findFreeRail(p, pRow->idx, pRow->idx, inUse, 0); |
| 440 | if( p->mxRail>=GR_MAX_RAIL ){ graph_clear(p); return; } |
| 441 | pDesc = pRow; |
| 442 | pParent = 0; |
| 443 | }else{ |
| 444 | assert( pRow->nParent>0 ); |
| 445 | parentRid = pRow->aParent[0]; |
| 446 | pParent = hashFind(p, parentRid); |
| 447 | if( pParent==0 ){ |
| 448 | pRow->iRail = ++p->mxRail; |
| 449 | if( p->mxRail>=GR_MAX_RAIL ){ graph_clear(p); return; } |
| 450 | pRow->railInUse = 1<<pRow->iRail; |
| 451 | continue; |
| 452 | } |
| 453 | if( pParent->idx>pRow->idx ){ |
| 454 | /* Common case: Child occurs after parent and is above the |
| 455 | ** parent in the timeline */ |
| 456 | pRow->iRail = findFreeRail(p, 0, pParent->idx, inUse, pParent->iRail); |
| 457 | if( p->mxRail>=GR_MAX_RAIL ){ graph_clear(p); return; } |
| 458 | pParent->aiRiser[pRow->iRail] = pRow->idx; |
| 459 | }else{ |
| 460 | /* Timewarp case: Child occurs earlier in time than parent and |
| 461 | ** appears below the parent in the timeline. */ |
| 462 | int iDownRail = ++p->mxRail; |
| 463 | if( iDownRail<1 ) iDownRail = ++p->mxRail; |
| 464 | pRow->iRail = ++p->mxRail; |
| 465 | if( p->mxRail>=GR_MAX_RAIL ){ graph_clear(p); return; } |
| 466 | pRow->railInUse = 1<<pRow->iRail; |
| 467 | pParent->aiRiser[iDownRail] = pRow->idx; |
| 468 | mask = 1<<iDownRail; |
| 469 | inUse |= mask; |
| 470 | for(pLoop=p->pFirst; pLoop; pLoop=pLoop->pNext){ |
| @@ -495,21 +496,21 @@ | |
| 495 | int parentRid = pRow->aParent[i]; |
| 496 | pDesc = hashFind(p, parentRid); |
| 497 | if( pDesc==0 ){ |
| 498 | /* Merge from a node that is off-screen */ |
| 499 | int iMrail = findFreeRail(p, pRow->idx, p->nRow, 0, 0); |
| 500 | if( p->mxRail>=GR_MAX_RAIL ){ graph_clear(p); return; } |
| 501 | mask = 1<<iMrail; |
| 502 | pRow->mergeIn[iMrail] = 2; |
| 503 | pRow->mergeDown |= mask; |
| 504 | for(pLoop=pRow->pNext; pLoop; pLoop=pLoop->pNext){ |
| 505 | pLoop->railInUse |= mask; |
| 506 | } |
| 507 | }else{ |
| 508 | /* Merge from an on-screen node */ |
| 509 | createMergeRiser(p, pDesc, pRow); |
| 510 | if( p->mxRail>=GR_MAX_RAIL ){ graph_clear(p); return; } |
| 511 | } |
| 512 | } |
| 513 | } |
| 514 | |
| 515 | /* |
| @@ -520,11 +521,11 @@ | |
| 520 | if( !pRow->isDup ) continue; |
| 521 | pDesc = hashFind(p, pRow->rid); |
| 522 | assert( pDesc!=0 && pDesc!=pRow ); |
| 523 | createMergeRiser(p, pDesc, pRow); |
| 524 | } |
| 525 | if( p->mxRail>=GR_MAX_RAIL ){ graph_clear(p); return; } |
| 526 | } |
| 527 | |
| 528 | /* |
| 529 | ** Find the maximum rail number. |
| 530 | */ |
| @@ -534,6 +535,7 @@ | |
| 534 | if( pRow->mergeOut/4>p->mxRail ) p->mxRail = pRow->mergeOut/4; |
| 535 | while( p->mxRail<GR_MAX_RAIL && pRow->mergeDown>((1<<(p->mxRail+1))-1) ){ |
| 536 | p->mxRail++; |
| 537 | } |
| 538 | } |
| 539 | } |
| 540 |
| --- src/graph.c | |
| +++ src/graph.c | |
| @@ -319,10 +319,11 @@ | |
| 319 | u32 inUse; |
| 320 | int hasDup = 0; /* True if one or more isDup entries */ |
| 321 | const char *zTrunk; |
| 322 | |
| 323 | if( p==0 || p->pFirst==0 || p->nErr ) return; |
| 324 | p->nErr = 1; /* Assume an error until proven otherwise */ |
| 325 | |
| 326 | /* Initialize all rows */ |
| 327 | p->nHash = p->nRow*2 + 1; |
| 328 | p->apHash = safeMalloc( sizeof(p->apHash[0])*p->nHash ); |
| 329 | for(pRow=p->pFirst; pRow; pRow=pRow->pNext){ |
| @@ -400,11 +401,11 @@ | |
| 401 | if( omitDescenders ){ |
| 402 | pRow->iRail = findFreeRail(p, pRow->idxTop, pRow->idx, 0, 0); |
| 403 | }else{ |
| 404 | pRow->iRail = ++p->mxRail; |
| 405 | } |
| 406 | if( p->mxRail>=GR_MAX_RAIL ) return; |
| 407 | mask = 1<<(pRow->iRail); |
| 408 | if( !omitDescenders ){ |
| 409 | pRow->bDescender = pRow->nParent>0; |
| 410 | for(pLoop=pRow; pLoop; pLoop=pLoop->pNext){ |
| 411 | pLoop->railInUse |= mask; |
| @@ -435,36 +436,36 @@ | |
| 436 | } |
| 437 | continue; |
| 438 | } |
| 439 | if( pRow->isDup ){ |
| 440 | pRow->iRail = findFreeRail(p, pRow->idx, pRow->idx, inUse, 0); |
| 441 | if( p->mxRail>=GR_MAX_RAIL ) return; |
| 442 | pDesc = pRow; |
| 443 | pParent = 0; |
| 444 | }else{ |
| 445 | assert( pRow->nParent>0 ); |
| 446 | parentRid = pRow->aParent[0]; |
| 447 | pParent = hashFind(p, parentRid); |
| 448 | if( pParent==0 ){ |
| 449 | pRow->iRail = ++p->mxRail; |
| 450 | if( p->mxRail>=GR_MAX_RAIL ) return; |
| 451 | pRow->railInUse = 1<<pRow->iRail; |
| 452 | continue; |
| 453 | } |
| 454 | if( pParent->idx>pRow->idx ){ |
| 455 | /* Common case: Child occurs after parent and is above the |
| 456 | ** parent in the timeline */ |
| 457 | pRow->iRail = findFreeRail(p, 0, pParent->idx, inUse, pParent->iRail); |
| 458 | if( p->mxRail>=GR_MAX_RAIL ) return; |
| 459 | pParent->aiRiser[pRow->iRail] = pRow->idx; |
| 460 | }else{ |
| 461 | /* Timewarp case: Child occurs earlier in time than parent and |
| 462 | ** appears below the parent in the timeline. */ |
| 463 | int iDownRail = ++p->mxRail; |
| 464 | if( iDownRail<1 ) iDownRail = ++p->mxRail; |
| 465 | pRow->iRail = ++p->mxRail; |
| 466 | if( p->mxRail>=GR_MAX_RAIL ) return; |
| 467 | pRow->railInUse = 1<<pRow->iRail; |
| 468 | pParent->aiRiser[iDownRail] = pRow->idx; |
| 469 | mask = 1<<iDownRail; |
| 470 | inUse |= mask; |
| 471 | for(pLoop=p->pFirst; pLoop; pLoop=pLoop->pNext){ |
| @@ -495,21 +496,21 @@ | |
| 496 | int parentRid = pRow->aParent[i]; |
| 497 | pDesc = hashFind(p, parentRid); |
| 498 | if( pDesc==0 ){ |
| 499 | /* Merge from a node that is off-screen */ |
| 500 | int iMrail = findFreeRail(p, pRow->idx, p->nRow, 0, 0); |
| 501 | if( p->mxRail>=GR_MAX_RAIL ) return; |
| 502 | mask = 1<<iMrail; |
| 503 | pRow->mergeIn[iMrail] = 2; |
| 504 | pRow->mergeDown |= mask; |
| 505 | for(pLoop=pRow->pNext; pLoop; pLoop=pLoop->pNext){ |
| 506 | pLoop->railInUse |= mask; |
| 507 | } |
| 508 | }else{ |
| 509 | /* Merge from an on-screen node */ |
| 510 | createMergeRiser(p, pDesc, pRow); |
| 511 | if( p->mxRail>=GR_MAX_RAIL ) return; |
| 512 | } |
| 513 | } |
| 514 | } |
| 515 | |
| 516 | /* |
| @@ -520,11 +521,11 @@ | |
| 521 | if( !pRow->isDup ) continue; |
| 522 | pDesc = hashFind(p, pRow->rid); |
| 523 | assert( pDesc!=0 && pDesc!=pRow ); |
| 524 | createMergeRiser(p, pDesc, pRow); |
| 525 | } |
| 526 | if( p->mxRail>=GR_MAX_RAIL ) return; |
| 527 | } |
| 528 | |
| 529 | /* |
| 530 | ** Find the maximum rail number. |
| 531 | */ |
| @@ -534,6 +535,7 @@ | |
| 535 | if( pRow->mergeOut/4>p->mxRail ) p->mxRail = pRow->mergeOut/4; |
| 536 | while( p->mxRail<GR_MAX_RAIL && pRow->mergeDown>((1<<(p->mxRail+1))-1) ){ |
| 537 | p->mxRail++; |
| 538 | } |
| 539 | } |
| 540 | p->nErr = 0; |
| 541 | } |
| 542 |