updated instructions and diffs from John A Fotheringham Daniel

* vms/*: updated instructions and diffs from John A Fotheringham
Daniel
diff --git a/ChangeLog b/ChangeLog
index 38a7485..354f01d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Tue Nov 13 16:23:04 CET 2001 Daniel Veillard <daniel@veillard.com>
+
+	* vms/*: updated instructions and diffs from John A Fotheringham
+
 Mon Nov 12 23:43:22 CET 2001 Daniel Veillard <daniel@veillard.com>
 
 	* include/libxml/xmlerror.h: avoid an include problem if
diff --git a/vms/build_libxml.com b/vms/build_libxml.com
index 28f69c9..57a46e4 100755
--- a/vms/build_libxml.com
+++ b/vms/build_libxml.com
@@ -1,51 +1,80 @@
 $! BUILD_LIBXML.COM
 $!
-$! Build the LIBXML object library
+$! Build the LIBXML library
 $!
-$! Ensure the logical name LIBXML is defined to point to the LIBXML source 
-$! directory. This procedure creates an object library LIBXML.OLB in the LIBXML
-$! directory. After the library is built, you can link LIBXML routines into
-$! your code with the command  $ LINK your_modules,LIBXML:LIBXML.OLB/LIBRARY
+$! Arguments:
+$!
+$!	"NOWARN" - suppress known/expected warnings
+$!   	"DEBUG"  - build everythign in debug
+$!
+$! This procedure creates an object library XMLOLB:LIBXML.OLB directory.  
+$! After the library is built, you can link LIBXML routines into
+$! your code with the command  
+$!
+$!	$ LINK your_modules,XMLOLB:LIBXML.OLB/LIBRARY
 $! 
+$! Change History
+$! --------------
+$! Command file author : John A Fotheringham (jaf@jafsoft.com)
+$! Last update         : 2 Nov 2001
+$!
 $!- configuration -------------------------------------------------------------
 $!
 $!- compile command.  If p1="nowarn" suppress the expected warning types
 $!
-$   cc_command = "CC/DEBUG/NOOPT"
+$   if p1.eqs."DEBUG" .or. p2.eqs."DEBUG"
+$   then
+$     debug = "Y"
+$     cc_command = "CC/DEBUG/NOOPT"
+$   else
+$     debug = "N"
+$     cc_command = "CC"
+$   endif
 $   if p1.eqs."NOWARN" then 		-
       cc_command = cc_command + "/WARN=DISABLE=(FLOATOVERFL,NOMAINUFLO)"
 $!
 $!- list of sources to be built into the LIBXML library.  Compare this list
-$!  to the definition of "libxml2_la_SOURCES" in the file MAKEFILE.
+$!  to the definition of "libxml2_la_SOURCES" in the file MAKEFILE.IN.
+$!  Currently this definition includes the list WITH_TRIO_SOURCES_TRUE
 $!
 $   sources = "SAX.c entities.c encoding.c error.c parserInternals.c parser.c"
 $   sources = sources + " tree.c hash.c list.c xmlIO.c xmlmemory.c uri.c valid.c"
 $   sources = sources + " xlink.c HTMLparser.c HTMLtree.c debugXML.c xpath.c "
 $   sources = sources + " xpointer.c xinclude.c nanohttp.c nanoftp.c "
 $   sources = sources + " DOCBparser.c catalog.c globals.c threads.c"
-$!
-$!- for VMS, we add in trio support
-$!
 $   sources = sources + " trio.c strio.c"
 $!
 $!- list of main modules to compile and link.  Compare this list to the
-$!  definition of bin_PROGRAMS in MAKEFILE.
+$!  definition of bin_PROGRAMS in MAKEFILE.IN
 $!
 $   bin_progs = "xmllint xmlcatalog"
 $!
 $!- list of test modules to compile and link.  Compare this list to the
 $!  definition of noinst_PROGRAMS in MAKEFILE.
 $!
-$   test_progs = "testSAX testHTML testXPath testURI testDocbook"
+$   test_progs = "testSAX testHTML testXPath testURI testDocbook testThreads"
 $!
 $!- set up build logicals -----------------------------------------------------\
 $!
+$   if f$trnlnm("XMLOLB").eqs.""
+$   then
+$     write sys$output ""
+$     write sys$output "	You need to define a XMLOLB logical directory to"
+$     write sys$output "	point to the directory containing your CMS object"
+$     write sys$output "	libraries.  This should already contain LIBXML.OLB"
+$     write sys$output "	from the libxml package, and will be the directory"
+$     write sys$output "	the new LIBXSLT.OLB library will be placed in"
+$     write sys$output ""
+$     exit
+$   endif
+$!
 $   if f$trnlnm("xml_srcdir").eqs.""
 $   then
-$     globfile = f$search("[...]globals.c")
+$     globfile = f$search("[-...]globals.c")
 $     if globfile.eqs.""
 $     then
-$	write sys$output "Can't locate globals.c.  You need to define a XML_SRCDIR logical"
+$	write sys$output "Can't locate globals.c.  You need to manually define a XML_SRCDIR logical"
+$	exit
 $     else
 $	srcdir = f$element(0,"]",globfile)+ "]"
 $	define/process xml_srcdir "''srcdir'"
@@ -55,10 +84,10 @@
 $!
 $   if f$trnlnm("libxml").eqs."" 
 $   then 
-$     globfile = f$search("[...]globals.h")
-$     if globfile.nes.""
+$     globfile = f$search("[-...]globals.h")
+$     if globfile.eqs.""
 $     then
-$	write sys$output "Can't locate globals.h.  You need to define a LIBXML logical"
+$	write sys$output "Can't locate globals.h.  You need to manually define a LIBXML logical"
 $	exit
 $     else
 $	includedir = f$element(0,"]",globfile)+ "]"
@@ -79,14 +108,18 @@
 $!
 $ set def xml_srcdir
 $ if f$search("DEBUG.DIR").eqs."" then create/dir [.DEBUG]
-$ if f$search("LIBXML.OLB").eqs."" then library/create LIBXML.OLB
+$ if f$search("XMLOLB:LIBXML.OLB").eqs."" 
+$ then 
+$   write sys$output "Creating new object library XMLOLB:LIBXML.OLB"
+$   library/create XMLOLB:LIBXML.OLB
+$ endif
 $!
 $ goto start_here
 $ start_here:	  ! move this line to debug/rerun parts of this command file
 $!
 $!- compile modules into the library ------------------------------------------
 $!
-$ lib_command   = "LIBRARY/REPLACE LIBXML.OLB"
+$ lib_command   = "LIBRARY/REPLACE XMLOLB:LIBXML.OLB"
 $ link_command	= ""
 $!
 $ write sys$output ""
@@ -102,11 +135,18 @@
 $   if next_source.nes."" .and. next_source.nes." "
 $   then
 $!
+$     on error then goto ERROR_OUT 
+$     on control_y then goto ERROR_OUT 
 $     if next_source.eqs."xpath.c"
 $     then
 $	call build 'next_source' /IEEE_MODE=UNDERFLOW_TO_ZERO/FLOAT=IEEE
 $     else
-$       call build 'next_source'
+$       if next_source.eqs."trio.c"
+$       then
+$	  call build 'next_source' /WARN=DISABLE=UNINIT1 
+$	else
+$         call build 'next_source'
+$	endif
 $     endif
 $     s_no = s_no + 1
 $     goto source_loop
@@ -115,7 +155,7 @@
 $!
 $!- now build self-test programs ----------------------------------------------
 $!
-$! these pograms are built as ordinary modules into LIBXML.OLB.  Here they
+$! these pograms are built as ordinary modules into XMLOLB:LIBXML.OLB.  Here they
 $! are built a second time with /DEFINE=(STANDALONE) in which case a main()
 $! is also compiled into the module
 $ 
@@ -150,6 +190,8 @@
 $   if next_prog.nes."" .and. next_prog.nes." "
 $   then
 $!
+$     on error then goto ERROR_OUT 
+$     on control_y then goto ERROR_OUT 
 $     call build 'next_prog'.c /IEEE_MODE=UNDERFLOW_TO_ZERO/FLOAT=IEEE
 $     p_no = p_no + 1
 $     goto prog_loop
@@ -158,6 +200,9 @@
 $!
 $!- Th-th-th-th-th-that's all folks! ------------------------------------------
 $!
+$ goto exit_here ! move this line to avoid parts of this command file
+$ exit_here:	  
+$!
 $ exit       
 $ goto exit_out
 $!
@@ -183,10 +228,12 @@
 $   object_file = f$fao("[.debug]!AS.OBJ",name)
 $!
 $!- compile
-$   write sys$output "Compiling ",p1,p2,"..."
-$   cc_command /object='object_file 'source_file' 'p2'
+$!
+$   write sys$output "Compiling ",p1," ",p2,"..."
+$   cc_command'p2' /object='object_file 'source_file'
 $!
 $!- insert into library if command defined
+$!
 $   if lib_command.nes.""  then lib_command 'object_file'
 $!
 $!- link module if command defined
@@ -194,8 +241,10 @@
 $   then
 $	text = f$element(0,".",p1)	! lose the ".c"
 $	write sys$output "Linking ",text,"..."
-$	link_command 'object_file',-
-      		[]libxml.olb/library
+$	opts = ""
+$	if debug then opts = "/DEBUG"
+$	link_command'opts' 'object_file',-
+      		XMLOLB:libxml.olb/library
 $   endif
 $!
 $EXIT_BUILD:
diff --git a/vms/diffs.vms b/vms/diffs.vms
new file mode 100644
index 0000000..5402910
--- /dev/null
+++ b/vms/diffs.vms
@@ -0,0 +1,192 @@
+--------------------------------------------------------------------------
+GLOBALS.C
+
+105a106
+> int xmlDoValidityCheckingDefaultValue = 0;
+111,121c112,113
+< #if defined(VMS) || defined(__VMS)
+<   #define PLATFORM_VMS
+< /* int xmlDoValidityCheckingDefaultVal = 0;
+<  * int xmlSubstituteEntitiesDefaultVal = 0;
+<  */
+<   #define xmlDoValidityCheckingDefaultValue xmlDoValidityCheckingDefaultVal 
+<   #define xmlSubstituteEntitiesDefaultValue xmlSubstituteEntitiesDefaultVal 
+< #else
+<   int xmlDoValidityCheckingDefaultValue = 0;
+<   int xmlSubstituteEntitiesDefaultValue = 0;
+< #endif
+---
+> int xmlSubstituteEntitiesDefaultValue = 0;
+> 
+289,291d280
+< #ifdef PLATFORM_VMS
+<     gs->xmlDoValidityCheckingDefaultVal = 0;
+< #else
+293,294d281
+< #endif
+< 
+316,318d302
+< #ifdef PLATFORM_VMS
+<     gs->xmlSubstituteEntitiesDefaultVal = 0;
+< #else
+320d303
+< #endif
+404,419c387,390
+< #ifdef PLATFORM_VMS
+<   extern int xmlDoValidityCheckingDefaultVal;
+<   #undef     xmlDoValidityCheckingDefaultVal
+<   int *
+<   __xmlDoValidityCheckingDefVal(void) {
+<     if (IS_MAIN_THREAD)
+< 	return (&xmlDoValidityCheckingDefaultVal);
+<     else
+< 	return (&xmlGetGlobalState()->xmlDoValidityCheckingDefaultVal);
+<   }
+<   #define __xmlDoValidityCheckingDefaultValue __xmlDoValidityCheckingDefVal
+< #else
+<   extern int xmlDoValidityCheckingDefaultValue;
+<   #undef	xmlDoValidityCheckingDefaultValue
+<   int *
+<   __xmlDoValidityCheckingDefaultValue(void) {
+---
+> extern int xmlDoValidityCheckingDefaultValue;
+> #undef	xmlDoValidityCheckingDefaultValue
+> int *
+> __xmlDoValidityCheckingDefaultValue(void) {
+424,425c395
+<   }
+< #endif
+---
+> }
+577,592c547,550
+< #ifdef PLATFORM_VMS
+<   extern int xmlSubstituteEntitiesDefaultVal;
+<   #undef     xmlSubstituteEntitiesDefaultVal
+<   int *
+<   __xmlSubsEntitiesDefaultValue(void) {
+<     if (IS_MAIN_THREAD)
+< 	return (&xmlSubstituteEntitiesDefaultVal);
+<     else
+< 	return (&xmlGetGlobalState()->xmlSubstituteEntitiesDefaultVal);
+<   }
+<   #define __xmlSubstituteEntitiesDefaultValue __xmlSubsEntitiesDefaultValue
+< #else
+<   extern int xmlSubstituteEntitiesDefaultValue;
+<   #undef	xmlSubstituteEntitiesDefaultValue
+<   int *
+<   __xmlSubstituteEntitiesDefaultValue(void) {
+---
+> extern int xmlSubstituteEntitiesDefaultValue;
+> #undef	xmlSubstituteEntitiesDefaultValue
+> int *
+> __xmlSubstituteEntitiesDefaultValue(void) {
+597,598c555
+<   }
+< #endif
+---
+> }
+
+
+--------------------------------------------------------------------------
+TRIO.C
+113,116d112
+< #if defined(VMS) || defined(__VMS)
+< # include <unistd.h>
+< #endif /* Platform is VMS */
+< 
+123d118
+< 
+
+
+--------------------------------------------------------------------------
+GLOBALS.H
+78,86c78,79
+< #if defined(VMS) || defined(__VMS)
+<         int xmlSubstituteEntitiesDefaultVal;    /* 31 character name limit */
+<         int xmlDoValidityCheckingDefaultVal;
+< #define xmlSubstituteEntitiesDefaultValue       xmlSubstituteEntitiesDefaultVal
+< #define xmlDoValidityCheckingDefaultValue       xmlDoValidityCheckingDefaultVal
+< #else
+<         int xmlSubstituteEntitiesDefaultValue;
+<         int xmlDoValidityCheckingDefaultValue;
+< #endif
+---
+> 	int xmlSubstituteEntitiesDefaultValue;
+> 	int xmlDoValidityCheckingDefaultValue;
+211,226c204,209
+< #if defined(VMS) || defined(__VMS)
+<   #ifdef LIBXML_THREAD_ENABLED
+<   extern int *__xmlDoValidityCheckingDefaultVal(void);
+<   #define xmlDoValidityCheckingDefaultVal \
+<   (*(__xmlDoValidityCheckingDefaultVal()))
+<   #else
+<   LIBXML_DLL_IMPORT extern int xmlDoValidityCheckingDefaultVal;
+<   #endif
+< #else
+<   #ifdef LIBXML_THREAD_ENABLED
+<   extern int *__xmlDoValidityCheckingDefaultValue(void);
+<   #define xmlDoValidityCheckingDefaultValue \
+<   (*(__xmlDoValidityCheckingDefaultValue()))
+<   #else
+<   LIBXML_DLL_IMPORT extern int xmlDoValidityCheckingDefaultValue;
+<   #endif
+---
+> #ifdef LIBXML_THREAD_ENABLED
+> extern int *__xmlDoValidityCheckingDefaultValue(void);
+> #define xmlDoValidityCheckingDefaultValue \
+> (*(__xmlDoValidityCheckingDefaultValue()))
+> #else
+> LIBXML_DLL_IMPORT extern int xmlDoValidityCheckingDefaultValue;
+317,332c300,305
+< #if defined(VMS) || defined(__VMS)
+<   #ifdef LIBXML_THREAD_ENABLED
+<   extern int *__xmlSubsEntitiesDefaultValue(void);
+<   #define xmlSubsEntitiesDefaultValue \
+<   (*(__xmlSubsEntitiesDefaultValue()))
+<   #else
+<   LIBXML_DLL_IMPORT extern int xmlSubsEntitiesDefaultValue;
+<   #endif
+< #else
+<   #ifdef LIBXML_THREAD_ENABLED
+<   extern int *__xmlSubstituteEntitiesDefaultValue(void);
+<   #define xmlSubstituteEntitiesDefaultValue \
+<   (*(__xmlSubstituteEntitiesDefaultValue()))
+<   #else
+<   LIBXML_DLL_IMPORT extern int xmlSubstituteEntitiesDefaultValue;
+<   #endif
+---
+> #ifdef LIBXML_THREAD_ENABLED
+> extern int *__xmlSubstituteEntitiesDefaultValue(void);
+> #define xmlSubstituteEntitiesDefaultValue \
+> (*(__xmlSubstituteEntitiesDefaultValue()))
+> #else
+> LIBXML_DLL_IMPORT extern int xmlSubstituteEntitiesDefaultValue;
+
+
+--------------------------------------------------------------------------
+XMLIO.H
+79,82d78
+< #if defined(VMS) || defined(__VMS)
+< void	xmlRegisterDefInputCallbacks		(void);
+< #define xmlRegisterDefaultInputCallbacks xmlRegisterDefInputCallbacks
+< #else
+84d79
+< #endif
+130,133d124
+< #if defined(VMS) || defined(__VMS)
+< void	xmlRegisterDefOutputCallbacks(void);
+< #define xmlRegisterDefaultOutputCallbacks xmlRegisterDefOutputCallbacks
+< #else
+135,136d125
+< #endif
+< 
+
+--------------------------------------------------------------------------
+XPATHINTERNALS.H
+433,436d432
+< #if defined(VMS) || defined(__VMS)
+< void		   xmlXPathRegisteredVarsCleanup(xmlXPathContextPtr ctxt);
+< #define xmlXPathRegisteredVariablesCleanup xmlXPathRegisteredVarsCleanup
+< #else
+438d433
+< #endif
diff --git a/vms/readme.vms b/vms/readme.vms
new file mode 100644
index 0000000..9fe045b
--- /dev/null
+++ b/vms/readme.vms
@@ -0,0 +1,194 @@
+Issues in porting libxml to VMS
+===============================
+
+Here's a summary of the issues I encountered when building LIBXML under
+VMS.  There was some VMS support in the version I got, but it was a little
+out of date with the result that some newer files had problems.
+
+I present this list "as is" to hopefully act as a guide to anyone having
+problems in the future.
+
+That's it.  Good luck!
+
+John A Fotheringham (jaf@jafsoft.com)
+October 2001
+
+
+Installation kit
+----------------
+
+- File attributes.  Having downloaded essentially a Unix distribution, some
+  of the file attributes weren't correct... especially those in the [.VMS]
+  subdirectory.  In EDT you could see line feeds and carriage returns as
+  <LF><CR> etc.  To correct this use the command
+
+	$ set file <filespec> /attr=rfm=stm
+
+  This sets the record format to be "stream".  Other variants may be used
+  instead depending on how you got the files onto your system.  Files will 
+  look okay in an EDT editor once the attributes are set.  Without
+  this the command file may not run correctly, since it may be interpreted
+  as a single line.
+
+- VMS-specific files are in a [.VMS] directory.  If you've found this file
+  then you already know this :-)  This directory contains
+
+      BUILD_LIBXML.COM	- a build command file, which I've radically re-worked
+      CONFIG.VMS	- a configuration file to replace config.h
+
+- Don't execute BUILD_LIBXML.COM until you've done all the following
+
+  - read these notes
+  - copied CONFIG.VMS to CONFIG.H
+  - reviewed the configuration section of BUILD_LIBXML.COM, and in particular
+    updated the module lists in line with MAKEFILE
+  - edited XMLVERSION.H so that WITH_TRIO is defined
+  - identified the location of the include files, so that you can manually
+    set the LIBXML logical if need be.
+  - re-read these notes :-p
+
+  instructions for all these steps are below.
+
+- the file [.vms]config.vms should be used to replace config.h.  This file
+  contains a number of define statements that identify the software options
+  required under VMS
+
+- The include files are in a [.INCLUDE.LIBXML] subdirectory.  You need
+  a logical "libxml" to point to this so that include statements of the
+  form
+
+	#include <libxml/parser.h>
+
+  will work correctly.  The source files are mostly two levels above this
+  directory, although there are some .h files there as well.
+
+- The command file BUILD_LIBXML.COM will do the following
+
+  - setup some logicals
+  - set def to the source directory
+  - compile modules and place them into a LIBXML.OLB library
+  - compile and link a number of self-test programs
+  - compile and link a number of utilities and test programs
+  - set def back to the original directory (i.e. if it fails you might not be
+    where you started :-)
+
+  before running this command file review the configuration segment at
+  the top.  In particular compare the lists of modules with those in the
+  most recent version of the Unix MAKEFILE.  Instructions are contained
+  in the command file itself.
+
+  The command file will attempt to set two logicals
+
+  - xml_srcdir.  The directory containing the source files
+  - libxml.  The include file directory.
+
+  It attempts this by looking for modules globals.c and globals.h in
+  nearby directories.  If this logic fails, you'll need to manually define
+  these logicals.
+
+
+The TRIO package
+----------------
+- A sub-package TRIO is used to provide some functions not naturally available
+  under VMS.  These include support for infinite and undefined numbers,
+  and specialised print functions like "snprintf"
+
+  I had to make several changes to trionan.c in discussion with the author
+  (hopefully these are now included in the distro, so I won't list them here)
+
+  To build this software we need to add
+
+	/IEEE_MODE=UNDERFLOW_TO_ZERO/FLOAT=IEEE 
+
+  to the compile command for xpath.c and trio.c, and to any main program
+  that uses this functionality.  BUILD_LIBXML.COM should do this for you.
+
+- to build in trio support you need the define WITH_TRIO to be set.  This
+  is done by editing xmlversion.h 
+
+
+Compiler and linker errors
+--------------------------
+- the DEC C compiler will produce a number of warnings when compiling the
+  C code.  These include
+
+    - Implicit function warnings.  These indicate functions whose type is
+      not defined in a .h file.  This will probably only happen if your
+      configuration is not correct (e.g. for "snprintf" if you haven't
+      edited xmlversion.h to set WITH_TRIO
+
+      These messages also occur for "read" and "write" when compiling trio.c
+
+    - uninitialised variables.  Not usually a problem.  You can solve this
+      by editing the code to initialise the variables affected
+
+  and with respect to the trionan code
+
+    - no main module for UNDERFLOW_TO_ZERO
+    - float overflow when compiling trionan.c STANDALONE
+
+  You can suppress these "expected" messages by using the compile command
+
+    $ CC /WARN=DISABLE=(FLOATOVERFL,NOMAINUFLO)
+
+  This can be achieved by specifying "NOWARN" as the first command
+  parameter to BUILD_LIBXML as follows
+
+    $ @BUILD_LIBXML NOWARN
+
+- the Linker will report the following error
+
+      %LINK-W-MULDEF, symbol DECC$STRERROR multiply defined
+        in module DECC$SHR file SYS$COMMON:[SYSLIB]DECC$SHR.EXE;5
+
+  This is complaining that DECC$STRERROR is multiply defined, which in turn 
+  is because this system symbol is getting added to LIBXML.OLB when strio.c
+  is compiled.
+
+  I'm not sure what the solution for this is, but this is a fairly benign error.
+
+
+Changes made to the codebase
+----------------------------
+- I changed all dummy declarations in trio.c to be 
+
+    va_list dummy = NULL;
+
+  to prevent compiler whinge in TRIO.C about uninitialised variables
+
+- I had to add the following to nanoftp.c
+
+    #if defined(VMS) || defined(__VMS)
+      #define SOCKLEN_T unsigned int
+    #endif
+
+  This matches similar lines already added to nanohttp.c
+
+- Several variables and function names exceed the 31 character limit 
+  used in VMS.  This leads to compiler warnings.  The solution adopted
+  has been
+
+  a) where variables or functions are defined, set up an ifdef on VMS 
+     to define a variable/function of a shorter name.  This may need to
+     be done in the .h file, and in the implementation .c file
+
+  b) use define statements to map the long name onto a shorter name.  That
+     way all future code can refer to the function/variable by the long name,
+     reducing the need to add VMS-specific code everywhere.
+
+  In the current distro, I had to do this for the following names
+
+  in globals.c, parserinternals.c, globals.h, parser.h
+    xmlSubstituteEntitiesDefaultValue
+    xmlDoValidityCheckingDefaultValue
+
+  in globals.c, globals.h
+    __xmlDoValidityCheckingDefaultValue
+
+  in xmlio.c, xmlio.h
+    xmlRegisterDefaultInputCallbacks
+    xmlRegisterDefaultOutputCallbacks
+
+  in xpath.c and xpathinternals.h
+    xmlXPathRegisteredVariablesCleanup
+