Make xmlwf build with XML_UNICODE_WCHAR_T on MinGW
This seems to need some extra mangling of Makefile.am for MinGW. * Add "-mwindows" to AM_CPPFLAGS * Add "AM_LDFLAGS = -municode" Running the XML tests (xmltest.sh) is problematic: it needs a unicode-aware differ for starters
This commit is contained in:
parent
56b64ca040
commit
742fbf024f
@ -71,10 +71,11 @@
|
||||
#endif
|
||||
|
||||
#include "filemap.h"
|
||||
#include "xmltchar.h"
|
||||
|
||||
int
|
||||
filemap(const char *name,
|
||||
void (*processor)(const void *, size_t, const char *, void *arg),
|
||||
filemap(const tchar *name,
|
||||
void (*processor)(const void *, size_t, const tchar *, void *arg),
|
||||
void *arg)
|
||||
{
|
||||
size_t nbytes;
|
||||
@ -83,18 +84,18 @@ filemap(const char *name,
|
||||
struct stat sb;
|
||||
void *p;
|
||||
|
||||
fd = open(name, O_RDONLY|O_BINARY);
|
||||
fd = topen(name, O_RDONLY|O_BINARY);
|
||||
if (fd < 0) {
|
||||
perror(name);
|
||||
tperror(name);
|
||||
return 0;
|
||||
}
|
||||
if (fstat(fd, &sb) < 0) {
|
||||
perror(name);
|
||||
tperror(name);
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
if (!S_ISREG(sb.st_mode)) {
|
||||
fprintf(stderr, "%s: not a regular file\n", name);
|
||||
ftprintf(stderr, T("%s: not a regular file\n"), name);
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
@ -113,19 +114,19 @@ filemap(const char *name,
|
||||
}
|
||||
p = malloc(nbytes);
|
||||
if (!p) {
|
||||
fprintf(stderr, "%s: out of memory\n", name);
|
||||
ftprintf(stderr, T("%s: out of memory\n"), name);
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
n = _EXPAT_read(fd, p, nbytes);
|
||||
if (n < 0) {
|
||||
perror(name);
|
||||
tperror(name);
|
||||
free(p);
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
if (n != (_EXPAT_read_count_t)nbytes) {
|
||||
fprintf(stderr, "%s: read unexpected number of bytes\n", name);
|
||||
ftprintf(stderr, T("%s: read unexpected number of bytes\n"), name);
|
||||
free(p);
|
||||
close(fd);
|
||||
return 0;
|
||||
|
@ -202,18 +202,18 @@ processStream(const XML_Char *filename, XML_Parser parser)
|
||||
if (filename != NULL)
|
||||
close(fd);
|
||||
ftprintf(stderr, T("%s: out of memory\n"),
|
||||
filename != NULL ? filename : "xmlwf");
|
||||
filename != NULL ? filename : T("xmlwf"));
|
||||
return 0;
|
||||
}
|
||||
nread = read(fd, buf, READ_SIZE);
|
||||
if (nread < 0) {
|
||||
tperror(filename != NULL ? filename : "STDIN");
|
||||
tperror(filename != NULL ? filename : T("STDIN"));
|
||||
if (filename != NULL)
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
if (XML_ParseBuffer(parser, nread, nread == 0) == XML_STATUS_ERROR) {
|
||||
reportError(parser, filename != NULL ? filename : "STDIN");
|
||||
reportError(parser, filename != NULL ? filename : T("STDIN"));
|
||||
if (filename != NULL)
|
||||
close(fd);
|
||||
return 0;
|
||||
|
@ -49,6 +49,7 @@
|
||||
#define topen _wopen
|
||||
#define tmain wmain
|
||||
#define tremove _wremove
|
||||
#define tchar wchar_t
|
||||
#else /* not XML_UNICODE */
|
||||
#define T(x) x
|
||||
#define ftprintf fprintf
|
||||
@ -65,4 +66,5 @@
|
||||
#define topen open
|
||||
#define tmain main
|
||||
#define tremove remove
|
||||
#define tchar char
|
||||
#endif /* not XML_UNICODE */
|
||||
|
@ -46,6 +46,10 @@
|
||||
#include <crtdbg.h>
|
||||
#endif
|
||||
|
||||
#ifdef XML_UNICODE
|
||||
#include <wchar.h>
|
||||
#endif
|
||||
|
||||
/* Structures for handler user data */
|
||||
typedef struct NotationList {
|
||||
struct NotationList *next;
|
||||
@ -1018,7 +1022,7 @@ tmain(int argc, XML_Char **argv)
|
||||
parser = XML_ParserCreate(encoding);
|
||||
|
||||
if (! parser) {
|
||||
tperror("Could not instantiate parser");
|
||||
tperror(T("Could not instantiate parser"));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user