mirror of
https://gitlab.gnome.org/GNOME/libxslt
synced 2025-07-31 02:43:06 +03:00
xsltproc: Make "-" read from stdin
This broke after libxml2@0a658c0f. Fixes #109.
This commit is contained in:
@ -55,6 +55,10 @@
|
|||||||
#include <sys/timeb.h>
|
#include <sys/timeb.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef STDIN_FILENO
|
||||||
|
#define STDIN_FILENO 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef LIBXML_DEBUG_ENABLED
|
#ifdef LIBXML_DEBUG_ENABLED
|
||||||
static int debug = 0;
|
static int debug = 0;
|
||||||
#endif
|
#endif
|
||||||
@ -314,6 +318,28 @@ xsltSubtreeCheck(xsltSecurityPrefsPtr sec ATTRIBUTE_UNUSED,
|
|||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static xmlDocPtr
|
||||||
|
xsltReadFile(const char *filename) {
|
||||||
|
xmlDocPtr doc;
|
||||||
|
|
||||||
|
#ifdef LIBXML_HTML_ENABLED
|
||||||
|
if (html) {
|
||||||
|
if (strcmp(filename, "-") == 0)
|
||||||
|
doc = htmlReadFd(STDIN_FILENO, "-", encoding, options);
|
||||||
|
else
|
||||||
|
doc = htmlReadFile(filename, encoding, options);
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
if (strcmp(filename, "-") == 0)
|
||||||
|
doc = xmlReadFd(STDIN_FILENO, "-", encoding, options);
|
||||||
|
else
|
||||||
|
doc = xmlReadFile(filename, encoding, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(doc);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xsltProcess(xmlDocPtr doc, xsltStylesheetPtr cur, const char *filename) {
|
xsltProcess(xmlDocPtr doc, xsltStylesheetPtr cur, const char *filename) {
|
||||||
xmlDocPtr res;
|
xmlDocPtr res;
|
||||||
@ -351,12 +377,7 @@ xsltProcess(xmlDocPtr doc, xsltStylesheetPtr cur, const char *filename) {
|
|||||||
res = xsltApplyStylesheet(cur, doc, params);
|
res = xsltApplyStylesheet(cur, doc, params);
|
||||||
xmlFreeDoc(res);
|
xmlFreeDoc(res);
|
||||||
xmlFreeDoc(doc);
|
xmlFreeDoc(doc);
|
||||||
#ifdef LIBXML_HTML_ENABLED
|
doc = xsltReadFile(filename);
|
||||||
if (html)
|
|
||||||
doc = htmlReadFile(filename, encoding, options);
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
doc = xmlReadFile(filename, encoding, options);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ctxt = xsltNewTransformContext(cur, doc);
|
ctxt = xsltNewTransformContext(cur, doc);
|
||||||
@ -857,12 +878,7 @@ main(int argc, char **argv)
|
|||||||
doc = NULL;
|
doc = NULL;
|
||||||
if (timing)
|
if (timing)
|
||||||
startTimer();
|
startTimer();
|
||||||
#ifdef LIBXML_HTML_ENABLED
|
doc = xsltReadFile(argv[i]);
|
||||||
if (html)
|
|
||||||
doc = htmlReadFile(argv[i], encoding, options);
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
doc = xmlReadFile(argv[i], encoding, options);
|
|
||||||
if (doc == NULL) {
|
if (doc == NULL) {
|
||||||
fprintf(stderr, "unable to parse %s\n", argv[i]);
|
fprintf(stderr, "unable to parse %s\n", argv[i]);
|
||||||
errorno = 6;
|
errorno = 6;
|
||||||
|
Reference in New Issue
Block a user