From d07d5a72938fd52415368c2320fc29575ae9a0c3 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Fri, 25 Sep 2009 16:04:37 -0700 Subject: Update expat to 2.0.1. We had one local patch relative to 2.0.0, in "xmltok_impl.c". That fix isn't in 2.0.1, but an equivalent patch is in expat CVS. I've gone with the upstream change, and surrounded it with BEGIN/END android-changed comments. Bug: 2086506 --- xmlwf/codepage.c | 2 +- xmlwf/readfilemap.c | 16 +++ xmlwf/unixfilemap.c | 7 ++ xmlwf/xmlfile.c | 19 ++-- xmlwf/xmlwf.c | 52 +++++----- xmlwf/xmlwf.dsp | 278 ++++++++++++++++++++++++++-------------------------- 6 files changed, 203 insertions(+), 171 deletions(-) (limited to 'xmlwf') diff --git a/xmlwf/codepage.c b/xmlwf/codepage.c index e610c7c3..57e48ff2 100644 --- a/xmlwf/codepage.c +++ b/xmlwf/codepage.c @@ -4,7 +4,7 @@ #include "codepage.h" -#ifdef WIN32 +#if (defined(WIN32) || (defined(__WATCOMC__) && defined(__NT__))) #define STRICT 1 #define WIN32_LEAN_AND_MEAN 1 diff --git a/xmlwf/readfilemap.c b/xmlwf/readfilemap.c index 42b5e038..088dda5c 100644 --- a/xmlwf/readfilemap.c +++ b/xmlwf/readfilemap.c @@ -8,6 +8,14 @@ #include #include +#ifdef __WATCOMC__ +#ifndef __LINUX__ +#include +#else +#include +#endif +#endif + #ifdef __BEOS__ #include #endif @@ -57,9 +65,17 @@ filemap(const char *name, return 0; } nbytes = sb.st_size; + /* malloc will return NULL with nbytes == 0, handle files with size 0 */ + if (nbytes == 0) { + static const char c = '\0'; + processor(&c, 0, name, arg); + close(fd); + return 1; + } p = malloc(nbytes); if (!p) { fprintf(stderr, "%s: out of memory\n", name); + close(fd); return 0; } n = read(fd, p, nbytes); diff --git a/xmlwf/unixfilemap.c b/xmlwf/unixfilemap.c index 22048c82..93adce32 100644 --- a/xmlwf/unixfilemap.c +++ b/xmlwf/unixfilemap.c @@ -44,6 +44,13 @@ filemap(const char *name, } nbytes = sb.st_size; + /* mmap fails for zero length files */ + if (nbytes == 0) { + static const char c = '\0'; + processor(&c, 0, name, arg); + close(fd); + return 1; + } p = (void *)mmap((caddr_t)0, (size_t)nbytes, PROT_READ, MAP_FILE|MAP_PRIVATE, fd, (off_t)0); if (p == (void *)-1) { diff --git a/xmlwf/xmlfile.c b/xmlwf/xmlfile.c index 88bb396b..99eeeaae 100644 --- a/xmlwf/xmlfile.c +++ b/xmlwf/xmlfile.c @@ -12,8 +12,10 @@ #include "winconfig.h" #elif defined(MACOS_CLASSIC) #include "macconfig.h" -#elif defined(__amigaos4__) +#elif defined(__amigaos__) #include "amigaconfig.h" +#elif defined(__WATCOMC__) +#include "watcomconfig.h" #elif defined(HAVE_EXPAT_CONFIG_H) #include #endif /* ndef COMPILED_FROM_DSP */ @@ -23,11 +25,11 @@ #include "xmltchar.h" #include "filemap.h" -#ifdef _MSC_VER +#if (defined(_MSC_VER) || (defined(__WATCOMC__) && !defined(__LINUX__))) #include #endif -#ifdef AMIGA_SHARED_LIB +#if defined(__amigaos__) && defined(__USE_INLINE__) #include #endif @@ -69,14 +71,15 @@ reportError(XML_Parser parser, const XML_Char *filename) else ftprintf(stderr, T("%s: (unknown message %d)\n"), filename, code); } - + +/* This implementation will give problems on files larger than INT_MAX. */ static void processFile(const void *data, size_t size, const XML_Char *filename, void *args) { XML_Parser parser = ((PROCESS_ARGS *)args)->parser; int *retPtr = ((PROCESS_ARGS *)args)->retPtr; - if (XML_Parse(parser, (const char *)data, size, 1) == XML_STATUS_ERROR) { + if (XML_Parse(parser, (const char *)data, (int)size, 1) == XML_STATUS_ERROR) { reportError(parser, filename); *retPtr = 0; } @@ -84,7 +87,7 @@ processFile(const void *data, size_t size, *retPtr = 1; } -#ifdef WIN32 +#if (defined(WIN32) || defined(__WATCOMC__)) static int isAsciiLetter(XML_Char c) @@ -102,7 +105,7 @@ resolveSystemId(const XML_Char *base, const XML_Char *systemId, *toFree = 0; if (!base || *systemId == T('/') -#ifdef WIN32 +#if (defined(WIN32) || defined(__WATCOMC__)) || *systemId == T('\\') || (isAsciiLetter(systemId[0]) && systemId[1] == T(':')) #endif @@ -116,7 +119,7 @@ resolveSystemId(const XML_Char *base, const XML_Char *systemId, s = *toFree; if (tcsrchr(s, T('/'))) s = tcsrchr(s, T('/')) + 1; -#ifdef WIN32 +#if (defined(WIN32) || defined(__WATCOMC__)) if (tcsrchr(s, T('\\'))) s = tcsrchr(s, T('\\')) + 1; #endif diff --git a/xmlwf/xmlwf.c b/xmlwf/xmlwf.c index 2de9b92e..41a433d3 100644 --- a/xmlwf/xmlwf.c +++ b/xmlwf/xmlwf.c @@ -16,7 +16,7 @@ #include #endif -#ifdef AMIGA_SHARED_LIB +#if defined(__amigaos__) && defined(__USE_INLINE__) #include #endif @@ -129,7 +129,7 @@ startElement(void *userData, const XML_Char *name, const XML_Char **atts) p = atts; while (*p) ++p; - nAtts = (p - atts) >> 1; + nAtts = (int)((p - atts) >> 1); if (nAtts > 1) qsort((void *)atts, nAtts, sizeof(XML_Char *) * 2, attcmp); while (*atts) { @@ -189,7 +189,7 @@ startElementNS(void *userData, const XML_Char *name, const XML_Char **atts) p = atts; while (*p) ++p; - nAtts = (p - atts) >> 1; + nAtts = (int)((p - atts) >> 1); if (nAtts > 1) qsort((void *)atts, nAtts, sizeof(XML_Char *) * 2, nsattcmp); while (*atts) { @@ -350,7 +350,7 @@ metaStartElement(void *userData, const XML_Char *name, fputts(T(">\n"), fp); do { ftprintf(fp, T("= specifiedAttsEnd) fputts(T("\" defaulted=\"yes\"/>\n"), fp); else if (atts == idAttPtr) @@ -381,7 +381,7 @@ metaProcessingInstruction(void *userData, const XML_Char *target, XML_Parser parser = (XML_Parser) userData; FILE *fp = (FILE *)XML_GetUserData(parser); ftprintf(fp, T("\n"), fp); @@ -393,7 +393,7 @@ metaComment(void *userData, const XML_Char *data) XML_Parser parser = (XML_Parser) userData; FILE *fp = (FILE *)XML_GetUserData(parser); fputts(T("\n"), fp); @@ -469,7 +469,7 @@ metaNotationDecl(void *userData, ftprintf(fp, T(" public=\"%s\""), publicId); if (systemId) { fputts(T(" system=\""), fp); - characterData(fp, systemId, tcslen(systemId)); + characterData(fp, systemId, (int)tcslen(systemId)); puttc(T('"'), fp); } metaLocation(parser); @@ -503,7 +503,7 @@ metaEntityDecl(void *userData, if (publicId) ftprintf(fp, T(" public=\"%s\""), publicId); fputts(T(" system=\""), fp); - characterData(fp, systemId, tcslen(systemId)); + characterData(fp, systemId, (int)tcslen(systemId)); puttc(T('"'), fp); ftprintf(fp, T(" notation=\"%s\""), notationName); metaLocation(parser); @@ -514,7 +514,7 @@ metaEntityDecl(void *userData, if (publicId) ftprintf(fp, T(" public=\"%s\""), publicId); fputts(T(" system=\""), fp); - characterData(fp, systemId, tcslen(systemId)); + characterData(fp, systemId, (int)tcslen(systemId)); puttc(T('"'), fp); metaLocation(parser); fputts(T("/>\n"), fp); @@ -533,7 +533,7 @@ metaStartNamespaceDecl(void *userData, ftprintf(fp, T(" prefix=\"%s\""), prefix); if (uri) { fputts(T(" ns=\""), fp); - characterData(fp, uri, tcslen(uri)); + characterData(fp, uri, (int)tcslen(uri)); fputts(T("\"/>\n"), fp); } else @@ -576,7 +576,7 @@ unknownEncoding(void *userData, const XML_Char *name, XML_Encoding *info) if (!s) return 0; cp *= 10; - cp += s - digits; + cp += (int)(s - digits); if (cp >= 0x10000) return 0; } @@ -607,7 +607,7 @@ showVersion(XML_Char *prog) const XML_Feature *features = XML_GetFeatureList(); while ((ch = *s) != 0) { if (ch == '/' -#ifdef WIN32 +#if (defined(WIN32) || defined(__WATCOMC__)) || ch == '\\' #endif ) @@ -639,13 +639,8 @@ usage(const XML_Char *prog, int rc) exit(rc); } -#ifdef AMIGA_SHARED_LIB -int -amiga_main(int argc, char *argv[]) -#else int tmain(int argc, XML_Char **argv) -#endif { int i, j; const XML_Char *outputDir = NULL; @@ -777,17 +772,28 @@ tmain(int argc, XML_Char **argv) XML_SetProcessingInstructionHandler(parser, nopProcessingInstruction); } else if (outputDir) { + const XML_Char * delim = T("/"); const XML_Char *file = useStdin ? T("STDIN") : argv[i]; - if (tcsrchr(file, T('/'))) - file = tcsrchr(file, T('/')) + 1; -#ifdef WIN32 - if (tcsrchr(file, T('\\'))) - file = tcsrchr(file, T('\\')) + 1; + if (!useStdin) { + /* Jump after last (back)slash */ + const XML_Char * lastDelim = tcsrchr(file, delim[0]); + if (lastDelim) + file = lastDelim + 1; +#if (defined(WIN32) || defined(__WATCOMC__)) + else { + const XML_Char * winDelim = T("\\"); + lastDelim = tcsrchr(file, winDelim[0]); + if (lastDelim) { + file = lastDelim + 1; + delim = winDelim; + } + } #endif + } outName = (XML_Char *)malloc((tcslen(outputDir) + tcslen(file) + 2) * sizeof(XML_Char)); tcscpy(outName, outputDir); - tcscat(outName, T("/")); + tcscat(outName, delim); tcscat(outName, file); fp = tfopen(outName, T("wb")); if (!fp) { diff --git a/xmlwf/xmlwf.dsp b/xmlwf/xmlwf.dsp index a639bc61..cbcff43b 100644 --- a/xmlwf/xmlwf.dsp +++ b/xmlwf/xmlwf.dsp @@ -1,139 +1,139 @@ -# Microsoft Developer Studio Project File - Name="xmlwf" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=xmlwf - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "xmlwf.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "xmlwf.mak" CFG="xmlwf - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "xmlwf - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "xmlwf - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "xmlwf - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir ".\Release" -# PROP BASE Intermediate_Dir ".\Release" -# PROP BASE Target_Dir "." -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir ".\Release" -# PROP Intermediate_Dir ".\Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "." -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c -# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\lib" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "COMPILED_FROM_DSP" /FD /c -# SUBTRACT CPP /YX /Yc /Yu -# ADD BASE RSC /l 0x809 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 setargv.obj kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /pdb:none /machine:I386 /out:"Release\xmlwf.exe" -# SUBTRACT LINK32 /nodefaultlib - -!ELSEIF "$(CFG)" == "xmlwf - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir ".\Debug" -# PROP BASE Intermediate_Dir ".\Debug" -# PROP BASE Target_Dir "." -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir ".\Debug" -# PROP Intermediate_Dir ".\Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "." -# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c -# ADD CPP /nologo /MTd /W3 /GX /ZI /Od /I "..\lib" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "COMPILED_FROM_DSP" /FD /c -# SUBTRACT CPP /Fr /YX -# ADD BASE RSC /l 0x809 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 -# ADD LINK32 setargv.obj kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /pdb:none /debug /machine:I386 /out:"Debug\xmlwf.exe" - -!ENDIF - -# Begin Target - -# Name "xmlwf - Win32 Release" -# Name "xmlwf - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;for;f90" -# Begin Source File - -SOURCE=.\codepage.c -# End Source File -# Begin Source File - -SOURCE=.\readfilemap.c -# PROP Exclude_From_Build 1 -# End Source File -# Begin Source File - -SOURCE=.\unixfilemap.c -# PROP Exclude_From_Build 1 -# End Source File -# Begin Source File - -SOURCE=.\win32filemap.c -# End Source File -# Begin Source File - -SOURCE=.\xmlfile.c -# End Source File -# Begin Source File - -SOURCE=.\xmlwf.c -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd" -# Begin Source File - -SOURCE=.\codepage.h -# End Source File -# Begin Source File - -SOURCE=.\xmlfile.h -# End Source File -# Begin Source File - -SOURCE=.\xmltchar.h -# End Source File -# End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe" -# End Group -# End Target -# End Project +# Microsoft Developer Studio Project File - Name="xmlwf" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=xmlwf - Win32 Release +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "xmlwf.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "xmlwf.mak" CFG="xmlwf - Win32 Release" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "xmlwf - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "xmlwf - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "xmlwf - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir ".\Release" +# PROP BASE Intermediate_Dir ".\Release" +# PROP BASE Target_Dir "." +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "..\win32\bin\Release" +# PROP Intermediate_Dir "..\win32\tmp\Release-xmlwf" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "." +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c +# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\lib" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "COMPILED_FROM_DSP" /FD /c +# SUBTRACT CPP /YX /Yc /Yu +# ADD BASE RSC /l 0x809 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 setargv.obj kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /pdb:none /machine:I386 +# SUBTRACT LINK32 /nodefaultlib + +!ELSEIF "$(CFG)" == "xmlwf - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir ".\Debug" +# PROP BASE Intermediate_Dir ".\Debug" +# PROP BASE Target_Dir "." +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "..\win32\bin\Debug" +# PROP Intermediate_Dir "..\win32\tmp\Debug-xmlwf" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "." +# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c +# ADD CPP /nologo /MTd /W3 /GX /ZI /Od /I "..\lib" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "COMPILED_FROM_DSP" /FD /c +# SUBTRACT CPP /Fr /YX +# ADD BASE RSC /l 0x809 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 +# ADD LINK32 setargv.obj kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /pdb:none /debug /machine:I386 + +!ENDIF + +# Begin Target + +# Name "xmlwf - Win32 Release" +# Name "xmlwf - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;for;f90" +# Begin Source File + +SOURCE=.\codepage.c +# End Source File +# Begin Source File + +SOURCE=.\readfilemap.c +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\unixfilemap.c +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\win32filemap.c +# End Source File +# Begin Source File + +SOURCE=.\xmlfile.c +# End Source File +# Begin Source File + +SOURCE=.\xmlwf.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd" +# Begin Source File + +SOURCE=.\codepage.h +# End Source File +# Begin Source File + +SOURCE=.\xmlfile.h +# End Source File +# Begin Source File + +SOURCE=.\xmltchar.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project -- cgit v1.2.3