| | @@ -291,36 +291,45 @@ |
| 291 | 291 | } |
| 292 | 292 | return rc; |
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | /* |
| 296 | | -** TH1 command: enable_htmlify BOOLEAN |
| 296 | +** TH1 command: enable_htmlify ?BOOLEAN? |
| 297 | 297 | ** |
| 298 | 298 | ** Enable or disable the HTML escaping done by all output which |
| 299 | 299 | ** originates from TH1 (via sendText()). |
| 300 | +** |
| 301 | +** If passed no arguments it instead returns 0 or 1 to indicate the |
| 302 | +** current state. |
| 300 | 303 | */ |
| 301 | 304 | static int enableHtmlifyCmd( |
| 302 | 305 | Th_Interp *interp, |
| 303 | 306 | void *p, |
| 304 | 307 | int argc, |
| 305 | 308 | const char **argv, |
| 306 | 309 | int *argl |
| 307 | 310 | ){ |
| 308 | | - int rc, buul; |
| 309 | | - if( argc<2 || argc>3 ){ |
| 311 | + int rc = 0, buul; |
| 312 | + if( argc>3 ){ |
| 310 | 313 | return Th_WrongNumArgs(interp, |
| 311 | | - "enable_htmlify [TRACE_LABEL] BOOLEAN"); |
| 312 | | - } |
| 313 | | - rc = Th_ToInt(interp, argv[argc-1], argl[argc-1], &buul); |
| 314 | | - if( g.thTrace ){ |
| 315 | | - Th_Trace("enable_htmlify {%.*s} -> %d<br />\n", |
| 316 | | - argl[1],argv[1],buul); |
| 317 | | - } |
| 318 | | - if(buul){ |
| 319 | | - g.th1Flags &= ~TH_INIT_NO_ENCODE; |
| 320 | | - }else{ |
| 321 | | - g.th1Flags |= TH_INIT_NO_ENCODE; |
| 314 | + "enable_htmlify [TRACE_LABEL] ?BOOLEAN?"); |
| 315 | + } |
| 316 | + buul = (TH_INIT_NO_ENCODE & g.th1Flags) ? 0 : 1; |
| 317 | + Th_SetResultInt(g.interp, buul); |
| 318 | + if(argc>1){ |
| 319 | + if( g.thTrace ){ |
| 320 | + Th_Trace("enable_htmlify {%.*s} -> %d<br />\n", |
| 321 | + argl[1],argv[1],buul); |
| 322 | + } |
| 323 | + rc = Th_ToInt(interp, argv[argc-1], argl[argc-1], &buul); |
| 324 | + if(!rc){ |
| 325 | + if(buul){ |
| 326 | + g.th1Flags &= ~TH_INIT_NO_ENCODE; |
| 327 | + }else{ |
| 328 | + g.th1Flags |= TH_INIT_NO_ENCODE; |
| 329 | + } |
| 330 | + } |
| 322 | 331 | } |
| 323 | 332 | return rc; |
| 324 | 333 | } |
| 325 | 334 | |
| 326 | 335 | /* |
| | @@ -2737,11 +2746,11 @@ |
| 2737 | 2746 | Blob * const origOut = Th_SetOutputBlob(pOut); |
| 2738 | 2747 | |
| 2739 | 2748 | assert(0==(TH_R2B_MASK & TH_INIT_MASK) && "init/r2b mask conflict"); |
| 2740 | 2749 | Th_FossilInit(mFlags & TH_INIT_MASK); |
| 2741 | 2750 | while( z[i] ){ |
| 2742 | | - if( 0!=(TH_R2B_NO_VARS & mFlags) |
| 2751 | + if( 0==(TH_R2B_NO_VARS & mFlags) |
| 2743 | 2752 | && z[i]=='$' && (n = validVarName(&z[i+1]))>0 ){ |
| 2744 | 2753 | const char *zVar; |
| 2745 | 2754 | int nVar; |
| 2746 | 2755 | int encode = 1; |
| 2747 | 2756 | sendText(pOut,z, i, 0); |
| 2748 | 2757 | |