bug 302531: QuoteString doesn't deal with not outputting anything. Also fix some whitespace nits. r=shaver a=brendan

This commit is contained in:
mrbkap%gmail.com 2005-07-28 18:16:30 +00:00
Родитель e246c70e9d
Коммит b2ecd424ea
2 изменённых файлов: 16 добавлений и 9 удалений

Просмотреть файл

@ -4710,15 +4710,15 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
JS_ASSERT(pn->pn_type == TOK_XMLLIST || pn->pn_count != 0); JS_ASSERT(pn->pn_type == TOK_XMLLIST || pn->pn_count != 0);
switch (pn->pn_head->pn_type) { switch (pn->pn_head->pn_type) {
case TOK_XMLETAGO: case TOK_XMLETAGO:
JS_ASSERT(0); JS_ASSERT(0);
/* FALL THROUGH */ /* FALL THROUGH */
case TOK_XMLPTAGC: case TOK_XMLPTAGC:
case TOK_XMLSTAGO: case TOK_XMLSTAGO:
break; break;
default: default:
if (js_Emit1(cx, cg, JSOP_STARTXML) < 0) if (js_Emit1(cx, cg, JSOP_STARTXML) < 0)
return JS_FALSE; return JS_FALSE;
} }
for (pn2 = pn->pn_head; pn2; pn2 = pn2->pn_next) { for (pn2 = pn->pn_head; pn2; pn2 = pn2->pn_next) {

Просмотреть файл

@ -431,6 +431,13 @@ QuoteString(Sprinter *sp, JSString *str, jschar quote)
/* Sprint the closing quote and return the quoted string. */ /* Sprint the closing quote and return the quoted string. */
if (quote && Sprint(sp, "%c", (char)quote) < 0) if (quote && Sprint(sp, "%c", (char)quote) < 0)
return NULL; return NULL;
/*
* If we haven't Sprint'd anything yet, Sprint an empty string so that
* the OFF2STR below gives a valid result.
*/
if (off == sp->offset && Sprint(sp, "") < 0)
return NULL;
return OFF2STR(sp, off); return OFF2STR(sp, off);
} }