rem: Ns_DString ds; char buf[10], *script, debugfile[255];
context: EvalChunks(NsInterp *itPtr, char *chunks){    int chunk, n, code, fd;    register char *ch = chunks;    Ns_DString ds;    char buf[10], *script, debugfile[255];    Tcl_Interp *interp = itPtr->interp;    char *file = itPtr->adp.file;    if (Ns_CheckStack() != NS_OK) {        interp->result =  "danger: stack grown too large (recursive adp?)";	itPtr->adp.exception = ADP_OVERFLOW;        return TCL_ERROR;    }    Ns_DStringInit(&ds);    code = TCL_OK;    chunk = 1;    while (*ch && itPtr->adp.exception == ADP_OK) {	n = strlen(ch);	if (*ch++ == 't') {	    Ns_DStringNAppend(itPtr->adp.outputPtr, ch, n-1);	} else {	    script = ch;	    if (itPtr->adp.debugLevel > 0) {		Ns_DStringTrunc(&ds, 0);		sprintf(buf, "%d", itPtr->adp.debugLevel);		Ns_DStringVarAppend(&ds,		    "#\n"		    "# level: ", buf, "\n", NULL);		sprintf(buf, "%d", chunk);		Ns_DStringVarAppend(&ds,		    "# chunk: ", buf, "\n"		    "# file:  ", file, "\n"		    "#\n\n", ch, NULL);		sprintf(debugfile, P_tmpdir "/adp%d.%d.XXXXXX",			itPtr->adp.debugLevel, chunk);		mktemp(debugfile);		fd = open(debugfile, O_WRONLY|O_TRUNC|O_CREAT|O_TEXT, 0644);		if (fd < 0) {		    Ns_Log(Error, "adp: failed to open %s: %s",			   debugfile, strerror(errno));		} else {		    write(fd, ds.string, ds.length);		    close(fd);		    Ns_DStringTrunc(&ds, 0);		    Ns_DStringVarAppend(&ds, "source ", debugfile, NULL);		    script = ds.string;		}	    }    	    code = NsTclEval(interp, script);	    if (code != TCL_OK &&		code != TCL_RETURN &&		itPtr->adp.exception == ADP_OK) {    	    	LogError(itPtr, chunk);	    }	    if (itPtr->adp.exception == ADP_RETURN) {		itPtr->adp.exception = ADP_OK;		code = TCL_OK;		if (script != ch) {		    unlink(debugfile);		}		goto done;		break;	    }	    if (script != ch) {		unlink(debugfile);	    }	    ++chunk;	}	ch += n;	NsAdpFlush(itPtr);    }     done:    NsAdpFlush(itPtr);    Ns_DStringFree(&ds);        return code;}