Fossil SCM
Make sure the TH1 unset command fails if the variable does not exist.
Commit
99bdfa0b9546e880e726fc716f3c06d8c076d9be
Parent
7164f52baaae3e0…
2 files changed
+1
-1
+10
M
src/th.c
+1
-1
| --- src/th.c | ||
| +++ src/th.c | ||
| @@ -1241,11 +1241,11 @@ | ||
| 1241 | 1241 | ** in the interpreter result and TH_ERROR is returned. |
| 1242 | 1242 | */ |
| 1243 | 1243 | int Th_UnsetVar(Th_Interp *interp, const char *zVar, int nVar){ |
| 1244 | 1244 | Th_Variable *pValue; |
| 1245 | 1245 | |
| 1246 | - pValue = thFindValue(interp, zVar, nVar, 1, 1); | |
| 1246 | + pValue = thFindValue(interp, zVar, nVar, 0, 1); | |
| 1247 | 1247 | if( !pValue ){ |
| 1248 | 1248 | return TH_ERROR; |
| 1249 | 1249 | } |
| 1250 | 1250 | |
| 1251 | 1251 | Th_Free(interp, pValue->zData); |
| 1252 | 1252 |
| --- src/th.c | |
| +++ src/th.c | |
| @@ -1241,11 +1241,11 @@ | |
| 1241 | ** in the interpreter result and TH_ERROR is returned. |
| 1242 | */ |
| 1243 | int Th_UnsetVar(Th_Interp *interp, const char *zVar, int nVar){ |
| 1244 | Th_Variable *pValue; |
| 1245 | |
| 1246 | pValue = thFindValue(interp, zVar, nVar, 1, 1); |
| 1247 | if( !pValue ){ |
| 1248 | return TH_ERROR; |
| 1249 | } |
| 1250 | |
| 1251 | Th_Free(interp, pValue->zData); |
| 1252 |
| --- src/th.c | |
| +++ src/th.c | |
| @@ -1241,11 +1241,11 @@ | |
| 1241 | ** in the interpreter result and TH_ERROR is returned. |
| 1242 | */ |
| 1243 | int Th_UnsetVar(Th_Interp *interp, const char *zVar, int nVar){ |
| 1244 | Th_Variable *pValue; |
| 1245 | |
| 1246 | pValue = thFindValue(interp, zVar, nVar, 0, 1); |
| 1247 | if( !pValue ){ |
| 1248 | return TH_ERROR; |
| 1249 | } |
| 1250 | |
| 1251 | Th_Free(interp, pValue->zData); |
| 1252 |
+10
| --- test/th1.test | ||
| +++ test/th1.test | ||
| @@ -132,5 +132,15 @@ | ||
| 132 | 132 | |
| 133 | 133 | ############################################################################### |
| 134 | 134 | |
| 135 | 135 | fossil test-th-eval "set var 1; unset var; expr {\$var+0}" |
| 136 | 136 | test th1-info-exists-5 {$RESULT eq {TH_ERROR: no such variable: var}} |
| 137 | + | |
| 138 | +############################################################################### | |
| 139 | + | |
| 140 | +fossil test-th-eval "set var 1; unset var" | |
| 141 | +test th1-unset-1 {$RESULT eq {var}} | |
| 142 | + | |
| 143 | +############################################################################### | |
| 144 | + | |
| 145 | +fossil test-th-eval "unset var" | |
| 146 | +test th1-unset-2 {$RESULT eq {TH_ERROR: no such variable: var}} | |
| 137 | 147 |
| --- test/th1.test | |
| +++ test/th1.test | |
| @@ -132,5 +132,15 @@ | |
| 132 | |
| 133 | ############################################################################### |
| 134 | |
| 135 | fossil test-th-eval "set var 1; unset var; expr {\$var+0}" |
| 136 | test th1-info-exists-5 {$RESULT eq {TH_ERROR: no such variable: var}} |
| 137 |
| --- test/th1.test | |
| +++ test/th1.test | |
| @@ -132,5 +132,15 @@ | |
| 132 | |
| 133 | ############################################################################### |
| 134 | |
| 135 | fossil test-th-eval "set var 1; unset var; expr {\$var+0}" |
| 136 | test th1-info-exists-5 {$RESULT eq {TH_ERROR: no such variable: var}} |
| 137 | |
| 138 | ############################################################################### |
| 139 | |
| 140 | fossil test-th-eval "set var 1; unset var" |
| 141 | test th1-unset-1 {$RESULT eq {var}} |
| 142 | |
| 143 | ############################################################################### |
| 144 | |
| 145 | fossil test-th-eval "unset var" |
| 146 | test th1-unset-2 {$RESULT eq {TH_ERROR: no such variable: var}} |
| 147 |