Fossil SCM

Simplify usage of the new TH1 Find structure.

mistachkin 2014-01-14 13:30 UTC th1UnsetVar
Commit b0eb21b66a270c913e8803c68563ee4d524325a6
1 file changed +3 -4
+3 -4
--- src/th.c
+++ src/th.c
@@ -1053,13 +1053,12 @@
10531053
}
10541054
10551055
/*
10561056
** The Find structure is used to return extra information to callers of the
10571057
** thFindValue function. The fields within it are populated by thFindValue
1058
-** as soon as the necessary information is available. Callers should zero
1059
-** out the structure prior to calling thFindValue and then check each field
1060
-** of interest upon return.
1058
+** as soon as the necessary information is available. Callers should check
1059
+** each field of interest upon return.
10611060
*/
10621061
10631062
struct Find {
10641063
Th_HashEntry *pValueEntry; /* Pointer to the scalar or array hash entry */
10651064
Th_HashEntry *pElemEntry; /* Pointer to the element hash entry, if any */
@@ -1101,10 +1100,11 @@
11011100
Th_Frame *pFrame = interp->pFrame;
11021101
Th_Variable *pValue;
11031102
11041103
thAnalyseVarname(zVar, nVar, &zOuter, &nOuter, &zInner, &nInner, &isGlobal);
11051104
if( pFind ){
1105
+ memset(pFind, 0, sizeof(Find));
11061106
pFind->zElem = zInner;
11071107
pFind->nElem = nInner;
11081108
}
11091109
if( isGlobal ){
11101110
while( pFrame->pCaller ) pFrame = pFrame->pCaller;
@@ -1288,11 +1288,10 @@
12881288
Find find;
12891289
Th_Variable *pValue;
12901290
Th_HashEntry *pEntry;
12911291
int rc = TH_ERROR;
12921292
1293
- memset(&find, 0, sizeof(Find));
12941293
pValue = thFindValue(interp, zVar, nVar, 0, 1, 0, &find);
12951294
if( !pValue ){
12961295
return rc;
12971296
}
12981297
12991298
--- src/th.c
+++ src/th.c
@@ -1053,13 +1053,12 @@
1053 }
1054
1055 /*
1056 ** The Find structure is used to return extra information to callers of the
1057 ** thFindValue function. The fields within it are populated by thFindValue
1058 ** as soon as the necessary information is available. Callers should zero
1059 ** out the structure prior to calling thFindValue and then check each field
1060 ** of interest upon return.
1061 */
1062
1063 struct Find {
1064 Th_HashEntry *pValueEntry; /* Pointer to the scalar or array hash entry */
1065 Th_HashEntry *pElemEntry; /* Pointer to the element hash entry, if any */
@@ -1101,10 +1100,11 @@
1101 Th_Frame *pFrame = interp->pFrame;
1102 Th_Variable *pValue;
1103
1104 thAnalyseVarname(zVar, nVar, &zOuter, &nOuter, &zInner, &nInner, &isGlobal);
1105 if( pFind ){
 
1106 pFind->zElem = zInner;
1107 pFind->nElem = nInner;
1108 }
1109 if( isGlobal ){
1110 while( pFrame->pCaller ) pFrame = pFrame->pCaller;
@@ -1288,11 +1288,10 @@
1288 Find find;
1289 Th_Variable *pValue;
1290 Th_HashEntry *pEntry;
1291 int rc = TH_ERROR;
1292
1293 memset(&find, 0, sizeof(Find));
1294 pValue = thFindValue(interp, zVar, nVar, 0, 1, 0, &find);
1295 if( !pValue ){
1296 return rc;
1297 }
1298
1299
--- src/th.c
+++ src/th.c
@@ -1053,13 +1053,12 @@
1053 }
1054
1055 /*
1056 ** The Find structure is used to return extra information to callers of the
1057 ** thFindValue function. The fields within it are populated by thFindValue
1058 ** as soon as the necessary information is available. Callers should check
1059 ** each field of interest upon return.
 
1060 */
1061
1062 struct Find {
1063 Th_HashEntry *pValueEntry; /* Pointer to the scalar or array hash entry */
1064 Th_HashEntry *pElemEntry; /* Pointer to the element hash entry, if any */
@@ -1101,10 +1100,11 @@
1100 Th_Frame *pFrame = interp->pFrame;
1101 Th_Variable *pValue;
1102
1103 thAnalyseVarname(zVar, nVar, &zOuter, &nOuter, &zInner, &nInner, &isGlobal);
1104 if( pFind ){
1105 memset(pFind, 0, sizeof(Find));
1106 pFind->zElem = zInner;
1107 pFind->nElem = nInner;
1108 }
1109 if( isGlobal ){
1110 while( pFrame->pCaller ) pFrame = pFrame->pCaller;
@@ -1288,11 +1288,10 @@
1288 Find find;
1289 Th_Variable *pValue;
1290 Th_HashEntry *pEntry;
1291 int rc = TH_ERROR;
1292
 
1293 pValue = thFindValue(interp, zVar, nVar, 0, 1, 0, &find);
1294 if( !pValue ){
1295 return rc;
1296 }
1297
1298

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button