Diff
Not logged in

Differences From:

File src/subscript.c part of check-in [e29abeff80] - Add the SbS_Render() interface for rendering HTML with embedded subscript. by drh on 2007-11-20 23:54:34. [view]

To:

File src/subscript.c part of check-in [555911dff5] - Render the header of every page using subscript. Add a setup page that for editing that subscript. by drh on 2007-11-21 03:01:40. [view]

@@ -378,8 +378,29 @@
   return sbs_store(&p->symTab, zVerb, -1, &v);
 }
 
 /*
+** Store a value in an interpreter variable.
+*/
+int SbS_Store(
+  struct Subscript *p,   /* Store into this interpreter */
+  const char *zName,     /* Name of the variable */
+  const char *zValue,    /* Value of the variable */
+  int makeCopy           /* If true, interpreter makes its own copy */
+){
+  SbSValue v;
+  v.flags = SBSVAL_STR;
+  v.u.str.size = strlen(zValue);
+  if( makeCopy ){
+    v.u.str.z = mprintf("%s", zValue);
+    v.flags |= SBSVAL_DYN;
+  }else{
+    v.u.str.z = zValue;
+  }
+  return sbs_store(&p->symTab, zName, -1, &v);
+}
+
+/*
 ** Push a string value onto the stack.
 **
 ** If the 4th parameter is 0, then the string is static.
 ** If the 4th parameter is non-zero then the string was obtained
@@ -779,9 +800,8 @@
 #if 0
     {
       int i, nElem;
       const char *zElem;
-      printf("TOKEN(%d): [%.*s]\n", ttype, n, zScript);
       if( p->nStack>0 ){
         printf("STACK:");
         for(i=0; i<p->nStack; i++){
           zElem = SbS_StackValue(p, i, &nElem);
@@ -788,8 +808,9 @@
           printf(" [%.*s]", nElem, zElem);
         }
         printf("\n");
       }
+      printf("TOKEN(%d): [%.*s]\n", ttype, n, zScript);
     }
 #endif
 
     switch( ttype ){
@@ -865,12 +886,14 @@
   int i = 0;
   int rc = SBS_OK;
   while( z[i] ){
     if( z[i]=='[' ){
-      if( g.cgiPanic ){
-        cgi_append_content(z, i);
-      }else{
-        fwrite(z, 1, i, stdout);
+      if( enableOutput ){
+        if( g.cgiPanic ){
+          cgi_append_content(z, i);
+        }else{
+          fwrite(z, 1, i, stdout);
+        }
       }
       z += i+1;
       for(i=0; z[i] && z[i]!=']'; i++){}
       rc = SbS_Eval(p, z, i);
@@ -881,9 +904,9 @@
     }else{
       i++;
     }
   }
-  if( i>0 ){
+  if( i>0 && enableOutput ){
     if( g.cgiPanic ){
       cgi_append_content(z, i);
     }else{
       fwrite(z, 1, i, stdout);