Diff
Not logged in

Differences From:

File src/th_main.c part of check-in [0c99a1554a] - Modify the TH1 script interperter to use native characters rather than unsigned characters. Fix a bug in the combobox extension command of TH1. by drh on 2008-10-24 16:36:34. [view]

To:

File src/th_main.c part of check-in [f55c6a1b62] - Begin adding a TH1 script trace mechanism actived by the --th_trace option on the "server" and "ui" commands. The implementation is incomplete, but the plane is landing.... by drh on 2008-10-24 18:23:23. [view]

@@ -51,8 +51,18 @@
   free(p);
 }
 static Th_Vtab vtab = { xMalloc, xFree };
 
+/*
+** Generate a TH1 trace message if debugging is enabled.
+*/
+void Th_Trace(const char *zFormat, ...){
+  va_list ap;
+  va_start(ap, zFormat);
+  blob_vappendf(&g.thLog, zFormat, ap);
+  va_end(ap);
+}
+
 
 /*
 ** True if output is enabled.  False if disabled.
 */
@@ -192,10 +202,15 @@
   int argc,
   const char **argv,
   int *argl
 ){
+  int rc;
   if( argc!=2 ){
     return Th_WrongNumArgs(interp, "hascap STRING");
+  }
+  rc = login_has_capability((char*)argv[1],argl[1]);
+  if( g.thTrace ){
+    Th_Trace("[hascap %.*h] => %d<br />\n", argl[1], argv[1], rc);
   }
   Th_SetResultInt(interp, login_has_capability((char*)argv[1],argl[1]));
   return TH_OK;
 }
@@ -293,9 +308,12 @@
   return TH_OK;
 }
 
 /*
-** Make sure the interpreter has been initialized.
+** Make sure the interpreter has been initialized.  Initialize it if
+** it has not been already.
+**
+** The interpreter is stored in the g.interp global variable.
 */
 void Th_FossilInit(void){
   static struct _Command {
     const char *zName;
@@ -328,9 +346,12 @@
 */
 void Th_Store(const char *zName, const char *zValue){
   Th_FossilInit();
   if( zValue ){
-    Th_SetVar(g.interp, (char*)zName, -1, (char*)zValue, strlen(zValue));
+    if( g.thTrace ){
+      Th_Trace("set %h {%h}<br />\n", zName, zValue);
+    }
+    Th_SetVar(g.interp, zName, -1, zValue, strlen(zValue));
   }
 }
 
 /*