mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-01-19 10:03:34 +03:00
Always fopen files with "rb"
We never want translation of newlines when reading files, so it should be safe to always specify "rb". On sane platforms, the "b" flag is simply ignored.
This commit is contained in:
parent
3f8655db97
commit
655cf3f46f
@ -41,7 +41,7 @@ testRegexpFile(const char *filename) {
|
||||
for (i = 0;i<1000;i++)
|
||||
states[i] = NULL;
|
||||
|
||||
input = fopen(filename, "r");
|
||||
input = fopen(filename, "rb");
|
||||
if (input == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Cannot open %s for reading\n", filename);
|
||||
|
14
testHTML.c
14
testHTML.c
@ -627,11 +627,7 @@ parseSAXFile(char *filename) {
|
||||
if (push) {
|
||||
FILE *f;
|
||||
|
||||
#if defined(_WIN32)
|
||||
f = fopen(filename, "rb");
|
||||
#else
|
||||
f = fopen(filename, "r");
|
||||
#endif
|
||||
if (f != NULL) {
|
||||
int res, size = 3;
|
||||
char chars[4096];
|
||||
@ -657,11 +653,7 @@ parseSAXFile(char *filename) {
|
||||
fclose(f);
|
||||
}
|
||||
if (!noout) {
|
||||
#if defined(_WIN32)
|
||||
f = fopen(filename, "rb");
|
||||
#else
|
||||
f = fopen(filename, "r");
|
||||
#endif
|
||||
f = fopen(filename, "rb");
|
||||
if (f != NULL) {
|
||||
int res, size = 3;
|
||||
char chars[4096];
|
||||
@ -721,11 +713,7 @@ parseAndPrintFile(char *filename) {
|
||||
if (push) {
|
||||
FILE *f;
|
||||
|
||||
#if defined(_WIN32)
|
||||
f = fopen(filename, "rb");
|
||||
#else
|
||||
f = fopen(filename, "r");
|
||||
#endif
|
||||
if (f != NULL) {
|
||||
int res, size = 3;
|
||||
char chars[4096];
|
||||
|
@ -40,7 +40,7 @@ testRegexpFile(const char *filename) {
|
||||
char expression[5000];
|
||||
int len;
|
||||
|
||||
input = fopen(filename, "r");
|
||||
input = fopen(filename, "rb");
|
||||
if (input == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Cannot open %s for reading\n", filename);
|
||||
@ -94,7 +94,7 @@ runFileTest(xmlExpCtxtPtr ctxt, const char *filename) {
|
||||
char expression[5000];
|
||||
int len;
|
||||
|
||||
input = fopen(filename, "r");
|
||||
input = fopen(filename, "rb");
|
||||
if (input == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Cannot open %s for reading\n", filename);
|
||||
|
@ -1012,11 +1012,7 @@ parseAndPrintFile(char *filename) {
|
||||
/*
|
||||
* Empty callbacks for checking
|
||||
*/
|
||||
#if defined(_WIN32)
|
||||
f = fopen(filename, "rb");
|
||||
#else
|
||||
f = fopen(filename, "r");
|
||||
#endif
|
||||
if (f != NULL) {
|
||||
int ret;
|
||||
char chars[10];
|
||||
@ -1041,11 +1037,7 @@ parseAndPrintFile(char *filename) {
|
||||
/*
|
||||
* Debug callback
|
||||
*/
|
||||
#if defined(_WIN32)
|
||||
f = fopen(filename, "rb");
|
||||
#else
|
||||
f = fopen(filename, "r");
|
||||
#endif
|
||||
if (f != NULL) {
|
||||
int ret;
|
||||
char chars[10];
|
||||
|
@ -118,7 +118,7 @@ testXPathFile(const char *filename) {
|
||||
char expression[5000];
|
||||
int len;
|
||||
|
||||
input = fopen(filename, "r");
|
||||
input = fopen(filename, "rb");
|
||||
if (input == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Cannot open %s for reading\n", filename);
|
||||
|
2
xmlIO.c
2
xmlIO.c
@ -866,7 +866,7 @@ xmlFileOpen_real (const char *filename) {
|
||||
#if defined(_WIN32)
|
||||
fd = xmlWrapOpenUtf8(path, 0);
|
||||
#else
|
||||
fd = fopen(path, "r");
|
||||
fd = fopen(path, "rb");
|
||||
#endif /* WIN32 */
|
||||
if (fd == NULL) xmlIOErr(0, path);
|
||||
return((void *) fd);
|
||||
|
20
xmllint.c
20
xmllint.c
@ -2202,13 +2202,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
|
||||
if ((filename[0] == '-') && (filename[1] == 0)) {
|
||||
f = stdin;
|
||||
} else {
|
||||
#if defined(_WIN32)
|
||||
f = fopen(filename, "rb");
|
||||
#elif defined(__OS400__)
|
||||
f = fopen(filename, "rb");
|
||||
#else
|
||||
f = fopen(filename, "r");
|
||||
#endif
|
||||
}
|
||||
if (f != NULL) {
|
||||
int res;
|
||||
@ -2276,15 +2270,9 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
|
||||
|
||||
/* '-' Usually means stdin -<sven@zen.org> */
|
||||
if ((filename[0] == '-') && (filename[1] == 0)) {
|
||||
f = stdin;
|
||||
f = stdin;
|
||||
} else {
|
||||
#if defined(_WIN32)
|
||||
f = fopen(filename, "rb");
|
||||
#elif defined(__OS400__)
|
||||
f = fopen(filename, "rb");
|
||||
#else
|
||||
f = fopen(filename, "r");
|
||||
#endif
|
||||
}
|
||||
if (f != NULL) {
|
||||
int ret;
|
||||
@ -2327,13 +2315,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
|
||||
} else {
|
||||
FILE *f;
|
||||
|
||||
#if defined(_WIN32)
|
||||
f = fopen(filename, "rb");
|
||||
#elif defined(__OS400__)
|
||||
f = fopen(filename, "rb");
|
||||
#else
|
||||
f = fopen(filename, "r");
|
||||
#endif
|
||||
if (f != NULL) {
|
||||
if (rectxt == NULL)
|
||||
doc = xmlReadIO(myRead, myClose, f, filename, NULL,
|
||||
|
Loading…
x
Reference in New Issue
Block a user