Fossil

Check-in [99bdfa0b]
Login

Check-in [99bdfa0b]

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

Overview
Comment:Make sure the TH1 unset command fails if the variable does not exist.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 99bdfa0b9546e880e726fc716f3c06d8c076d9be
User & Date: mistachkin 2014-01-05 23:05:55
Context
2014-01-06
02:54
Add 'file' class to file browser/tree items even if the file has an extension. ... (check-in: e5606c94 user: joel tags: trunk)
2014-01-05
23:05
Make sure the TH1 unset command fails if the variable does not exist. ... (check-in: 99bdfa0b user: mistachkin tags: trunk)
22:53
Fix TH1 'info exists' command for variables that have been unset. ... (check-in: 7164f52b user: mistachkin tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/th.c.

1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
** an array, or an array member. If the identified variable exists, it
** is deleted and TH_OK returned. Otherwise, an error message is left
** in the interpreter result and TH_ERROR is returned.
*/
int Th_UnsetVar(Th_Interp *interp, const char *zVar, int nVar){
  Th_Variable *pValue;

  pValue = thFindValue(interp, zVar, nVar, 1, 1);
  if( !pValue ){
    return TH_ERROR;
  }

  Th_Free(interp, pValue->zData);
  pValue->zData = 0;
  if( pValue->pHash ){







|







1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
** an array, or an array member. If the identified variable exists, it
** is deleted and TH_OK returned. Otherwise, an error message is left
** in the interpreter result and TH_ERROR is returned.
*/
int Th_UnsetVar(Th_Interp *interp, const char *zVar, int nVar){
  Th_Variable *pValue;

  pValue = thFindValue(interp, zVar, nVar, 0, 1);
  if( !pValue ){
    return TH_ERROR;
  }

  Th_Free(interp, pValue->zData);
  pValue->zData = 0;
  if( pValue->pHash ){

Changes to test/th1.test.

130
131
132
133
134
135
136










fossil test-th-eval "set var 1; expr {\$var+0}"
test th1-info-exists-4 {$RESULT eq {1}}

###############################################################################

fossil test-th-eval "set var 1; unset var; expr {\$var+0}"
test th1-info-exists-5 {$RESULT eq {TH_ERROR: no such variable: var}}

















>
>
>
>
>
>
>
>
>
>
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
fossil test-th-eval "set var 1; expr {\$var+0}"
test th1-info-exists-4 {$RESULT eq {1}}

###############################################################################

fossil test-th-eval "set var 1; unset var; expr {\$var+0}"
test th1-info-exists-5 {$RESULT eq {TH_ERROR: no such variable: var}}

###############################################################################

fossil test-th-eval "set var 1; unset var"
test th1-unset-1 {$RESULT eq {var}}

###############################################################################

fossil test-th-eval "unset var"
test th1-unset-2 {$RESULT eq {TH_ERROR: no such variable: var}}