Diff
Not logged in

Differences From:

File src/tkt.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/tkt.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]

@@ -331,12 +331,15 @@
     style_submenu_element("Timeline", "Timeline Of This Ticket",
         "%s/tkttimeline/%T", g.zTop, zUuid);
   }
   style_header("View Ticket");
+  if( g.thTrace ) Th_Trace("BEGIN_TKTVIEW<br />\n", -1);
   ticket_init();
   initializeVariablesFromDb();
   zScript = ticket_viewpage_code();
+  if( g.thTrace ) Th_Trace("BEGIN_TKTVIEW_SCRIPT<br />\n", -1);
   Th_Render(zScript);
+  if( g.thTrace ) Th_Trace("END_TKTVIEW<br />\n", -1);
   style_footer();
 }
 
 /*
@@ -350,18 +353,22 @@
 static int appendRemarkCmd(
   Th_Interp *interp,
   void *p,
   int argc,
-  const unsigned char **argv,
+  const char **argv,
   int *argl
 ){
   int idx;
 
   if( argc!=3 ){
     return Th_WrongNumArgs(interp, "append_field FIELD STRING");
   }
+  if( g.thTrace ){
+    Th_Trace("append_field %#h {%#h}<br />\n",
+              argl[1], argv[1], argl[2], argv[2]);
+  }
   for(idx=0; idx<nField; idx++){
-    if( strncmp(azField[idx], (const char*)argv[1], argl[1])==0
+    if( strncmp(azField[idx], argv[1], argl[1])==0
         && azField[idx][argl[1]]==0 ){
       break;
     }
   }
@@ -385,9 +392,9 @@
 static int submitTicketCmd(
   Th_Interp *interp,
   void *pUuid,
   int argc,
-  const unsigned char **argv,
+  const char **argv,
   int *argl
 ){
   char *zDate;
   const char *zUuid;
@@ -433,22 +440,19 @@
   blob_appendf(&tktchng, "K %s\n", zUuid);
   blob_appendf(&tktchng, "U %F\n", g.zLogin ? g.zLogin : "");
   md5sum_blob(&tktchng, &cksum);
   blob_appendf(&tktchng, "Z %b\n", &cksum);
-
-  if( strncmp(g.zPath,"debug_",6)==0 ){
-    @ <hr><pre>
-    @ %h(blob_str(&tktchng))
-    @ </pre><hr>
-    blob_zero(&tktchng);
-    return TH_OK;
-  }
-
-  rid = content_put(&tktchng, 0, 0);
-  if( rid==0 ){
-    fossil_panic("trouble committing ticket: %s", g.zErrMsg);
-  }
-  manifest_crosslink(rid, &tktchng);
+  if( g.thTrace ){
+    Th_Trace("submit_ticket {\n<blockquote><pre>\n%h\n</pre></blockquote>\n"
+             "}<br />\n",
+       blob_str(&tktchng));
+  }else{
+    rid = content_put(&tktchng, 0, 0);
+    if( rid==0 ){
+      fossil_panic("trouble committing ticket: %s", g.zErrMsg);
+    }
+    manifest_crosslink(rid, &tktchng);
+  }
   return TH_RETURN;
 }
 
 
@@ -473,8 +477,9 @@
   if( P("cancel") ){
     cgi_redirect("home");
   }
   style_header("New Ticket");
+  if( g.thTrace ) Th_Trace("BEGIN_TKTNEW<br />\n", -1);
   ticket_init();
   getAllTicketFields();
   initializeVariablesFromDb();
   initializeVariablesFromCGI();
@@ -484,13 +489,15 @@
   Th_Store("login", g.zLogin);
   Th_Store("date", db_text(0, "SELECT datetime('now')"));
   Th_CreateCommand(g.interp, "submit_ticket", submitTicketCmd,
                    (void*)&zNewUuid, 0);
-  if( Th_Render(zScript)==TH_RETURN && zNewUuid ){
+  if( g.thTrace ) Th_Trace("BEGIN_TKTNEW_SCRIPT<br />\n", -1);
+  if( Th_Render(zScript)==TH_RETURN && !g.thTrace && zNewUuid ){
     cgi_redirect(mprintf("%s/tktview/%s", g.zBaseURL, zNewUuid));
     return;
   }
   @ </form>
+  if( g.thTrace ) Th_Trace("END_TKTVIEW<br />\n", -1);
   style_footer();
 }
 
 /*
@@ -534,8 +541,9 @@
     @ <font color="red"><b>%d(nRec) tickets begin with: \"%h(zName)\"</b></font>
     style_footer();
     return;
   }
+  if( g.thTrace ) Th_Trace("BEGIN_TKTEDIT<br />\n", -1);
   ticket_init();
   getAllTicketFields();
   initializeVariablesFromCGI();
   initializeVariablesFromDb();
@@ -546,13 +554,15 @@
   Th_Store("login", g.zLogin);
   Th_Store("date", db_text(0, "SELECT datetime('now')"));
   Th_CreateCommand(g.interp, "append_field", appendRemarkCmd, 0, 0);
   Th_CreateCommand(g.interp, "submit_ticket", submitTicketCmd, (void*)&zName,0);
-  if( Th_Render(zScript)==TH_RETURN && zName ){
+  if( g.thTrace ) Th_Trace("BEGIN_TKTEDIT_SCRIPT<br />\n", -1);
+  if( Th_Render(zScript)==TH_RETURN && !g.thTrace && zName ){
     cgi_redirect(mprintf("%s/tktview/%s", g.zBaseURL, zName));
     return;
   }
   @ </form>
+  if( g.thTrace ) Th_Trace("BEGIN_TKTEDIT<br />\n", -1);
   style_footer();
 }
 
 /*