Karsten Hopp 476fd8
To: vim_dev@googlegroups.com
Karsten Hopp 476fd8
Subject: Patch 7.4.119
Karsten Hopp 476fd8
Fcc: outbox
Karsten Hopp 476fd8
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 476fd8
Mime-Version: 1.0
Karsten Hopp 476fd8
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 476fd8
Content-Transfer-Encoding: 8bit
Karsten Hopp 476fd8
------------
Karsten Hopp 476fd8
Karsten Hopp 476fd8
Patch 7.4.119
Karsten Hopp 476fd8
Problem:    Vim doesn't work well on OpenVMS.
Karsten Hopp 476fd8
Solution:   Fix various problems. (Samuel Ferencik)
Karsten Hopp 476fd8
Files:	    src/os_unix.c, src/os_unix.h, src/os_vms.c
Karsten Hopp 476fd8
Karsten Hopp 476fd8
Karsten Hopp 476fd8
*** ../vim-7.4.118/src/os_unix.c	2013-12-11 13:21:44.000000000 +0100
Karsten Hopp 476fd8
--- src/os_unix.c	2013-12-11 16:16:03.000000000 +0100
Karsten Hopp 476fd8
***************
Karsten Hopp 476fd8
*** 168,174 ****
Karsten Hopp 476fd8
  static pid_t wait4pid __ARGS((pid_t, waitstatus *));
Karsten Hopp 476fd8
  
Karsten Hopp 476fd8
  static int  WaitForChar __ARGS((long));
Karsten Hopp 476fd8
! #if defined(__BEOS__)
Karsten Hopp 476fd8
  int  RealWaitForChar __ARGS((int, long, int *));
Karsten Hopp 476fd8
  #else
Karsten Hopp 476fd8
  static int  RealWaitForChar __ARGS((int, long, int *));
Karsten Hopp 476fd8
--- 168,174 ----
Karsten Hopp 476fd8
  static pid_t wait4pid __ARGS((pid_t, waitstatus *));
Karsten Hopp 476fd8
  
Karsten Hopp 476fd8
  static int  WaitForChar __ARGS((long));
Karsten Hopp 476fd8
! #if defined(__BEOS__) || defined(VMS)
Karsten Hopp 476fd8
  int  RealWaitForChar __ARGS((int, long, int *));
Karsten Hopp 476fd8
  #else
Karsten Hopp 476fd8
  static int  RealWaitForChar __ARGS((int, long, int *));
Karsten Hopp 476fd8
***************
Karsten Hopp 476fd8
*** 435,441 ****
Karsten Hopp 476fd8
  	/* Process the queued netbeans messages. */
Karsten Hopp 476fd8
  	netbeans_parse_messages();
Karsten Hopp 476fd8
  #endif
Karsten Hopp 476fd8
- #ifndef VMS  /* VMS: must try reading, WaitForChar() does nothing. */
Karsten Hopp 476fd8
  	/*
Karsten Hopp 476fd8
  	 * We want to be interrupted by the winch signal
Karsten Hopp 476fd8
  	 * or by an event on the monitored file descriptors.
Karsten Hopp 476fd8
--- 435,440 ----
Karsten Hopp 476fd8
***************
Karsten Hopp 476fd8
*** 446,452 ****
Karsten Hopp 476fd8
  		handle_resize();
Karsten Hopp 476fd8
  	    return 0;
Karsten Hopp 476fd8
  	}
Karsten Hopp 476fd8
- #endif
Karsten Hopp 476fd8
  
Karsten Hopp 476fd8
  	/* If input was put directly in typeahead buffer bail out here. */
Karsten Hopp 476fd8
  	if (typebuf_changed(tb_change_cnt))
Karsten Hopp 476fd8
--- 445,450 ----
Karsten Hopp 476fd8
***************
Karsten Hopp 476fd8
*** 5039,5044 ****
Karsten Hopp 476fd8
--- 5037,5043 ----
Karsten Hopp 476fd8
      return avail;
Karsten Hopp 476fd8
  }
Karsten Hopp 476fd8
  
Karsten Hopp 476fd8
+ #ifndef VMS
Karsten Hopp 476fd8
  /*
Karsten Hopp 476fd8
   * Wait "msec" msec until a character is available from file descriptor "fd".
Karsten Hopp 476fd8
   * "msec" == 0 will check for characters once.
Karsten Hopp 476fd8
***************
Karsten Hopp 476fd8
*** 5338,5350 ****
Karsten Hopp 476fd8
  	}
Karsten Hopp 476fd8
  # endif
Karsten Hopp 476fd8
  
Karsten Hopp 476fd8
- # ifdef OLD_VMS
Karsten Hopp 476fd8
- 	/* Old VMS as v6.2 and older have broken select(). It waits more than
Karsten Hopp 476fd8
- 	 * required. Should not be used */
Karsten Hopp 476fd8
- 	ret = 0;
Karsten Hopp 476fd8
- # else
Karsten Hopp 476fd8
  	ret = select(maxfd + 1, &rfds, NULL, &efds, tvp);
Karsten Hopp 476fd8
- # endif
Karsten Hopp 476fd8
  # ifdef EINTR
Karsten Hopp 476fd8
  	if (ret == -1 && errno == EINTR)
Karsten Hopp 476fd8
  	{
Karsten Hopp 476fd8
--- 5337,5343 ----
Karsten Hopp 476fd8
***************
Karsten Hopp 476fd8
*** 5466,5473 ****
Karsten Hopp 476fd8
      return (ret > 0);
Karsten Hopp 476fd8
  }
Karsten Hopp 476fd8
  
Karsten Hopp 476fd8
- #ifndef VMS
Karsten Hopp 476fd8
- 
Karsten Hopp 476fd8
  #ifndef NO_EXPANDPATH
Karsten Hopp 476fd8
  /*
Karsten Hopp 476fd8
   * Expand a path into all matching files and/or directories.  Handles "*",
Karsten Hopp 476fd8
--- 5459,5464 ----
Karsten Hopp 476fd8
*** ../vim-7.4.118/src/os_unix.h	2013-06-12 20:09:44.000000000 +0200
Karsten Hopp 476fd8
--- src/os_unix.h	2013-12-11 16:16:03.000000000 +0100
Karsten Hopp 476fd8
***************
Karsten Hopp 476fd8
*** 225,230 ****
Karsten Hopp 476fd8
--- 225,232 ----
Karsten Hopp 476fd8
  # include <starlet.h>
Karsten Hopp 476fd8
  # include <socket.h>
Karsten Hopp 476fd8
  # include <lib$routines.h>
Karsten Hopp 476fd8
+ # include <libdef.h>
Karsten Hopp 476fd8
+ # include <libdtdef.h>
Karsten Hopp 476fd8
  
Karsten Hopp 476fd8
  # ifdef FEAT_GUI_GTK
Karsten Hopp 476fd8
  #  include "gui_gtk_vms.h"
Karsten Hopp 476fd8
*** ../vim-7.4.118/src/os_vms.c	2010-06-26 06:03:31.000000000 +0200
Karsten Hopp 476fd8
--- src/os_vms.c	2013-12-11 17:10:24.000000000 +0100
Karsten Hopp 476fd8
***************
Karsten Hopp 476fd8
*** 11,16 ****
Karsten Hopp 476fd8
--- 11,33 ----
Karsten Hopp 476fd8
  
Karsten Hopp 476fd8
  #include	"vim.h"
Karsten Hopp 476fd8
  
Karsten Hopp 476fd8
+ /* define _generic_64 for use in time functions */
Karsten Hopp 476fd8
+ #ifndef VAX
Karsten Hopp 476fd8
+ #   include <gen64def.h>
Karsten Hopp 476fd8
+ #else
Karsten Hopp 476fd8
+ /* based on Alpha's gen64def.h; the file is absent on VAX */
Karsten Hopp 476fd8
+ typedef struct _generic_64 {
Karsten Hopp 476fd8
+ #   pragma __nomember_alignment
Karsten Hopp 476fd8
+     __union  {                          /* You can treat me as...  */
Karsten Hopp 476fd8
+ 	/* long long is not available on VAXen */
Karsten Hopp 476fd8
+ 	/* unsigned __int64 gen64$q_quadword; ...a single 64-bit value, or */
Karsten Hopp 476fd8
+ 
Karsten Hopp 476fd8
+ 	unsigned int gen64$l_longword [2]; /* ...two 32-bit values, or */
Karsten Hopp 476fd8
+ 	unsigned short int gen64$w_word [4]; /* ...four 16-bit values */
Karsten Hopp 476fd8
+     } gen64$r_quad_overlay;
Karsten Hopp 476fd8
+ } GENERIC_64;
Karsten Hopp 476fd8
+ #endif
Karsten Hopp 476fd8
+ 
Karsten Hopp 476fd8
  typedef struct
Karsten Hopp 476fd8
  {
Karsten Hopp 476fd8
      char	class;
Karsten Hopp 476fd8
***************
Karsten Hopp 476fd8
*** 669,671 ****
Karsten Hopp 476fd8
--- 686,777 ----
Karsten Hopp 476fd8
      }
Karsten Hopp 476fd8
      return ;
Karsten Hopp 476fd8
  }
Karsten Hopp 476fd8
+ 
Karsten Hopp 476fd8
+ struct typeahead_st {
Karsten Hopp 476fd8
+     unsigned short numchars;
Karsten Hopp 476fd8
+     unsigned char  firstchar;
Karsten Hopp 476fd8
+     unsigned char  reserved0;
Karsten Hopp 476fd8
+     unsigned long  reserved1;
Karsten Hopp 476fd8
+ } typeahead;
Karsten Hopp 476fd8
+ 
Karsten Hopp 476fd8
+ /*
Karsten Hopp 476fd8
+  * Wait "msec" msec until a character is available from file descriptor "fd".
Karsten Hopp 476fd8
+  * "msec" == 0 will check for characters once.
Karsten Hopp 476fd8
+  * "msec" == -1 will block until a character is available.
Karsten Hopp 476fd8
+  */
Karsten Hopp 476fd8
+     int
Karsten Hopp 476fd8
+ RealWaitForChar(fd, msec, check_for_gpm)
Karsten Hopp 476fd8
+     int		fd UNUSED; /* always read from iochan */
Karsten Hopp 476fd8
+     long	msec;
Karsten Hopp 476fd8
+     int		*check_for_gpm UNUSED;
Karsten Hopp 476fd8
+ {
Karsten Hopp 476fd8
+     int status;
Karsten Hopp 476fd8
+     struct _generic_64 time_curr;
Karsten Hopp 476fd8
+     struct _generic_64 time_diff;
Karsten Hopp 476fd8
+     struct _generic_64 time_out;
Karsten Hopp 476fd8
+     unsigned int convert_operation = LIB$K_DELTA_SECONDS_F;
Karsten Hopp 476fd8
+     float sec = (float) msec / 1000;
Karsten Hopp 476fd8
+ 
Karsten Hopp 476fd8
+     /* make sure the iochan is set */
Karsten Hopp 476fd8
+     if (!iochan)
Karsten Hopp 476fd8
+ 	get_tty();
Karsten Hopp 476fd8
+ 
Karsten Hopp 476fd8
+     if (msec > 0) {
Karsten Hopp 476fd8
+         /* time-out specified; convert it to absolute time */
Karsten Hopp 476fd8
+ 
Karsten Hopp 476fd8
+         /* get current time (number of 100ns ticks since the VMS Epoch) */
Karsten Hopp 476fd8
+         status = sys$gettim(&time_curr);
Karsten Hopp 476fd8
+         if (status != SS$_NORMAL)
Karsten Hopp 476fd8
+             return 0; /* error */
Karsten Hopp 476fd8
+ 
Karsten Hopp 476fd8
+         /* construct the delta time */
Karsten Hopp 476fd8
+         status = lib$cvtf_to_internal_time(
Karsten Hopp 476fd8
+                 &convert_operation, &sec, &time_diff);
Karsten Hopp 476fd8
+         if (status != LIB$_NORMAL)
Karsten Hopp 476fd8
+             return 0; /* error */
Karsten Hopp 476fd8
+ 
Karsten Hopp 476fd8
+         /* add them up */
Karsten Hopp 476fd8
+         status = lib$add_times(
Karsten Hopp 476fd8
+                 &time_curr,
Karsten Hopp 476fd8
+                 &time_diff,
Karsten Hopp 476fd8
+                 &time_out);
Karsten Hopp 476fd8
+         if (status != LIB$_NORMAL)
Karsten Hopp 476fd8
+             return 0; /* error */
Karsten Hopp 476fd8
+     }
Karsten Hopp 476fd8
+ 
Karsten Hopp 476fd8
+     while (TRUE) {
Karsten Hopp 476fd8
+         /* select() */
Karsten Hopp 476fd8
+         status = sys$qiow(0, iochan, IO$_SENSEMODE | IO$M_TYPEAHDCNT, iosb,
Karsten Hopp 476fd8
+                 0, 0, &typeahead, 8, 0, 0, 0, 0);
Karsten Hopp 476fd8
+ 	if (status != SS$_NORMAL || (iosb[0] & 0xFFFF) != SS$_NORMAL)
Karsten Hopp 476fd8
+             return 0; /* error */
Karsten Hopp 476fd8
+ 
Karsten Hopp 476fd8
+         if (typeahead.numchars)
Karsten Hopp 476fd8
+             return 1; /* ready to read */
Karsten Hopp 476fd8
+ 
Karsten Hopp 476fd8
+         /* there's nothing to read; what now? */
Karsten Hopp 476fd8
+         if (msec == 0) {
Karsten Hopp 476fd8
+             /* immediate time-out; return impatiently */
Karsten Hopp 476fd8
+             return 0;
Karsten Hopp 476fd8
+         }
Karsten Hopp 476fd8
+         else if (msec < 0) {
Karsten Hopp 476fd8
+             /* no time-out; wait on indefinitely */
Karsten Hopp 476fd8
+             continue;
Karsten Hopp 476fd8
+         }
Karsten Hopp 476fd8
+         else {
Karsten Hopp 476fd8
+             /* time-out needs to be checked */
Karsten Hopp 476fd8
+             status = sys$gettim(&time_curr);
Karsten Hopp 476fd8
+             if (status != SS$_NORMAL)
Karsten Hopp 476fd8
+                 return 0; /* error */
Karsten Hopp 476fd8
+ 
Karsten Hopp 476fd8
+             status = lib$sub_times(
Karsten Hopp 476fd8
+                     &time_out,
Karsten Hopp 476fd8
+                     &time_curr,
Karsten Hopp 476fd8
+                     &time_diff);
Karsten Hopp 476fd8
+             if (status != LIB$_NORMAL)
Karsten Hopp 476fd8
+                 return 0; /* error, incl. time_diff < 0 (i.e. time-out) */
Karsten Hopp 476fd8
+ 
Karsten Hopp 476fd8
+             /* otherwise wait some more */
Karsten Hopp 476fd8
+         }
Karsten Hopp 476fd8
+     }
Karsten Hopp 476fd8
+ }
Karsten Hopp 476fd8
*** ../vim-7.4.118/src/version.c	2013-12-11 15:51:54.000000000 +0100
Karsten Hopp 476fd8
--- src/version.c	2013-12-11 16:09:16.000000000 +0100
Karsten Hopp 476fd8
***************
Karsten Hopp 476fd8
*** 740,741 ****
Karsten Hopp 476fd8
--- 740,743 ----
Karsten Hopp 476fd8
  {   /* Add new patch number below this line */
Karsten Hopp 476fd8
+ /**/
Karsten Hopp 476fd8
+     119,
Karsten Hopp 476fd8
  /**/
Karsten Hopp 476fd8
Karsten Hopp 476fd8
-- 
Karsten Hopp 476fd8
It is hard to understand how a cemetery raised its burial
Karsten Hopp 476fd8
cost and blamed it on the cost of living.
Karsten Hopp 476fd8
Karsten Hopp 476fd8
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 476fd8
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 476fd8
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 476fd8
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///