Diff
Not logged in

Differences From:

File src/report.c part of check-in [dff17229ff] - Addition to the default style sheet to cover the name/value pairs at the top of the vinfo page. Also a bugfix in the report.c code. by drh on 2007-12-02 22:30:09. Also file src/report.c part of check-in [d0305b305a] - Merged mainline into my branch to get the newest application. by aku on 2007-12-05 08:07:46. [view]

To:

File src/report.c part of check-in [55342eb9fb] - The bug report generator compiles but still does not work right. by drh on 2008-05-17 14:49:49. [view]

@@ -64,9 +64,9 @@
   if( g.okWrTkt ){
     @ <li><a href="rptnew">Create a new report format</a></li>
   }
   @ </ol>
-  common_footer();
+  style_footer();
 }
 
 /*
 ** Remove whitespace from both ends of a string.
@@ -157,9 +157,9 @@
          "plink",
          "event",
          "tag",
          "tagxref",
-      }
+      };
       int i;
       for(i=0; i<sizeof(azAllowed)/sizeof(azAllowed[0]); i++){
         if( strcasecmp(zArg1, azAllowed[i])==0 ) break;
       }
@@ -184,11 +184,12 @@
 ** there is a problem.
 */
 char *verify_sql_statement(char *zSql){
   int i;
-  char *zErr1 = 0;
-  char *zErr2 = 0;
-  char *zTail;
+  char *zErr = 0;
+  const char *zTail;
+  sqlite3_stmt *pStmt;
+  int rc;
 
   /* First make sure the SQL is a single query command by verifying that
   ** the first token is "SELECT" and that there are no unquoted semicolons.
   */
@@ -216,9 +217,8 @@
   /* Compile the statement and check for illegal accesses or syntax errors. */
   sqlite3_set_authorizer(g.db, report_query_authorizer, (void*)&zErr);
   rc = sqlite3_prepare(g.db, zSql, -1, &pStmt, &zTail);
   if( rc!=SQLITE_OK ){
-    free(zErr);
     zErr = mprintf("Syntax error: %s", sqlite3_errmsg(g.db));
   }
   if( pStmt ){
     sqlite3_finalize(pStmt);
@@ -230,13 +230,13 @@
 /*
 ** WEBPAGE: /rptsql
 */
 void view_see_sql(void){
-  int rn, rc;
-  char *zTitle;
-  char *zSQL;
-  char *zOwner;
-  char *zClrKey;
+  int rn;
+  const char *zTitle;
+  const char *zSQL;
+  const char *zOwner;
+  const char *zClrKey;
   Stmt q;
 
   login_check_credentials();
   if( !g.okQuery ){
@@ -290,9 +290,9 @@
   if( !g.okQuery ){
     login_needed();
     return;
   }
-  view_add_functions(0);
+  /*view_add_functions(0);*/
   rn = atoi(PD("rn","0"));
   zTitle = P("t");
   zOwner = PD("w",g.zLogin);
   z = P("s");
@@ -379,8 +379,9 @@
       @ #cacae5 Deferred
       @ #c8c8c8 Closed
     ;
   }else{
+    Stmt q;
     db_prepare(&q, "SELECT title, sqlcode, owner, cols "
                      "FROM reportfmt WHERE rn=%d",rn);
     if( db_step(&q)==SQLITE_ROW ){
       zTitle = db_column_malloc(&q, 0);
@@ -387,8 +388,9 @@
       zSQL = db_column_malloc(&q, 1);
       zOwner = db_column_malloc(&q, 2);
       zClrKey = db_column_malloc(&q, 3);
     }
+    db_finalize(&q);
     if( P("copy") ){
       rn = 0;
       zTitle = mprintf("Copy Of %s", zTitle);
       zOwner = g.zLogin;
@@ -612,25 +614,8 @@
   @ </pre></blockquote>
   @
 }
 
-/*********************************************************************/
-static void output_report_field(const char *zData,int rn){
-  const char *zWkey = wiki_key();
-  const char *zTkey = tkt_key();
-  const char *zCkey = chng_key();
-
-  if( !strncmp(zData,zWkey,strlen(zWkey)) ){
-    output_formatted(&zData[strlen(zWkey)],0);
-  }else if( !strncmp(zData,zTkey,strlen(zTkey)) ){
-    output_ticket(atoi(&zData[strlen(zTkey)]),rn);
-  }else if( !strncmp(zData,zCkey,strlen(zCkey)) ){
-    output_chng(atoi(&zData[strlen(zCkey)]));
-  }else{
-    @ %h(zData)
-  }
-}
-
 static void column_header(int rn,const char *zCol, int nCol, int nSorted,
     const char *zDirection, const char *zExtra
 ){
   int set = (nCol==nSorted);
@@ -656,24 +641,26 @@
     @ %s(zExtra)">%h(zCol)</a></th>
   }
 }
 
-/*********************************************************************/
+/*
+** The state of the report generation.
+*/
 struct GenerateHTML {
-  int rn;
-  int nCount;
+  int rn;        /* Report number */
+  int nCount;    /* Row number */
 };
 
 /*
 ** The callback function for db_query
 */
 static int generate_html(
-  void* pUser,     /* Pointer to output state */
+  void *pUser,     /* Pointer to output state */
   int nArg,        /* Number of columns in this result row */
   char **azArg,    /* Text of data in all columns */
   char **azName    /* Names of the columns */
 ){
-  struct GenerateHTML* pState = (struct GenerateHTML*)pUser;
+  struct GenerateHTML *pState = (struct GenerateHTML*)pUser;
   int i;
   int tn;            /* Ticket number.  (value of column named '#') */
   int rn;            /* Report number */
   int ncol;          /* Number of columns in the table */
@@ -715,39 +702,8 @@
 
   /* The first time this routine is called, output a table header
   */
   if( pState->nCount==0 ){
-    char zExtra[2000];
-    int nField = atoi(PD("order_by","0"));
-    const char* zDir = PD("order_dir","");
-    zDir = !strcmp("ASC",zDir) ? "ASC" : "DESC";
-    zExtra[0] = 0;
-
-    if( g.nAux ){
-      @ <tr>
-      @ <td colspan=%d(ncol)><form action="rptview" method="GET">
-      @ <input type="hidden" name="rn" value="%d(rn)">
-      for(i=0; i<g.nAux; i++){
-        const char *zN = g.azAuxName[i];
-        const char *zP = g.azAuxParam[i];
-        if( g.azAuxVal[i] && g.azAuxVal[i][0] ){
-          appendf(zExtra,0,sizeof(zExtra),
-                  "&amp;%t=%t",g.azAuxParam[i],g.azAuxVal[i]);
-        }
-        if( g.azAuxOpt[i] ){
-          @ %h(zN):
-          if( g.anAuxCols[i]==1 ) {
-            cgi_v_optionmenu( 0, zP, g.azAuxVal[i], g.azAuxOpt[i] );
-          }else if( g.anAuxCols[i]==2 ){
-            cgi_v_optionmenu2( 0, zP, g.azAuxVal[i], g.azAuxOpt[i] );
-          }
-        }else{
-          @ %h(zN): <input type="text" name="%h(zP)" value="%h(g.azAuxVal[i])">
-        }
-      }
-      @ <input type="submit" value="Go">
-      @ </form></td></tr>
-    }
     @ <tr>
     tn = -1;
     for(i=0; i<nArg; i++){
       char *zName = azName[i];
@@ -762,14 +718,8 @@
       }else{
         if( zName[0]=='#' ){
           tn = i;
         }
-        /*
-        ** This handles any sorting related stuff. Note that we don't
-        ** bother trying to sort on the "wiki format" columns. I don't
-        ** think it makes much sense, visually.
-        */
-        column_header(rn,azName[i],i+1,nField,zDir,zExtra);
       }
     }
     if( g.okWrite && tn>=0 ){
       @ <th>&nbsp;</th>
@@ -808,19 +758,18 @@
         tn = 0;
       }
       if( zData[0] ){
         @ </tr><tr bgcolor="%h(zBg)"><td colspan=%d(ncol)>
-        output_formatted(zData, zPage[0] ? zPage : 0);
+        @ %h(zData)
       }
     }else if( azName[i][0]=='#' ){
       tn = atoi(zData);
-      if( tn>0 ) bprintf(zPage, sizeof(zPage), "%d", tn);
       @ <td valign="top"><a href="tktview?tn=%d(tn),%d(rn)">%h(zData)</a></td>
     }else if( zData[0]==0 ){
       @ <td valign="top">&nbsp;</td>
     }else{
       @ <td valign="top">
-      output_report_field(zData,rn);
+      @ %h(zData)
       @ </td>
     }
   }
   if( tn>0 && g.okWrite ){
@@ -935,9 +884,9 @@
     cgi_redirect("reportlist");
     return;
   }
   tabs = P("tablist")!=0;
-  view_add_functions(tabs);
+  /* view_add_functions(tabs); */
   db_prepare(&q,
     "SELECT title, sqlcode, owner, cols FROM reportfmt WHERE rn=%d", rn);
   if( db_step(&q)!=SQLITE_ROW ){
     cgi_redirect("reportlist");
@@ -967,14 +916,14 @@
   count = 0;
   if( !tabs ){
     struct GenerateHTML sState;
 
-    db_execute("PRAGMA empty_result_callbacks=ON");
+    db_multi_exec("PRAGMA empty_result_callbacks=ON");
     style_submenu_element("Raw", "Raw",
-      "rptview?tablist=1&%s", P("QUERY_STRING",""));
+      "rptview?tablist=1&%s", PD("QUERY_STRING",""));
     if( g.okAdmin
        || (g.okQuery && g.zLogin && zOwner && strcmp(g.zLogin,zOwner)==0) ){
-      style_submentu_element("Edit", "Edit", "rptedit?rn=%d", rn);
+      style_submenu_element("Edit", "Edit", "rptedit?rn=%d", rn);
     }
     style_submenu_element("SQL", "SQL", "rptsql?rn=%d",rn);
     style_header(zTitle);
     output_color_key(zClrKey, 1,