On Sun, 5 Jan 2014, Sergei Gavrikov wrote:

[no lyrics]

>   % ./fossil version
>   This is fossil version 1.28 [da90bbe591] 2014-01-04 16:17:47 UTC
>   % ./fossil test-th-eval 'set v 1; unset v; info exists v'
>   1
>
> We expect 0. No issues with unset
>
>   % ./fossil test-th-eval 'set v 1; unset v; expr $v+0'
>   TH_ERROR: no such variable: v

Hm, unset

  % ./fossil test-th-eval 'unset absent'
  absent

Th_UnsetVar() creates (creatok=1), then unset variable. So, unset never
raise an error. It is okay?

With patch below TH1 behaves like TCL

  % ./fossil test-th-eval 'unset absent'
  TH_ERROR: no such variable: absent
  % ./fossil test-th-eval 'set v 1; unset v; info exists v'
  0

Sergei

--- src/th.c
+++ src/th.c
@@ -1154,11 +1154,12 @@

 /*
 ** Return true if variable (zVar, nVar) exists.
 */
 int Th_ExistsVar(Th_Interp *interp, const char *zVar, int nVar){
-  return thFindValue(interp, zVar, nVar, 0, 0)!=0;
+  Th_Variable *pValue = thFindValue(interp, zVar, nVar, 0, 0);
+  return pValue!=0 && pValue->zData!=0;
 }

 /*
 ** String (zVar, nVar) must contain the name of a scalar variable or
 ** array member. If the variable does not exist it is created. The
@@ -1240,11 +1241,11 @@
 ** 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);
+  pValue = thFindValue(interp, zVar, nVar, 0, 1);
   if( !pValue ){
     return TH_ERROR;
   }

   Th_Free(interp, pValue->zData);
_______________________________________________
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users

Reply via email to