* htmlDoRead: * @ctxt: an HTML parser context * @URL: the base URL to use for the document * @encoding: the document encoding, or NULL * @options: a combination of htmlParserOption(s) * @reuse: keep the context for reuse * * Common front-end for the htmlRead functions * * Returns the resulting document tree or NULL */
| 5947 | * Returns the resulting document tree or NULL |
| 5948 | */ |
| 5949 | static htmlDocPtr |
| 5950 | htmlDoRead(htmlParserCtxtPtr ctxt, const char *URL, const char *encoding, |
| 5951 | int options, int reuse) |
| 5952 | { |
| 5953 | htmlDocPtr ret; |
| 5954 | |
| 5955 | htmlCtxtUseOptions(ctxt, options); |
| 5956 | ctxt->html = 1; |
| 5957 | if (encoding != NULL) { |
| 5958 | xmlCharEncodingHandlerPtr hdlr; |
| 5959 | |
| 5960 | hdlr = xmlFindCharEncodingHandler(encoding); |
| 5961 | if (hdlr != NULL) |
| 5962 | xmlSwitchToEncoding(ctxt, hdlr); |
| 5963 | } |
| 5964 | if ((URL != NULL) && (ctxt->input != NULL) && |
| 5965 | (ctxt->input->filename == NULL)) |
| 5966 | ctxt->input->filename = (char *) xmlStrdup((const xmlChar *) URL); |
| 5967 | htmlParseDocument(ctxt); |
| 5968 | ret = ctxt->myDoc; |
| 5969 | ctxt->myDoc = NULL; |
| 5970 | if (!reuse) { |
| 5971 | if ((ctxt->dictNames) && |
| 5972 | (ret != NULL) && |
| 5973 | (ret->dict == ctxt->dict)) |
| 5974 | ctxt->dict = NULL; |
| 5975 | xmlFreeParserCtxt(ctxt); |
| 5976 | } |
| 5977 | return (ret); |
| 5978 | } |
| 5979 | |
| 5980 | /** |
| 5981 | * htmlReadDoc: |
no test coverage detected