Skip to content

Commit fc059b8

Browse files
committed
updated for version 7.4.119
Problem: Vim doesn't work well on OpenVMS. Solution: Fix various problems. (Samuel Ferencik)
1 parent 9826953 commit fc059b8

File tree

4 files changed

+112
-11
lines changed

4 files changed

+112
-11
lines changed

src/os_unix.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ typedef int waitstatus;
168168
static pid_t wait4pid __ARGS((pid_t, waitstatus *));
169169

170170
static int WaitForChar __ARGS((long));
171-
#if defined(__BEOS__)
171+
#if defined(__BEOS__) || defined(VMS)
172172
int RealWaitForChar __ARGS((int, long, int *));
173173
#else
174174
static int RealWaitForChar __ARGS((int, long, int *));
@@ -435,7 +435,6 @@ mch_inchar(buf, maxlen, wtime, tb_change_cnt)
435435
/* Process the queued netbeans messages. */
436436
netbeans_parse_messages();
437437
#endif
438-
#ifndef VMS /* VMS: must try reading, WaitForChar() does nothing. */
439438
/*
440439
* We want to be interrupted by the winch signal
441440
* or by an event on the monitored file descriptors.
@@ -446,7 +445,6 @@ mch_inchar(buf, maxlen, wtime, tb_change_cnt)
446445
handle_resize();
447446
return 0;
448447
}
449-
#endif
450448

451449
/* If input was put directly in typeahead buffer bail out here. */
452450
if (typebuf_changed(tb_change_cnt))
@@ -5039,6 +5037,7 @@ WaitForChar(msec)
50395037
return avail;
50405038
}
50415039

5040+
#ifndef VMS
50425041
/*
50435042
* Wait "msec" msec until a character is available from file descriptor "fd".
50445043
* "msec" == 0 will check for characters once.
@@ -5338,13 +5337,7 @@ RealWaitForChar(fd, msec, check_for_gpm)
53385337
}
53395338
# endif
53405339

5341-
# ifdef OLD_VMS
5342-
/* Old VMS as v6.2 and older have broken select(). It waits more than
5343-
* required. Should not be used */
5344-
ret = 0;
5345-
# else
53465340
ret = select(maxfd + 1, &rfds, NULL, &efds, tvp);
5347-
# endif
53485341
# ifdef EINTR
53495342
if (ret == -1 && errno == EINTR)
53505343
{
@@ -5466,8 +5459,6 @@ RealWaitForChar(fd, msec, check_for_gpm)
54665459
return (ret > 0);
54675460
}
54685461

5469-
#ifndef VMS
5470-
54715462
#ifndef NO_EXPANDPATH
54725463
/*
54735464
* Expand a path into all matching files and/or directories. Handles "*",

src/os_unix.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@
225225
# include <starlet.h>
226226
# include <socket.h>
227227
# include <lib$routines.h>
228+
# include <libdef.h>
229+
# include <libdtdef.h>
228230

229231
# ifdef FEAT_GUI_GTK
230232
# include "gui_gtk_vms.h"

src/os_vms.c

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,23 @@
1111

1212
#include "vim.h"
1313

14+
/* define _generic_64 for use in time functions */
15+
#ifndef VAX
16+
# include <gen64def.h>
17+
#else
18+
/* based on Alpha's gen64def.h; the file is absent on VAX */
19+
typedef struct _generic_64 {
20+
# pragma __nomember_alignment
21+
__union { /* You can treat me as... */
22+
/* long long is not available on VAXen */
23+
/* unsigned __int64 gen64$q_quadword; ...a single 64-bit value, or */
24+
25+
unsigned int gen64$l_longword [2]; /* ...two 32-bit values, or */
26+
unsigned short int gen64$w_word [4]; /* ...four 16-bit values */
27+
} gen64$r_quad_overlay;
28+
} GENERIC_64;
29+
#endif
30+
1431
typedef struct
1532
{
1633
char class;
@@ -669,3 +686,92 @@ vms_remove_version(void * fname)
669686
}
670687
return ;
671688
}
689+
690+
struct typeahead_st {
691+
unsigned short numchars;
692+
unsigned char firstchar;
693+
unsigned char reserved0;
694+
unsigned long reserved1;
695+
} typeahead;
696+
697+
/*
698+
* Wait "msec" msec until a character is available from file descriptor "fd".
699+
* "msec" == 0 will check for characters once.
700+
* "msec" == -1 will block until a character is available.
701+
*/
702+
int
703+
RealWaitForChar(fd, msec, check_for_gpm)
704+
int fd UNUSED; /* always read from iochan */
705+
long msec;
706+
int *check_for_gpm UNUSED;
707+
{
708+
int status;
709+
struct _generic_64 time_curr;
710+
struct _generic_64 time_diff;
711+
struct _generic_64 time_out;
712+
unsigned int convert_operation = LIB$K_DELTA_SECONDS_F;
713+
float sec = (float) msec / 1000;
714+
715+
/* make sure the iochan is set */
716+
if (!iochan)
717+
get_tty();
718+
719+
if (msec > 0) {
720+
/* time-out specified; convert it to absolute time */
721+
722+
/* get current time (number of 100ns ticks since the VMS Epoch) */
723+
status = sys$gettim(&time_curr);
724+
if (status != SS$_NORMAL)
725+
return 0; /* error */
726+
727+
/* construct the delta time */
728+
status = lib$cvtf_to_internal_time(
729+
&convert_operation, &sec, &time_diff);
730+
if (status != LIB$_NORMAL)
731+
return 0; /* error */
732+
733+
/* add them up */
734+
status = lib$add_times(
735+
&time_curr,
736+
&time_diff,
737+
&time_out);
738+
if (status != LIB$_NORMAL)
739+
return 0; /* error */
740+
}
741+
742+
while (TRUE) {
743+
/* select() */
744+
status = sys$qiow(0, iochan, IO$_SENSEMODE | IO$M_TYPEAHDCNT, iosb,
745+
0, 0, &typeahead, 8, 0, 0, 0, 0);
746+
if (status != SS$_NORMAL || (iosb[0] & 0xFFFF) != SS$_NORMAL)
747+
return 0; /* error */
748+
749+
if (typeahead.numchars)
750+
return 1; /* ready to read */
751+
752+
/* there's nothing to read; what now? */
753+
if (msec == 0) {
754+
/* immediate time-out; return impatiently */
755+
return 0;
756+
}
757+
else if (msec < 0) {
758+
/* no time-out; wait on indefinitely */
759+
continue;
760+
}
761+
else {
762+
/* time-out needs to be checked */
763+
status = sys$gettim(&time_curr);
764+
if (status != SS$_NORMAL)
765+
return 0; /* error */
766+
767+
status = lib$sub_times(
768+
&time_out,
769+
&time_curr,
770+
&time_diff);
771+
if (status != LIB$_NORMAL)
772+
return 0; /* error, incl. time_diff < 0 (i.e. time-out) */
773+
774+
/* otherwise wait some more */
775+
}
776+
}
777+
}

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,8 @@ static char *(features[]) =
738738

739739
static int included_patches[] =
740740
{ /* Add new patch number below this line */
741+
/**/
742+
119,
741743
/**/
742744
118,
743745
/**/

0 commit comments

Comments
 (0)