Fixed some bugs with escape sequences.
[egate.git] / www / wtcl.c
index 8772adc..f67fb32 100644 (file)
  * USE OR PERFORMANCE OF THIS SOFTWARE.
  *
  * $Log: wtcl.c,v $
+ * Revision 1.23  1998/03/26 11:29:02  franck
+ * Fixed some bugs with escape sequences.
+ *
+ * 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.
+ *
  * Revision 1.20  1997/01/31 11:16:01  adam
  * Enhanced the egw_source command. An optional parameter specifies the
  * name of a variable in which the HTML output is stored.
@@ -203,7 +212,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)
     {
@@ -228,27 +236,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;
 }
 
@@ -319,7 +327,7 @@ static int proc_enc (ClientData clientData, Tcl_Interp *interp,
         while (*cp)
         { 
             if (*cp < ' ' || *cp >= 127 || *cp == '&' || *cp == '?'
-                || *cp == '%' || *cp == '+')
+                || *cp == '%' || *cp == '+' || *cp == '"' || *cp == '=')
             {
                 sprintf (buf1+1, "%02X", *cp & 0xff);
                 Tcl_AppendResult (interp, buf1, NULL);
@@ -614,15 +622,19 @@ static int exec_file (const char *fname, struct tcl_info *p)
         case '$':
             if (escape)
             {
-                c = getc (inf);
                 wo_putc (p->wcl, c);
+                escape = 0;
+                c = getc (inf);
             }
             else
                 c = var_ref (p, inf);
             break;
         case '{':
             if (escape)
+            {
                 wo_putc (p->wcl, c);
+                escape = 0;
+            }
             else
             {
                 int r = tcl_exec (fname, p, inf, &lineno);
@@ -637,7 +649,6 @@ static int exec_file (const char *fname, struct tcl_info *p)
                     return -2;
                 }
             }
-            escape = 0;
             c = getc (inf);
             break;
         default: