parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, int htmlp)
{
xmlDoc *doc;
- xmlNode *node;
Lisp_Object result = Qnil;
const char *burl = "";
- EMACS_INT bytes;
- EMACS_INT istart, iend;
+ ptrdiff_t bytes;
+ ptrdiff_t istart, iend;
LIBXML_TEST_VERSION;
if (doc != NULL)
{
+ /* If the document is just comments, then this should get us the
+ nodes anyway. */
xmlNode *n = doc->children->next;
Lisp_Object r = Qnil;
while (n) {
- if (r != Qnil)
+ if (!NILP (r))
result = Fcons (r, result);
r = make_dom (n);
n = n->next;
}
- if (result == Qnil)
- result = r;
- else
+ if (NILP (result)) {
+ /* The document isn't just comments, so get the tree the
+ proper way. */
+ xmlNode *node = xmlDocGetRootElement (doc);
+ if (node != NULL)
+ result = make_dom (node);
+ } else
result = Fcons (intern ("top"),
Fcons (Qnil, Fnreverse (Fcons (r, result))));
xmlFreeDoc (doc);
- xmlCleanupParser ();
}
return result;