if (!pc) { NS_WARNING("No pc in threadstate"); return PR_TRUE; }
jsds_FilterHook (JSDContext *jsdc, JSDThreadState *state){    JSContext *cx = JSD_GetJSContext (jsdc, state);    void *glob = NS_STATIC_CAST(void *, JS_GetGlobalObject (cx));    if (!glob) {        NS_WARNING("No global in threadstate");        return PR_FALSE;    }        JSDStackFrameInfo *frame = JSD_GetStackFrame (jsdc, state);    if (!frame) {        NS_WARNING("No frame in threadstate");        return PR_FALSE;    }    JSDScript *script = JSD_GetScriptForStackFrame (jsdc, state, frame);    if (!script)        return PR_TRUE;    jsuint pc = JSD_GetPCForStackFrame (jsdc, state, frame);    if (!pc) {        NS_WARNING("No pc in threadstate");        return PR_TRUE;    }    const char *url = JSD_GetScriptFilename (jsdc, script);    if (!url) {        NS_WARNING ("Script with no filename");        return PR_FALSE;    }    if (!gFilters)        return PR_TRUE;        PRUint32 currentLine = JSD_GetClosestLine (jsdc, script, pc);    PRUint32 len = 0;    FilterRecord *currentFilter = gFilters;    do {        PRUint32 flags = 0;        nsresult rv = currentFilter->filterObject->GetFlags(&flags);        NS_ASSERTION(NS_SUCCEEDED(rv), "Error getting flags for filter");        if (flags & jsdIFilter::FLAG_ENABLED) {            /* if there is no glob, or the globs match */            if ((!currentFilter->glob || currentFilter->glob == glob) &&                /* and there is no start line, or the start line is before                  * or equal to the current */                (!currentFilter->startLine ||                  currentFilter->startLine <= currentLine) &&                /* and there is no end line, or the end line is after                 * or equal to the current */                (!currentFilter->endLine ||                 currentFilter->endLine >= currentLine)) {                /* then we're going to have to compare the url. */                if (currentFilter->patternType == ptIgnore)                    return flags & jsdIFilter::FLAG_PASS;                if (!len)                    len = PL_strlen(url);                                if (len >= currentFilter->patternLength) {                    switch (currentFilter->patternType) {                        case ptEquals:                            if (!PL_strcmp(currentFilter->urlPattern, url))                                return flags & jsdIFilter::FLAG_PASS;                            break;                        case ptStartsWith:                            if (!PL_strncmp(currentFilter->urlPattern, url,                                            currentFilter->patternLength))                                return flags & jsdIFilter::FLAG_PASS;                            break;                        case ptEndsWith:                            if (!PL_strcmp(currentFilter->urlPattern,                                           &url[len -                                                currentFilter->patternLength]))                                return flags & jsdIFilter::FLAG_PASS;                            break;                        case ptContains:                            if (PL_strstr(url, currentFilter->urlPattern))                                return flags & jsdIFilter::FLAG_PASS;                            break;                        default:                            NS_ASSERTION(0, "Invalid pattern type");                    }                }                            }        }        currentFilter = NS_REINTERPRET_CAST(FilterRecord *,                                            PR_NEXT_LINK(&currentFilter->links));    } while (currentFilter != gFilters);    return PR_TRUE;    }