diff -cr perl5.002/dosish.h perl5.002.new/dosish.h
*** perl5.002/dosish.h	Tue Feb 27 13:29:32 1996
--- perl5.002.new/dosish.h	Sun Mar 03 01:39:06 1996
***************
*** 2,7 ****
--- 2,9 ----
  
  #define BIT_BUCKET "/dev/null"  /* Will this work? */
  #define PERL_SYS_INIT(c,v)
+ #define PERL_SYS_TERM()
+ #define dXSUB_SYS() int dummy
  #define TMPPATH "plXXXXXX"
  
  /*
diff -cr perl5.002/ext/DynaLoader/dl_os2.xs perl5.002.new/ext/DynaLoader/dl_os2.xs
*** perl5.002/ext/DynaLoader/dl_os2.xs	Fri Jan 19 21:55:46 1996
--- perl5.002.new/ext/DynaLoader/dl_os2.xs	Sat Mar 02 18:00:10 1996
***************
*** 27,32 ****
--- 27,34 ----
  	if ((rc = DosLoadModule(fail, sizeof fail, path, &handle)) == 0)
  		return (void *)handle;
  
+ 	retcode = rc;
+ 
  	/* Not found. Check for non-FAT name and try truncated name. */
  	/* Don't know if this helps though... */
  	for (beg = dot = path + strlen(path);
***************
*** 42,48 ****
  			return (void *)handle;
  	}
  
- 	retcode = rc;
  	return NULL;
  }
  
--- 45,50 ----
diff -cr perl5.002/hints/os2.sh perl5.002.new/hints/os2.sh
*** perl5.002/hints/os2.sh	Wed Feb 14 17:40:44 1996
--- perl5.002.new/hints/os2.sh	Thu Feb 29 01:29:52 1996
***************
*** 39,45 ****
      d_fork='define'
      lddlflags='-Zdll'
      ldflags='-Zexe'
!     ccflags='-DDOSISH -DNO_SYS_ALLOC -DOS2=2 -DEMBED -I.'
      use_clib='c'
  else
      d_shrplib='define'
--- 39,45 ----
      d_fork='define'
      lddlflags='-Zdll'
      ldflags='-Zexe'
!     ccflags='-DDOSISH -DNO_SYS_ALLOC -DOS2=2 -DEMBED -I. -DPACK_MALLOC'
      use_clib='c'
  else
      d_shrplib='define'
***************
*** 49,56 ****
      plibext='.lib'
      d_fork='undef'
      lddlflags='-Zdll -Zomf -Zcrtdll'
!     ldflags='-Zexe -Zomf -Zcrtdll'
!     ccflags='-Zomf -DDOSISH -DOS2=2 -DEMBED -I.'
      use_clib='c_import'
  fi
  
--- 49,57 ----
      plibext='.lib'
      d_fork='undef'
      lddlflags='-Zdll -Zomf -Zcrtdll'
!     # Recursive regmatch may eat 2.5M of stack alone.
!     ldflags='-Zexe -Zomf -Zcrtdll -Zstack 32000'
!     ccflags='-Zomf -DDOSISH -DOS2=2 -DEMBED -I. -DPACK_MALLOC'
      use_clib='c_import'
  fi
  
diff -cr perl5.002/lib/File/Copy.pm perl5.002.new/lib/File/Copy.pm
*** perl5.002/lib/File/Copy.pm	Tue Feb 27 13:30:20 1996
--- perl5.002.new/lib/File/Copy.pm	Sat Mar 02 22:36:58 1996
***************
*** 25,32 ****
        unless(@_ == 2 || @_ == 3);
  
      # VMS: perform RMS copy to preserve file attributes, indices, etc.
!     # This function is always defined under VMS, even in miniperl
      if (defined(&File::Copy::rmscopy)) { return File::Copy::rmscopy($_[0],$_[1]) }
  
      my $from = shift;
      my $to = shift;
--- 25,38 ----
        unless(@_ == 2 || @_ == 3);
  
      # VMS: perform RMS copy to preserve file attributes, indices, etc.
!     # This function is always defined under VMS, even in miniperl (same in OS/2)
      if (defined(&File::Copy::rmscopy)) { return File::Copy::rmscopy($_[0],$_[1]) }
+     if (defined(&File::Copy::syscopy) 
+ 	and not ref $_[0] and not ref $_[1] 
+ 	and ref \$_[0] ne 'GLOB' and ref \$_[1] ne 'GLOB') 
+     { 
+ 	return File::Copy::syscopy($_[0],$_[1]);
+     }
  
      my $from = shift;
      my $to = shift;
***************
*** 45,50 ****
--- 51,57 ----
  	*FROM = *$from;
      } else {
  	open(FROM,"<$from")||goto(fail_open1);
+ 	binmode FROM;
  	$closefrom = 1;
      }
  
***************
*** 55,60 ****
--- 62,68 ----
  	*TO = *$to;
      } else {
  	open(TO,">$to")||goto(fail_open2);
+ 	binmode TO;
  	$closeto=1;
      }
  
diff -cr perl5.002/lib/File/Find.pm perl5.002.new/lib/File/Find.pm
*** perl5.002/lib/File/Find.pm	Mon Jan 22 17:44:04 1996
--- perl5.002.new/lib/File/Find.pm	Thu Feb 29 04:14:54 1996
***************
*** 133,140 ****
  
  		# Get link count and check for directoriness.
  
! 		($dev,$ino,$mode,$nlink) = ($Is_VMS ? stat($_) : lstat($_))
! 		    unless ($nlink || $dont_use_nlink);
  		
  		if (-d _) {
  
--- 133,140 ----
  
  		# Get link count and check for directoriness.
  
! 		($dev,$ino,$mode,$nlink) = ($Is_VMS ? stat($_) : lstat($_));
! 		    # unless ($nlink || $dont_use_nlink);
  		
  		if (-d _) {
  
diff -cr perl5.002/miniperlmain.c perl5.002.new/miniperlmain.c
*** perl5.002/miniperlmain.c	Mon Feb 12 11:56:44 1996
--- perl5.002.new/miniperlmain.c	Sat Mar 02 21:44:26 1996
***************
*** 51,56 ****
--- 51,58 ----
      perl_destruct( my_perl );
      perl_free( my_perl );
  
+     PERL_SYS_TERM();
+ 
      exit( exitstatus );
  }
  
***************
*** 58,64 ****
--- 60,67 ----
  
  /* Do not delete this line--writemain depends on it */
  
  static void
  xs_init()
  {
+   dXSUB_SYS;
  }
diff -cr perl5.002/os2/diff.c2ph perl5.002.new/os2/diff.c2ph
*** perl5.002/os2/diff.c2ph	Mon Feb 12 11:57:34 1996
--- perl5.002.new/os2/diff.c2ph	Thu Feb 29 03:27:44 1996
***************
*** 1,13 ****
! *** c2ph.PL~	Mon Nov 20 09:36:16 1995
! --- utils/c2ph.PL	Thu Dec 07 15:24:10 1995
  ***************
! *** 1180,1184 ****
    close OUT or die "Can't close $file: $!";
    chmod 0755, $file or die "Can't reset permissions for $file: $!\n";
    unlink 'pstruct';
! ! link c2ph, pstruct;
    exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';
! --- 1180,1188 ----
    close OUT or die "Can't close $file: $!";
    chmod 0755, $file or die "Can't reset permissions for $file: $!\n";
    unlink 'pstruct';
--- 1,14 ----
! *** utils/c2ph.PL.orig	Mon Jan 29 23:03:22 1996
! --- utils/c2ph.PL	Thu Feb 29 02:58:32 1996
  ***************
! *** 1391,1396 ****
    close OUT or die "Can't close $file: $!";
    chmod 0755, $file or die "Can't reset permissions for $file: $!\n";
    unlink 'pstruct';
! ! print "Linking c2ph to pstruct.\n";
! ! link c2ph, pstruct unless $Config{'osname'} eq 'VMS';
    exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';
! --- 1391,1399 ----
    close OUT or die "Can't close $file: $!";
    chmod 0755, $file or die "Can't reset permissions for $file: $!\n";
    unlink 'pstruct';
diff -cr perl5.002/os2/Makefile.SHs perl5.002.new/os2/Makefile.SHs
*** perl5.002/os2/Makefile.SHs	Mon Feb 12 11:57:12 1996
--- perl5.002.new/os2/Makefile.SHs	Sat Mar 02 20:19:24 1996
***************
*** 19,25 ****
  	echo DATA LOADONCALL NONSHARED MULTIPLE		>>$@
  	echo EXPORTS					>>$@
  	echo '  "ctermid"'				>>$@
! 	echo '  "settmppath"'				>>$@
  !NO!SUBS!
  
  if [ ! -z "$myttyname" ] ; then
--- 19,26 ----
  	echo DATA LOADONCALL NONSHARED MULTIPLE		>>$@
  	echo EXPORTS					>>$@
  	echo '  "ctermid"'				>>$@
! 	echo '  "Perl_OS2_init"'			>>$@
! 	echo '  "OS2_Perl_data"'			>>$@
  !NO!SUBS!
  
  if [ ! -z "$myttyname" ] ; then
diff -cr perl5.002/os2/os2.c perl5.002.new/os2/os2.c
*** perl5.002/os2/os2.c	Mon Feb 12 11:57:42 1996
--- perl5.002.new/os2/os2.c	Sat Mar 02 22:03:54 1996
***************
*** 1,5 ****
--- 1,6 ----
  #define INCL_DOS
  #define INCL_NOPM
+ #define INCL_DOSFILEMGR
  #ifndef NO_SYS_ALLOC 
  #  define INCL_DOSMEMMGR
  #  define INCL_DOSERRORS
***************
*** 269,307 ****
  
  #ifndef NO_SYS_ALLOC
  
! static char *old2K;
  
! #define ONE_K (1<<10)
! #define TWO_K (1<<11)
! #define FOUR_K (1<<12)
! #define FOUR_K_FLAG (FOUR_K - 1)
  
  
  void *
  sbrk(int size)
  {
      char *got;
      APIRET rc;
!     int is2K = 0;
  
      if (!size) return 0;
!     else if (size == TWO_K) {
! 	is2K = 1;
! 	if (old2K) {
! 	    char *ret = old2K;
! 
! 	    old2K = 0;
! 	    return (void *)ret;
! 	}
! 	size = FOUR_K;
!     } else if (size & FOUR_K_FLAG) {
! 	croak("Memory allocation in units %li not multiple to 4K", size);
      }
      rc = DosAllocMem((void **)&got, size, PAG_COMMIT | PAG_WRITE);
      if (rc == ERROR_NOT_ENOUGH_MEMORY) {
  	return (void *) -1;
      } else if ( rc ) die("Got an error from DosAllocMem: %li", (long)rc);
!     if (is2K) old2K = got + TWO_K;
      return (void *)got;
  }
  #endif /* ! defined NO_SYS_ALLOC */
--- 270,319 ----
  
  #ifndef NO_SYS_ALLOC
  
! static char *oldchunk;
! static long oldsize;
  
! #define _32_K (1<<15)
! #define _64_K (1<<16)
  
+ /* The real problem is that DosAllocMem will grant memory on 64K-chunks
+  * boundaries only. Note that addressable space for application memory
+  * is around 240M, thus we will run out of addressable space if we
+  * allocate around 14M worth of 4K segments.
+  * Thus we allocate memory in 64K chunks, and abandon the rest of the old
+  * chunk if the new is bigger than that rest. Also, we just allocate
+  * whatever is requested if the size is bigger that 32K. With this strategy
+  * we cannot lose more than 1/2 of addressable space. */
  
  void *
  sbrk(int size)
  {
      char *got;
      APIRET rc;
!     int small, reqsize;
  
      if (!size) return 0;
!     else if (size <= oldsize) {
! 	got = oldchunk;
! 	oldchunk += size;
! 	oldsize -= size;
! 	return (void *)got;
!     } else if (size >= _32_K) {
! 	small = 0;
!     } else {
! 	reqsize = size;
! 	size = _64_K;
! 	small = 1;
      }
      rc = DosAllocMem((void **)&got, size, PAG_COMMIT | PAG_WRITE);
      if (rc == ERROR_NOT_ENOUGH_MEMORY) {
  	return (void *) -1;
      } else if ( rc ) die("Got an error from DosAllocMem: %li", (long)rc);
!     if (small) {
! 	/* Chunk is small, register the rest for future allocs. */
! 	oldchunk = got + reqsize;
! 	oldsize = size - reqsize;
!     }
      return (void *)got;
  }
  #endif /* ! defined NO_SYS_ALLOC */
***************
*** 325,327 ****
--- 337,385 ----
      strcpy(tpath + len + 1, TMPPATH1);
      tmppath = tpath;
  }
+ 
+ #include "XSUB.h"
+ 
+ XS(XS_File__Copy_syscopy)
+ {
+     dXSARGS;
+     if (items < 2 || items > 3)
+ 	croak("Usage: File::Copy::syscopy(src,dst,flag=0)");
+     {
+ 	char *	src = (char *)SvPV(ST(0),na);
+ 	char *	dst = (char *)SvPV(ST(1),na);
+ 	U32	flag;
+ 	int	RETVAL, rc;
+ 
+ 	if (items < 3)
+ 	    flag = 0;
+ 	else {
+ 	    flag = (unsigned long)SvIV(ST(2));
+ 	}
+ 
+ 	errno = DosCopy(src, dst, flag);
+ 	RETVAL = !errno;
+ 	ST(0) = sv_newmortal();
+ 	sv_setiv(ST(0), (IV)RETVAL);
+     }
+     XSRETURN(1);
+ }
+ 
+ OS2_Perl_data_t OS2_Perl_data;
+ 
+ int
+ Xs_OS2_init()
+ {
+     char *file = __FILE__;
+     {
+         newXS("File::Copy::syscopy", XS_File__Copy_syscopy, file);
+     }
+ }
+ 
+ void
+ Perl_OS2_init()
+ {
+     settmppath();
+     OS2_Perl_data.xs_init = &Xs_OS2_init;
+ }
+ 
diff -cr perl5.002/os2/os2ish.h perl5.002.new/os2/os2ish.h
*** perl5.002/os2/os2ish.h	Tue Feb 27 13:30:36 1996
--- perl5.002.new/os2/os2ish.h	Sat Mar 02 21:45:46 1996
***************
*** 25,39 ****
  
  #define BIT_BUCKET "/dev/null"  /* Will this work? */
  
  #define PERL_SYS_INIT(argcp, argvp) do {	\
      _response(argcp, argvp);			\
      _wildcard(argcp, argvp);			\
!     settmppath(); } while (0)
  
  #define TMPPATH tmppath
  #define TMPPATH1 "plXXXXXX"
  extern char *tmppath;
- void settmppath();
  
  /*
   * fwrite1() should be a routine with the same calling sequence as fwrite(),
--- 25,44 ----
  
  #define BIT_BUCKET "/dev/null"  /* Will this work? */
  
+ void Perl_OS2_init();
+ 
  #define PERL_SYS_INIT(argcp, argvp) do {	\
      _response(argcp, argvp);			\
      _wildcard(argcp, argvp);			\
!     Perl_OS2_init();	} while (0)
! 
! #define PERL_SYS_TERM()
! 
! #define dXSUB_SYS int fake = OS2_XS_init()
  
  #define TMPPATH tmppath
  #define TMPPATH1 "plXXXXXX"
  extern char *tmppath;
  
  /*
   * fwrite1() should be a routine with the same calling sequence as fwrite(),
***************
*** 70,76 ****
  
  #define Stat(fname,bufptr) os2_stat((fname),(bufptr))
  #define Fstat(fd,bufptr)   fstat((fd),(bufptr))
! #define FFlush(fp)         fflush(fp)
  
  #undef S_IFBLK
  #undef S_ISBLK
--- 75,81 ----
  
  #define Stat(fname,bufptr) os2_stat((fname),(bufptr))
  #define Fstat(fd,bufptr)   fstat((fd),(bufptr))
! #define Fflush(fp)         fflush(fp)
  
  #undef S_IFBLK
  #undef S_ISBLK
***************
*** 81,86 ****
  
  #define Stat(fname,bufptr) stat((fname),(bufptr))
  #define Fstat(fd,bufptr)   fstat((fd),(bufptr))
! #define FFlush(fp)         fflush(fp)
  
  #endif
--- 86,109 ----
  
  #define Stat(fname,bufptr) stat((fname),(bufptr))
  #define Fstat(fd,bufptr)   fstat((fd),(bufptr))
! #define Fflush(fp)         fflush(fp)
  
  #endif
+ 
+ /* Our private OS/2 specific data. */
+ 
+ typedef struct OS2_Perl_data {
+   unsigned long flags;
+   unsigned long phab;
+   int (*xs_init)();
+ } OS2_Perl_data_t;
+ 
+ extern OS2_Perl_data_t OS2_Perl_data;
+ 
+ #define hab		((HAB)OS2_Perl_data->phab)
+ #define OS2_Perl_flag	(OS2_Perl_data->flag)
+ #define Perl_HAB_set_f	1
+ #define Perl_HAB_set	(OS2_Perl_flag & Perl_HAB_set_f)
+ #define set_Perl_HAB_f	(OS2_Perl_flag |= Perl_HAB_set_f)
+ #define set_Perl_HAB(h) (set_Perl_HAB_f, hab = h)
+ #define OS2_XS_init() (*OS2_Perl_data.xs_init)()
\ No newline at end of file
diff -cr perl5.002/os2/perl2cmd.pl perl5.002.new/os2/perl2cmd.pl
*** perl5.002/os2/perl2cmd.pl	Mon Jan 22 17:46:34 1996
--- perl5.002.new/os2/perl2cmd.pl	Thu Feb 29 01:29:52 1996
***************
*** 22,28 ****
    $base =~ s|.*/||;
    $file =~ s|/|\\|g ;
    print "Processing $file => $dir\\$base.cmd\n";
!   system "echo extproc perl -S > $dir\\$base.cmd";
!   system "type $file >> $dir\\$base.cmd";
  }
  
--- 22,28 ----
    $base =~ s|.*/||;
    $file =~ s|/|\\|g ;
    print "Processing $file => $dir\\$base.cmd\n";
!   system 'cmd.exe', '/c', "echo extproc perl -Sx > $dir\\$base.cmd";
!   system 'cmd.exe', '/c', "type $file >> $dir\\$base.cmd";
  }
  
diff -cr perl5.002/os2/README perl5.002.new/os2/README
*** perl5.002/os2/README	Mon Feb 12 11:57:18 1996
--- perl5.002.new/os2/README	Sun Mar 03 02:02:24 1996
***************
*** 84,90 ****
  b) when extraction perl5.*.tar.gz you need to extract perl5.*/Configure
  separately, since by default perl5.001m/configure may overwrite it;
  	like this:
! 		tar vzxf perl5.004.tar.gz perl5.004/Configure
  
  c) Necessary manual intervention when compiling on OS/2:
  
--- 84,90 ----
  b) when extraction perl5.*.tar.gz you need to extract perl5.*/Configure
  separately, since by default perl5.001m/configure may overwrite it;
  	like this:
! 		tar vzxf perl5.004.tar.gz --case-sensitive perl5.004/Configure
  
  c) Necessary manual intervention when compiling on OS/2:
  
***************
*** 212,224 ****
  OS/2 extensions
  ~~~~~~~~~~~~~~~
  I include 3 extensions by Andread Kaiser, OS2::REXX, OS2::UPM, and OS2::FTP, 
! with minor changes needed to compile them by standard tools. I cannot 
  test UPM and FTP, so I will appreciate your feedback.
  
  The -R switch of older perl is deprecated. If you need to call a REXX code
  which needs access to variables, include the call into a REXX compartment
  created by 
! 	REXX_call {block};
  
  Two new functions are supported by REXX code, 
  	REXX_eval 'string';
--- 212,225 ----
  OS/2 extensions
  ~~~~~~~~~~~~~~~
  I include 3 extensions by Andread Kaiser, OS2::REXX, OS2::UPM, and OS2::FTP, 
! into my ftp directory, mirrored on CPAN. I made
! some minor changes needed to compile them by standard tools. I cannot 
  test UPM and FTP, so I will appreciate your feedback.
  
  The -R switch of older perl is deprecated. If you need to call a REXX code
  which needs access to variables, include the call into a REXX compartment
  created by 
! 	REXX_call {...block...};
  
  Two new functions are supported by REXX code, 
  	REXX_eval 'string';
diff -cr perl5.002/unixish.h perl5.002.new/unixish.h
*** perl5.002/unixish.h	Tue Feb 27 13:31:26 1996
--- perl5.002.new/unixish.h	Sun Mar 03 01:38:48 1996
***************
*** 62,67 ****
--- 62,69 ----
  
  #define BIT_BUCKET "/dev/null"
  #define PERL_SYS_INIT(c,v)
+ #define PERL_SYS_TERM()
+ #define dXSUB_SYS() int dummy
  
  /*
   * fwrite1() should be a routine with the same calling sequence as fwrite(),
diff -cr perl5.002/utils/h2xs.PL perl5.002.new/utils/h2xs.PL
*** perl5.002/utils/h2xs.PL	Mon Feb 12 12:02:24 1996
--- perl5.002.new/utils/h2xs.PL	Sat Mar 02 16:55:36 1996
***************
*** 576,582 ****
  # Change 1..1 below to 1..last_test_to_print .
  # (It may become useful if the test is moved to ./t subdirectory.)
  
! BEGIN {print "1..1\n";}
  END {print "not ok 1\n" unless $loaded;}
  _END_
  print EX <<_END_;
--- 576,582 ----
  # Change 1..1 below to 1..last_test_to_print .
  # (It may become useful if the test is moved to ./t subdirectory.)
  
! BEGIN { $| = 1; print "1..1\n"; }
  END {print "not ok 1\n" unless $loaded;}
  _END_
  print EX <<_END_;
***************
*** 603,609 ****
  close(EX) || die "Can't close $ext$modpname/Changes: $!\n";
  
  warn "Writing $ext$modpname/MANIFEST\n";
! system '/bin/ls > MANIFEST' or system 'ls > MANIFEST';
  !NO!SUBS!
  
  close OUT or die "Can't close $file: $!";
--- 603,609 ----
  close(EX) || die "Can't close $ext$modpname/Changes: $!\n";
  
  warn "Writing $ext$modpname/MANIFEST\n";
! system 'ls > MANIFEST';
  !NO!SUBS!
  
  close OUT or die "Can't close $file: $!";
diff -cr perl5.002/vms/vmsish.h perl5.002.new/vms/vmsish.h
*** perl5.002/vms/vmsish.h	Tue Feb 27 13:33:16 1996
--- perl5.002.new/vms/vmsish.h	Sun Mar 03 01:40:14 1996
***************
*** 91,96 ****
--- 91,98 ----
  
  #define BIT_BUCKET "_NLA0:"
  #define PERL_SYS_INIT(c,v)  getredirection((c),(v))
+ #define PERL_SYS_TERM()
+ #define dXSUB_SYS() int dummy
  #define HAS_KILL
  #define HAS_WAIT
  
diff -cr perl5.002/writemain.SH perl5.002.new/writemain.SH
*** perl5.002/writemain.SH	Mon Jan 22 17:40:56 1996
--- perl5.002.new/writemain.SH	Sat Mar 02 23:03:10 1996
***************
*** 69,74 ****
--- 69,75 ----
  static void
  xs_init()
  {
+   dXSUB_SYS;
  EOP
  
  if test X"$args" != "X" ; then
