amp = ((PyUnicodeObject*)PyUnicode_DecodeASCII("&", 5, NULL))->str;
lt = ((PyUnicodeObject*)PyUnicode_DecodeASCII("<", 4, NULL))->str;
gt = ((PyUnicodeObject*)PyUnicode_DecodeASCII(">", 4, NULL))->str;
- qt = ((PyUnicodeObject*)PyUnicode_DecodeASCII(""", 5, NULL))->str;
+ qt = ((PyUnicodeObject*)PyUnicode_DecodeASCII(""", 6, NULL))->str;
Py_DECREF(datastructure);
Py_DECREF(exceptions);
Py_UNICODE *outp;
int i, len;
- int quotes = 0;
- PyObject *text = NULL;
+ PyObject *text = NULL, *use_quotes = NULL;
- /* XXX: "b" is "tiny int", not bool. */
- if (!PyArg_ParseTuple(args, "O|b", &text, "es))
+ if (!PyArg_ParseTuple(args, "O|O", &text, &use_quotes))
return NULL;
+ int quotes = use_quotes && PyObject_IsTrue(use_quotes);
in = (PyUnicodeObject*)PyObject_Unicode(text);
if (!in)
return NULL;
len += 5;
break;
case '"':
- len += quotes ? 5 : 1;
+ len += quotes ? 6 : 1;
break;
case '<':
case '>':
break;
case '"':
if (quotes) {
- Py_UNICODE_COPY(outp, qt, 5);
- outp += 5;
+ Py_UNICODE_COPY(outp, qt, 6);
+ outp += 6;
}
else
*outp++ = in->str[i];