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