Enhanced the code that deals with FORM variables.
[egate.git] / www / wtcl.c
index 69d0ab4..ea5b2ce 100644 (file)
@@ -41,6 +41,9 @@
  * USE OR PERFORMANCE OF THIS SOFTWARE.
  *
  * $Log: wtcl.c,v $
+ * Revision 1.22  1997/12/15 15:05:03  adam
+ * Enhanced the code that deals with FORM variables.
+ *
  * Revision 1.21  1997/02/10 10:15:40  adam
  * Bug fix: egw_source <file> <var> didn't work properly.
  *
@@ -206,7 +209,6 @@ static int proc_form_invoke (struct tcl_info *p, wform_data *wfdata,
 {
     const char *arg = NULL;
     int failFlag = 0;
-    int i;
 
     if (argc == 3)
     {
@@ -231,27 +233,27 @@ static int proc_form_invoke (struct tcl_info *p, wform_data *wfdata,
         arg = argv[1];
     if (arg)
     {
-        for (i = 0; *wfdata[i].name; i++)
-            if (!strcmp (arg, wfdata[i].name))
+        for (; wfdata; wfdata = wfdata->next)
+            if (!strcmp (arg, wfdata->name))
             {
                 failFlag = 0;
-                if (*wfdata[i].value)
-                    Tcl_AppendElement (p->interp, wfdata[i].value);
+                if (wfdata->value)
+                    Tcl_AppendElement (p->interp, wfdata->value);
             }
         if (failFlag)
         {
             Tcl_AppendResult (p->interp, arg, " doesn't exist", NULL);
             return TCL_ERROR;
         }
-        return TCL_OK;
     }    
-    for (i = 0; *wfdata[i].name; i++)
-    {
-        Tcl_AppendResult (p->interp, "{ ", NULL);
-        Tcl_AppendElement (p->interp, wfdata[i].name);
-        Tcl_AppendElement (p->interp, wfdata[i].value);
-        Tcl_AppendResult (p->interp, " }\n", NULL);
-    }
+    else
+        for ( ; wfdata; wfdata = wfdata->next)
+        {
+            Tcl_AppendResult (p->interp, "{ ", NULL);
+            Tcl_AppendElement (p->interp, wfdata->name);
+            Tcl_AppendElement (p->interp, wfdata->value ? wfdata->value : "");
+            Tcl_AppendResult (p->interp, " }\n", NULL);
+        }
     return TCL_OK;
 }