in_single_quote = !in_single_quote;
if (!in_double_quote) in_single_quote = !in_single_quote;
lo_ProcessStyleAttribute(MWContext *context, lo_DocState *state, PA_Tag *tag, char *script_buff){    lo_TopState *top_state;    char *scope_to = NULL;    int32 script_buff_len;    char *new_id;    XP_Bool in_double_quote=FALSE, in_single_quote=FALSE;    char *ptr, *end;    ETEvalStuff * stuff;    if (!state)  	{       XP_FREEIF(script_buff);	   return FALSE;	}    if (!script_buff)        return FALSE;    /* @@@ A bit of a hack.     * Get rid of the style attribute in the tag->data so that we don't     * go circular     *     * get rid of STYLE by rewriting it as SYTLE so that the parser      * ignores it :)     */    for (ptr=(char*)tag->data, end = ptr+tag->data_len; ptr < end; ptr++) {        if (*ptr == '"') {            in_double_quote = !in_double_quote;        }        else if (*ptr == '\'') {            in_single_quote = !in_single_quote;        }        else if (!in_single_quote &&                 !in_double_quote &&                 !strncasecomp(ptr, PARAM_STYLE, sizeof(PARAM_STYLE)-1)) {            *ptr = 'T';    /* ttyle NOT style */            break;        }    }    script_buff_len = XP_STRLEN(script_buff);    top_state = state->top_state;    /* get the tag ID if it has one */    new_id = (char *)lo_FetchParamValue(context, tag, PARAM_ID);    if (!new_id)        new_id = PR_smprintf(NSIMPLICITID"%ld", top_state->tag_count);    if (!new_id)        return FALSE;    if (top_state->default_style_script_type == SCRIPT_TYPE_JSSS ||	top_state->default_style_script_type == SCRIPT_TYPE_MOCHA) {    	StrAllocCopy(scope_to, "document.ids.");    	StrAllocCat(scope_to, new_id);    	if (!scope_to) {    	    XP_FREE(new_id);	    return(FALSE);	}    }    else if (top_state->default_style_script_type == SCRIPT_TYPE_CSS) {        char *new_jss_buff;        int32 new_jss_buff_len;        char *new_css_buff;        int32 new_css_buff_len;        /* scope the css to the ns implicit ID */        new_css_buff = PR_smprintf("#%s { %s }", new_id, script_buff);        XP_FREE(script_buff);        if (!new_css_buff) {	    XP_FREE(new_id);	    return FALSE;	}        new_css_buff_len = XP_STRLEN(new_css_buff);                /* convert to JSS */        CSS_ConvertToJS(new_css_buff,                        new_css_buff_len,                        &new_jss_buff,                        &new_jss_buff_len);        XP_FREE(new_css_buff);        if (!new_jss_buff) {	    XP_FREE(new_id);	    return FALSE;	}        script_buff = new_jss_buff;        script_buff_len = new_jss_buff_len;    }    else {        /* unknown script type, punt */        XP_FREE(script_buff);	XP_FREE(new_id);        return FALSE;    }    /* not needed anymore */    XP_FREE(new_id);    stuff = (ETEvalStuff *) XP_NEW_ZAP(ETEvalStuff);    if (!stuff) {	/* what do we free here? */	XP_FREE(new_id);        return FALSE;    }    if (lo_CloneTagAndBlockLayout(context, state, tag)) {        tag->type = P_UNKNOWN;	stuff->len = XP_STRLEN(script_buff);	stuff->line_no = top_state->script_lineno;	stuff->scope_to = scope_to;	stuff->want_result = JS_FALSE;	stuff->data = context;	stuff->version = top_state->version;	stuff->principals = NULL;        ET_EvaluateScript(context, script_buff, stuff, lo_StyleEvalExitFn);	/* don't free scope_to, ET_EvaluateScript has taken possession */        XP_FREE(script_buff);        return TRUE;    }    XP_FREEIF(scope_to);    XP_FREE(script_buff);        return FALSE;}