rem: Ns_DString ds, *dsPtr;
add: Ns_DString chunks, path;
context: AdpRun(NsInterp *itPtr, char *file, int argc, char **argv, Ns_DString *outputPtr){    NsServer  *servPtr = itPtr->servPtr;    Tcl_Interp *interp = itPtr->interp;    struct stat st;    Ns_DString ds, *dsPtr;    Frame frame;    Page *pagePtr;    Ns_Entry *ePtr;    int new, status;    char *p, *key;    Ns_Cache *cachePtr;        pagePtr = NULL;    status = TCL_ERROR;    dsPtr = Ns_DStringPop();    Ns_DStringInit(&ds);        /*     * Construct the full, normalized path to the ADP file.     */    if (Ns_PathIsAbsolute(file)) {	Ns_NormalizePath(&ds, file);    } else {	Ns_MakePath(dsPtr, itPtr->adp.cwd, file, NULL);	Ns_NormalizePath(&ds, dsPtr->string);	Ns_DStringTrunc(dsPtr, 0);    }    file = ds.string;    /*     * Check for TclPro debugging.     */    if (itPtr->adp.debugLevel > 0) {	++itPtr->adp.debugLevel;    } else if (servPtr->adp.enabledebug != NS_FALSE &&	itPtr->adp.debugFile != NULL &&	(p = strrchr(file, '/')) != NULL &&	Tcl_StringMatch(p+1, itPtr->adp.debugFile)) {	Ns_Set *hdrs;	char *host, *port, *procs;	hdrs = Ns_ConnGetQuery(itPtr->conn);	host = Ns_SetIGet(hdrs, "dhost");	port = Ns_SetIGet(hdrs, "dport");	procs = Ns_SetIGet(hdrs, "dprocs");	if (NsAdpDebug(itPtr, host, port, procs) != TCL_OK) {	    Ns_ConnReturnNotice(itPtr->conn, 200, "Debug Init Failed",				interp->result);	    itPtr->adp.exception = ADP_ABORT;	    goto done;	}    }    /*     * Determine the cache to use (if any).     */         if (itPtr->adp.debugLevel > 0) {	cachePtr = NULL;    } else if (!servPtr->adp.threadcache) {    	cachePtr = servPtr->adp.cache;    } else {	if (itPtr->adp.cache == NULL) {    	    itPtr->adp.cache = NsAdpCache(Ns_ThreadGetName(),		servPtr->adp.cachesize);	}    	cachePtr = itPtr->adp.cache;    }    /*     * Verify the file is an existing, ordinary file and then either     * parse directly or fetch through the cache.     */    if (stat(file, &st) != 0) {	Tcl_AppendResult(interp, "could not stat \"",	    file, "\": ", Tcl_PosixError(interp), NULL);    } else if (S_ISREG(st.st_mode) == 0) {    	Tcl_AppendResult(interp, "not an ordinary file: ", file,			 NULL);    } else if (cachePtr == NULL) {        	/*	 * Parse directly from file.	 */	     	status = ParseFile(itPtr, file, st.st_size, dsPtr);    } else {#ifdef WIN32	key = file;#else    	Key ukey;	ukey.dev = st.st_dev;	ukey.ino = st.st_ino;	key = (char *) &ukey;#endif	if (cachePtr != servPtr->adp.cache) {    	    /*	     * Fetch from private, free-threaded cache.	     */            ePtr = Ns_CacheCreateEntry(cachePtr, key, &new);            if (!new) {    		pagePtr = Ns_CacheGetValue(ePtr);    		if (pagePtr->mtime != st.st_mtime || pagePtr->size != st.st_size) {		    Ns_CacheUnsetValue(ePtr);		    new = 1;		} else {		    status = TCL_OK;		}	    }	    if (new) {		status = ParseFile(itPtr, file, st.st_size, dsPtr);		if (status != TCL_OK) {                    Ns_CacheDeleteEntry(ePtr);		} else {		    pagePtr = NewPage(dsPtr, &st, 1);                    Ns_CacheSetValueSz(ePtr, pagePtr, pagePtr->size);		}	    }	} else {    	    /*	     * Fetch from shared, interlocked cache.	     */            Ns_CacheLock(cachePtr);            ePtr = Ns_CacheCreateEntry(cachePtr, key, &new);            if (!new) {		while (ePtr != NULL && (pagePtr = Ns_CacheGetValue(ePtr)) == NULL) {		    Ns_CacheWait(cachePtr);		    ePtr = Ns_CacheFindEntry(cachePtr, key);		}		if (pagePtr == NULL) {		    Tcl_AppendResult(interp, "wait failed for file: ", file, NULL);		} else if (pagePtr->mtime != st.st_mtime || pagePtr->size != st.st_size) {		    Ns_CacheUnsetValue(ePtr);		    new = 1;		} else {		    Ns_DStringNAppend(dsPtr, pagePtr->chunks, pagePtr->length);		    status = TCL_OK;		}	    }	    if (new) {		Ns_CacheUnlock(cachePtr);		status = ParseFile(itPtr, file, st.st_size, dsPtr);		Ns_CacheLock(cachePtr);		if (status != TCL_OK) {                    Ns_CacheDeleteEntry(ePtr);		} else {		    pagePtr = NewPage(dsPtr, &st, 0);                    Ns_CacheSetValueSz(ePtr, pagePtr, pagePtr->size);        	}		Ns_CacheBroadcast(cachePtr);	    }	    Ns_CacheUnlock(cachePtr);	}    }        /*     * If valid chunks where parsed or copied, push a new call frame, run     * the chunks, and pop the frame.     */             if (status == TCL_OK) {    	PushFrame(itPtr, &frame, file, argc, argv, outputPtr);        if (cachePtr == NULL || cachePtr == servPtr->adp.cache) {            status = EvalChunks(itPtr, dsPtr->string);        } else {            status = EvalBlocks(itPtr, pagePtr->firstPtr);        }    	PopFrame(itPtr, &frame);    }    if (itPtr->adp.debugLevel > 0) {	--itPtr->adp.debugLevel;    }done:    Ns_DStringFree(&ds);    Ns_DStringPush(dsPtr);    return status;}