Skip to content

Commit 57ce223

Browse files
committed
Update all findRecbyNmXX() calls to basAnc::FindRecByName
1 parent 92bd2d8 commit 57ce223

File tree

16 files changed

+676
-397
lines changed

16 files changed

+676
-397
lines changed

src/ancrec.cpp

Lines changed: 252 additions & 29 deletions
Large diffs are not rendered by default.

src/ancrec.h

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class basAnc // base class for record anchors: basAnc<recordName>
8282
basAnc( int flags, SFIR * fir, USI nFlds, const char * what, USI eSz, RCT rt, USI sOff, const CULT* pCult, bool dontRegister=false );
8383
void FC regis();
8484
virtual ~basAnc(); // destroyed in deriv classes, to use vf
85-
virtual record* ptr() = 0; // access block ptr (in drv class: typed)
85+
virtual record* ptr() const = 0; // access block ptr (in drv class: typed)
8686
virtual void** pptr() = 0;
8787
virtual void setPtr( record* r) = 0;
8888
virtual record& rec(TI i) = 0; // { return (record)((char *)ptr() + i*eSz); } // access record i
@@ -100,12 +100,27 @@ class basAnc // base class for record anchors: basAnc<recordName>
100100
static BP FC anc4n( USI an, int erOp=ABT); // access anchor by anchor #
101101
static RC FC findAnchorByNm( char *what, BP *b);
102102
static int FC ancNext( size_t &an, BP *_b); // iterate anchors
103-
RC validate( const char* fcnName, int erOp=ABT, SI noStat=0); // check for valid anchor
103+
static RC ba_ValidateSafe(const basAnc* _this, const char* fcnName, int erOp = ABT, bool noStat = false);
104+
RC ba_Validate( const char* fcnName, int erOp=ABT, bool noStat=false) const; // check for valid anchor
104105
record* Get1stForOwner(int ss);
105106
RC findRecByNm1( const char* _name, TI *_i, record **_r); // find record by 1st match on name
107+
RC findRecByNm1X( const char* _name, TI *_i, record **_r); // find record by 1st match on name
108+
106109
RC findRecByNmU( const char* _name, TI *_i, record **_r); // find record by unique name match
110+
RC findRecByNmUX( const char* _name, TI *_i, record **_r); // find record by unique name match
111+
107112
RC findRecByNmO( const char* _name, TI ownTi, TI *_i, record **_r); // find record by name and owner subscript
113+
RC findRecByNmOX( const char* _name, TI ownTi, TI *_i, record **_r); // find record by name and owner subscript
114+
108115
RC findRecByNmDefO( const char* _name, TI ownTi, record **_r1, record **_r2 ); // find record by name, and owner if ambiguous
116+
RC findRecByNmDefOX( const char* _name, TI ownTi, record **_r1, record **_r2 ); // find record by name, and owner if ambiguous
117+
118+
119+
static constexpr int frn1STMATCH = 0;
120+
static constexpr int frnUNIQUE = 0x40000000;
121+
static constexpr int frnACCEPTNONOWNER = 0x20000000;
122+
static constexpr int frnTIMASK = 0x01ffffff;
123+
static RC FindRecByName(const basAnc* _b, const char* _name, int ownerTIOpt=0, record** pr1=nullptr, TI* pTi=nullptr, record** pr2=nullptr);
109124
const char* getChoiTx( int fn, int options=0, SI chan=-1, BOOL* bIsHid=NULL) const;
110125
const char* culMbrIdTx(int fn) const;
111126
int culMbrArrayDim(int fn) const;
@@ -363,7 +378,7 @@ template <class T> class anc : public basAnc
363378
}
364379
} // GetAtGud
365380

366-
virtual record* ptr() { return p; } // access block ptr (in base class / generic code)
381+
virtual record* ptr() const { return p; } // access block ptr (in base class / generic code)
367382
virtual void** pptr() { return (void **)&p; }
368383
virtual void setPtr( record* r) { p = (T*)r; }
369384
virtual record& rec(TI i) { return p[i]; } // access record i in base/generic code
@@ -402,13 +417,12 @@ template <class T> class anc : public basAnc
402417
//----- variant with condition
403418
#define RLUPC( B, rp, C) for (rp=(B).p+(B).mn; rp <= (B).p + (B).n; rp++) if (rp->r_status > 0 && (C))
404419

405-
#if 0
406-
0 unused
407-
0 //----- macro to loop over records of generic anchor (record type not known) (hook to change re skipping deleted records)
408-
0 #define RLUPGEN( B, rp) for ( rp = (record *)( (char *)(B).ptr() + (B).eSz*(B).mn ); \
409-
0 rp <= (record *)( (char *)(B).ptr() + (B).eSz*(B).n ); \
410-
0 (char *)rp += (B).eSz ) \
411-
0 if (((record *)rp)->r_status > 0)
420+
#if 1
421+
//----- macro to loop over records of generic anchor (record type not known) (hook to change re skipping deleted records)
422+
#define RLUPGEN( B, rp) for ( rp = (record *)( (char *)(B).ptr() + (B).eSz*(B).mn ); \
423+
rp <= (record *)( (char *)(B).ptr() + (B).eSz*(B).n ); \
424+
IncP( DMPP( rp), (B).eSz) ) \
425+
if (((record *)rp)->r_status > 0)
412426
#endif
413427

414428
//----- macro to loop over records of generic anchor in member fcn (hook to change re skipping deleted records)

src/cgwthr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ RC DESCOND::dc_CkF() // check after input
553553
static void DCTauTest( int doy)
554554
{
555555
float ebnlist[] = { 150.f, 200.f, 250.f, 300.f, -1.f };
556-
float edflist[] = { 20.f, 30.f, 40.f };
556+
float edflist[] = { 20.f, 30.f, 40.f, -1.f };
557557

558558
DESCOND dc( &DcR, 1);
559559
dc.dc_doy = doy;

src/cncult2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1995,7 +1995,7 @@ RC ckRefPt( // check / access ref from one RAT to another
19951995
record* p = NULL;
19961996

19971997
// check argument
1998-
if (toBase->validate( "cncult2.cpp:ckRefPt", WRN))
1998+
if (basAnc::ba_ValidateSafe( toBase, "cncult2.cpp:ckRefPt", WRN) != RCOK)
19991999
rc = RCBAD;
20002000
else
20012001
{

src/cncult4.cpp

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -511,45 +511,45 @@ RC RI::ri_oneRxp() // process one report or export for topRxp
511511

512512
// topZn and topCol must be called first; buildUnspoolInfo must be called afterwards.
513513
{
514-
RC rc=RCOK;
514+
RC rc = RCOK;
515515

516516
int isEx = isExport; // 1 for export, 0 for report
517517
const char* exrp = isEx ? "ex" : "rp"; // to insert in member names in error messages
518518
const char* exrePort = isEx ? "export" : "report"; // to insert in errmsgs
519519

520-
// get field texts for errMsgs. No errmsg (except in returned text) if value out of range.
520+
// get field texts for errMsgs. No errmsg (except in returned text) if value out of range.
521521

522-
const char* tyTx = getChoiTx( RI_RPTY, 1);
523-
const char* whenTy = strtprintf( "when %sType=%s", exrp, tyTx);
522+
const char* tyTx = getChoiTx(RI_RPTY, 1);
523+
const char* whenTy = strtprintf("when %sType=%s", exrp, tyTx);
524524

525-
// check RQD members set -- else can bomb with FPE
525+
// check RQD members set -- else can bomb with FPE
526526

527-
if (CkSet( RI_RPTY))
527+
if (CkSet(RI_RPTY))
528528
return RCBAD; // if not set, no run, terminate checking this report/export now
529529

530-
// recall entry time check function 1) as it has not been called for pre-stuffed default reports entries;
531-
// 2) to recheck references (DELETE given after entry?)(if it checks any); and 3) general paranoia.
530+
// recall entry time check function 1) as it has not been called for pre-stuffed default reports entries;
531+
// 2) to recheck references (DELETE given after entry?)(if it checks any); and 3) general paranoia.
532532

533533
if (!errCount()) // but if already have errors (hence no run), do not recall:
534-
// would issue duplicate messages for any errors it detected.
534+
// would issue duplicate messages for any errors it detected.
535535
if (ri_CkF()) // note this is the ckf for exports as well as reports
536536
return RCBAD; // bad. done with entry.
537537

538-
// default start and/or end days of report. Don't set nz b4 other checks as not allowed with some rpt types & freq's.
539-
// and, doing here sets dates for monthly default reports.
538+
// default start and/or end days of report. Don't set nz b4 other checks as not allowed with some rpt types & freq's.
539+
// and, doing here sets dates for monthly default reports.
540540

541-
if ( rpFreq==C_IVLCH_M // monthly frequency: default days to start and end of run
542-
|| rpFreq==C_IVLCH_Y ) // annual frequency: this sets dates
541+
if (rpFreq==C_IVLCH_M // monthly frequency: default days to start and end of run
542+
|| rpFreq==C_IVLCH_Y) // annual frequency: this sets dates
543543
{
544544
if (!rpDayBeg) rpDayBeg = Topi.tp_begDay;
545545
if (!rpDayEnd) rpDayEnd = Topi.tp_endDay;
546546
}
547547
else if (!rpDayEnd) // other frequencies; rpDayBeg is 0 if here and dates not used.
548548
rpDayEnd = rpDayBeg; // end day defaults to start day
549549

550-
// disallow condition for types without repeated conditional lines
550+
// disallow condition for types without repeated conditional lines
551551

552-
int rpCondGiven = IsSet( RI_RPCOND); // 1 if rpCond entered by user, 0 if rpCond defaulted (to TRUE).
552+
int rpCondGiven = IsSet(RI_RPCOND); // 1 if rpCond entered by user, 0 if rpCond defaulted (to TRUE).
553553
switch (rpTy)
554554
{
555555
case C_RPTYCH_SUM:
@@ -562,7 +562,7 @@ RC RI::ri_oneRxp() // process one report or export for topRxp
562562
case C_RPTYCH_TUSIZE:
563563
case C_RPTYCH_TULOAD: // 6-95
564564
if (rpCondGiven)
565-
rc = oer( MH_S0548, exrp, exrp, tyTx); // "%sCond may not be given with %sType=%s"
565+
rc = oer(MH_S0548, exrp, exrp, tyTx); // "%sCond may not be given with %sType=%s"
566566
break;
567567
default:
568568
;
@@ -574,70 +574,71 @@ RC RI::ri_oneRxp() // process one report or export for topRxp
574574
switch (rpTy)
575575
{
576576
case C_RPTYCH_MTR: // "Meter" report/export requires rp/exMeter
577-
rc |= require( whenTy, RI_MTRI);
578-
rc |= disallowN( whenTy, RI_ZI, RI_AHI, RI_TUI, RI_DHWMTRI, RI_AFMTRI, 0);
577+
rc |= require(whenTy, RI_MTRI);
578+
rc |= disallowN(whenTy, RI_ZI, RI_AHI, RI_TUI, RI_DHWMTRI, RI_AFMTRI, 0);
579579
break;
580580

581581
case C_RPTYCH_DHWMTR: // "DHWMTR" report/export requires rp/exDHWMeter
582-
rc |= require( whenTy, RI_DHWMTRI);
583-
rc |= disallowN( whenTy, RI_ZI, RI_AHI, RI_TUI, RI_MTRI, RI_AFMTRI, 0);
582+
rc |= require(whenTy, RI_DHWMTRI);
583+
rc |= disallowN(whenTy, RI_ZI, RI_AHI, RI_TUI, RI_MTRI, RI_AFMTRI, 0);
584584
break;
585585

586586
case C_RPTYCH_AFMTR: // "AFMTR" report/export requires rp/exAFMeter
587-
rc |= require( whenTy, RI_AFMTRI);
587+
rc |= require(whenTy, RI_AFMTRI);
588588
rc |= disallowN(whenTy, RI_ZI, RI_AHI, RI_TUI, RI_MTRI, RI_DHWMTRI, 0);
589589
break;
590590

591591
case C_RPTYCH_AHSIZE: // AH-specific reports
592592
case C_RPTYCH_AHLOAD:
593593
case C_RPTYCH_AH:
594-
rc |= require( whenTy, RI_AHI);
595-
rc |= disallowN( whenTy, RI_ZI, RI_TUI, RI_MTRI, RI_DHWMTRI, 0);
594+
rc |= require(whenTy, RI_AHI);
595+
rc |= disallowN(whenTy, RI_ZI, RI_TUI, RI_MTRI, RI_DHWMTRI, 0);
596596
break;
597597

598598
case C_RPTYCH_TUSIZE: // TU-specific reports
599599
case C_RPTYCH_TULOAD:
600-
rc |= require( whenTy, RI_TUI);
601-
rc |= disallowN( whenTy, RI_ZI, RI_AHI, RI_MTRI, RI_DHWMTRI, 0);
600+
rc |= require(whenTy, RI_TUI);
601+
rc |= disallowN(whenTy, RI_ZI, RI_AHI, RI_MTRI, RI_DHWMTRI, 0);
602602
break;
603603

604604
case C_RPTYCH_ZDD: // zone-specific reports
605605
case C_RPTYCH_ZEB:
606606
case C_RPTYCH_ZST:
607-
rc |= require( whenTy, RI_ZI);
608-
rc |= disallowN( whenTy, RI_TUI, RI_AHI, RI_MTRI, RI_DHWMTRI, 0);
607+
rc |= require(whenTy, RI_ZI);
608+
rc |= disallowN(whenTy, RI_TUI, RI_AHI, RI_MTRI, RI_DHWMTRI, 0);
609609
break;
610610

611611
case C_RPTYCH_SUM: // non- zone -ah -tu -meter reports/exports
612612
case C_RPTYCH_LOG:
613613
case C_RPTYCH_ERR:
614614
case C_RPTYCH_INP:
615615
case C_RPTYCH_UDT:
616-
rc |= disallowN( whenTy, RI_ZI, RI_TUI, RI_AHI, RI_MTRI, RI_DHWMTRI, 0);
616+
rc |= disallowN(whenTy, RI_ZI, RI_TUI, RI_AHI, RI_MTRI, RI_DHWMTRI, 0);
617617
break;
618618

619619
default:
620620
if (!errCount()) // if other error has occurred, suppress msg: may be consequential
621-
rc = oer( (const char *)MH_S0555, exrp, rpTy); // "cncult:topRp: Internal error: Bad %sType %d"
621+
rc = oer((const char*)MH_S0555, exrp, rpTy); // "cncult:topRp: Internal error: Bad %sType %d"
622622
}
623623

624-
// default/check file reference. Defaulted to rp/exfile in which nested, else default here to "Primary" (supplied by TopStarPrf)
624+
// default/check file reference. Defaulted to rp/exfile in which nested, else default here to "Primary" (supplied by TopStarPrf)
625625

626626
if (!ownTi) // if no file given & not defaulted (note default does not set FsSET bit)
627-
{ anc<RFI>* fb = isEx ? &XfiB : &RfiB; // ptr to reportfile or exportfile input ratbase
628-
if (fb->findRecByNm1("Primary", &ownTi, NULL)) // find first record by name (ancrec.cpp) / if not found
627+
{
628+
anc<RFI>* fb = isEx ? &XfiB : &RfiB; // ptr to reportfile or exportfile input ratbase
629+
if (basAnc::FindRecByName(fb, "Primary", 0, nullptr, &ownTi) != RCOK) // find first record by name / if not found
629630
{
630631
if (fb->n) // if not found, if there are ANY r/xport files,
631632
ownTi = 1; // use first one: is probably Primary renamed with ALTER
632633
else // no r/xport files at all
633-
rc |= ooer(RI_OWNTI, // issue error once (cul.cpp), no run
634-
isEx ? MH_S0556 : MH_S0557); // "No exExportfile given" or "No rpReportfile given"
634+
rc |= ooer(RI_OWNTI, MH_S0556, // issue error once (cul.cpp), no run
635+
isEx ? "exExportFile" : "rpReportFile"); // "exExportFile/rpReportFile 'Primary' not found"
635636
}
636637
}
637-
RFI* rfp=NULL;
638-
if (ownTi)
639-
if (ckRefPt( isEx ? &XfiB : &RfiB, ownTi, isEx ? "exFile" : "rpFile", NULL, (record **)&rfp ) ) // ck ref
640-
return RCBAD;
638+
RFI* rfp = NULL;
639+
if (!ownTi
640+
|| ckRefPt( isEx ? &XfiB : &RfiB, ownTi, isEx ? "exFile" : "rpFile", NULL, (record **)&rfp ) ) // ck ref
641+
return RCBAD;
641642

642643
// check zone reference or ALL or SUM
643644
int isAll = 0; // set nz iff ALL

src/cueval.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,12 +1043,14 @@ LOCAL RC FC cuEvalI(
10431043
defO = *IPI++; // get 0 or default owner subscript for ambiquity resolution
10441044
p = *SPP; // get ptr to name string from stack. no pop: will overwrite.
10451045
const char* pName = strTrim( (char *)p); // trim in place
1046-
if (defO // if defO given (owning input record subscript)
1047-
&& b->ownB ) // if owning-basAnc pointer set in probed basAnc (should be set in run rat
1048-
// only if subscripts in owning run rat match input subscripts)
1049-
trc = b->findRecByNmDefO( pName, defO, SPPR, NULL); // seek rcd by name & defO, repl ptr in stk.
1050-
else
1051-
trc = b->findRecByNmU( pName, NULL, SPPR); // seek unique record by name, replace ptr in stk.
1046+
// if defO given (owning input record subscript)
1047+
// and owning-basAnc pointer set in probed basAnc (should be set in run rat
1048+
// only if subscripts in owning run rat match input subscripts)
1049+
int ownerTIOpt = defO && b->ownB
1050+
? defO | basAnc::frnACCEPTNONOWNER // seek rcd by name & defO, accept alt owner if unique
1051+
: basAnc::frnUNIQUE; // seek any rcd iff unique
1052+
trc = basAnc::FindRecByName(b, pName, ownerTIOpt, SPPR);
1053+
10521054
if (trc)
10531055
{
10541056
ms = strtprintf(

src/cul.cpp

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -436,11 +436,13 @@ x trace = 1;
436436
err( PWRN, MH_S0204); // "cul(): NULL RAT entry arg (e)"
437437
return 1;
438438
}
439-
if (e->b->validate("cul.cpp:cul",WRN)) return 1;
439+
if (basAnc::ba_ValidateSafe( e->b, "cul.cpp:cul", WRN) != RCOK)
440+
return 1;
440441

441442
// autosize flag pointer and flag
442443
pAuszF = _pAuszF; // store argument pointer or NULL given by caller
443-
if (pAuszF) *pAuszF = FALSE; // say no AUTOSIZE commands yet seen
444+
if (pAuszF)
445+
*pAuszF = FALSE; // say no AUTOSIZE commands yet seen
444446

445447
// init top-level context stack frame
446448
memset( xSp, 0, sizeof(XSTK) ); // zero it: inits many members
@@ -1224,26 +1226,30 @@ LOCAL RC FC culRATE( // do RATE cult entry
12241226
// "owned" basAnc record names need only be unique for same owner:
12251227
if ( !defTy // type names must be globally unique
12261228
&& xSp > xStk ) // insurance: if command is nested
1227-
{
1228-
if (b->findRecByNmO( name, // find basAnc record by name/owner, ancrec.cpp
1229-
xSp->i, // owner subscript. always here??
1230-
NULL, NULL)==RCOK ) // if found
1229+
{ // find basAnc record by name/owner
1230+
// old comment: xSp->i: owner subscript, always here?
1231+
if (basAnc::FindRecByName(b, name, xSp->i) == RCOK)
1232+
{ // record found: duplicate name
12311233
// if owner ti can be set != xSp->i, then check again at END.<<<<
12321234
perlc( // errMsg, show input line and ^. cuparse.cpp.
12331235
scWrapIf( // strtcat w conditional \n
1234-
strtprintf( MH_S0227, c->id, name.CStr() ), // "duplicate %s name '%s' in "
1235-
xSp->b->rec(xSp->i).objIdTx( 1 ), // owner class & obj name, etc
1236+
strtprintf(MH_S0227, c->id, name.CStr()), // "duplicate %s name '%s' in "
1237+
xSp->b->rec(xSp->i).objIdTx(1), // owner class & obj name, etc
12361238
"\n "), getCpl()); // \n between if wd be longer
1239+
}
12371240
// and continue here (?) (perlc prevents RUN)
12381241
}
1239-
else // not ownable or not in ownable context
1240-
if ( (defTy ? b->tyB->findRecByNm1( name, NULL, NULL) // search basAnc's types basAnc if defining a type
1241-
: b ? b->findRecByNm1( name, NULL, NULL) // else the basAnc itself
1242-
: RCBAD )==RCOK ) // NULL b ??: unsure while converting code, sometime if possible
1243-
// if any record with same name found found
1244-
perlc( MH_S0228, c->id, defTy ? " type" : "", name.CStr()); // "duplicate %s%s name '%s'"
1242+
else
1243+
{ // not ownable or not in ownable context
1244+
// defining a type (defTy): search b->tyB (basAnc's types basAnc)
1245+
// (Future: if necessary to avoid defTy ambiguity, also search b)
1246+
// else basAnc itself
1247+
if (basAnc::FindRecByName(defTy ? b->tyB : b, name) == RCOK)
1248+
{ // if any record with same name found found
1249+
perlc(MH_S0228, c->id, defTy ? " type" : "", name.CStr()); // "duplicate %s%s name '%s'"
1250+
}
1251+
}
12451252
// and continue here (?) (perlc prevents RUN)
1246-
// if necessary to avoid (future) ambiguity during defTy, also search regular table (b).
12471253
}
12481254

12491255
// add record to specified basAnc
@@ -1280,7 +1286,7 @@ LOCAL RC FC culRATE( // do RATE cult entry
12801286
if (typeName.IsSet())
12811287
{
12821288
record *typeE;
1283-
if (b->tyB->findRecByNm1( typeName, NULL, /*VV*/ &typeE) != RCOK)
1289+
if (basAnc::FindRecByName(b->tyB, typeName, basAnc::frn1STMATCH, &typeE) != RCOK)
12841290
perlc( MH_S0229, c->id, typeName.CStr()); // "%s type '%s' not found"
12851291
// and continue here with raw record (perlc prevents RUN)
12861292
else // found
@@ -3452,7 +3458,8 @@ LOCAL RC ratPutTy( record *e, CULT *c)
34523458

34533459
#ifdef DEBUG
34543460
// check argument
3455-
if (b->validate("cul:ratPutTy",WRN)) return RCBAD;
3461+
if (basAnc::ba_ValidateSafe( b, "cul:ratPutTy", WRN) != RCOK)
3462+
return RCBAD;
34563463
#endif
34573464

34583465
// require record to be LAST in basAnc -- else have no way to delete ( <<<< believe no longer true 1-92, fix if need found)
@@ -3637,7 +3644,7 @@ LOCAL RC FC ratTyR( BP b) // if basAnc does not have secondary basAnc for types
36373644
// returns RCOK/RCFATAL
36383645
{
36393646
#ifdef DEBUG
3640-
if (b->validate("ratTyR",WRN)) // check argument
3647+
if (basAnc::ba_ValidateSafe( b, "ratTyR", WRN) != RCOK) // check argument
36413648
return RCFATAL;
36423649
#endif
36433650

@@ -4041,16 +4048,19 @@ LOCAL RC ratLuDefO( // look up basAnc record by name, resolving ambiguities usin
40414048
what = b->what;
40424049
if (defO==0) // if no default owner given
40434050
{
4044-
rc = b->findRecByNm1( name, NULL, /*VV*/ &e); // find first record with given name, ancrec.cpp
4051+
rc = basAnc::FindRecByName(b, name, basAnc::frn1STMATCH, &e); // find first record with given name
40454052
if (rc)
40464053
ms = strtprintf( MH_S0278, what, name); // format ms "%s '%s' not found" to Tmpstr. Also used below.
40474054
}
40484055
else
40494056
{
4050-
rc = b->findRecByNmDefO( name, defO, /*VV*/ &e, /*VV*/ &e2); // find record by name & dfl owner, ancrec.cpp
4051-
if (rc) // (RCBAD not found, RCBAD2 ambiguous 1-92)
4057+
// if (defO) err(PABT, "Hit");
4058+
4059+
rc = basAnc::FindRecByName( b, name, defO | basAnc::frnACCEPTNONOWNER, &e, nullptr, &e2);
4060+
// rc: RCOK: found, RCBAD=not found, RCBAD2=ambiguous
4061+
if (rc)
40524062
{
4053-
if (e) // if bad and entrie(s) returned, is ambiguous match
4063+
if (e && e2) // if bad and entrie(s) returned, is ambiguous match
40544064
ms = strtprintf( MH_S0279, // "ambiguous name: \n"
40554065
what, name, e->whatIn(), // " %s '%s' exists in %s\n"
40564066
e2->whatIn() ); // " and also in %s" */

src/cuprobe.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -479,9 +479,10 @@ RC PROBEOBJECT::po_TryImInProbe()
479479
TI defO = ratDefO(b); /* get 0 or input record subscript in b->ownB of context in which current
480480
expr is being evaluated. Returns 0 if not "owned record" basAnc, if its .ownB
481481
is 0, or cur expr not embedded in stmt group for such a record. cul.cpp. */
482-
RC trc = defO
483-
? b->findRecByNmDefO(name, defO, &e, NULL) // seek record (ancrec.cpp) by name & defO, ret ptr if found.
484-
: b->findRecByNmU(name, NULL, &e); // seek unique record (ancpak.cpp) by name, ret ptr if found.
482+
int ownerTIOpt = defO
483+
? defO | basAnc::frnACCEPTNONOWNER // seek by owner, match non-owned iff owned not found
484+
: basAnc::frnUNIQUE; // search all / match iff unique
485+
RC trc = basAnc::FindRecByName(b, name, ownerTIOpt, &e);
485486
/*if (!evfOk) as below; add if found ambiguity error occurs here
486487
when caller fallthru to runtime probe could work */
487488
if (trc==RCBAD2) // if ambiguity (not resolved by defO)

0 commit comments

Comments
 (0)