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