lkundrak / rpms / vim

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