Skip to content

Commit 6336d50

Browse files
brammoold3zd3z
authored andcommitted
Patch 6.4.010 (extra)
Problem: VMS: Reading typed characters in console mode is inefficient and may not read escape sequences correctly. Solution: Improve the vms_read() function. (Zoltan Arpadffy) Files: src/os_vms.c
1 parent f80411f commit 6336d50

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

src/os_vms.c

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -300,31 +300,36 @@ vms_read(char *inbuf, size_t nbytes)
300300
{
301301
int status, function, len;
302302
TT_MODE tt_mode;
303-
ITEM itmlst[3];
303+
ITEM itmlst[2]; /* terminates on everything */
304304
static long trm_mask[8] = {-1, -1, -1, -1, -1, -1, -1, -1};
305305

306306
/* whatever happened earlier we need an iochan here */
307307
if (!iochan)
308308
tt_mode = get_tty();
309309

310+
/* important: clean the inbuf */
311+
memset(inbuf, 0, nbytes);
312+
313+
/* set up the itemlist for the first read */
310314
vul_item(&itmlst[0], 0, TRM$_MODIFIERS,
311-
(char *)( TRM$M_TM_ESCAPE | TRM$M_TM_TIMED | TRM$M_TM_NOECHO |
312-
TRM$M_TM_NOEDIT | TRM$M_TM_NOFILTR |
313-
TRM$M_TM_NORECALL| TRM$M_TM_TRMNOECHO), 0);
314-
vul_item(&itmlst[1], 0, TRM$_TIMEOUT, (char *) 1, 0 );
315-
vul_item(&itmlst[2], sizeof(trm_mask), TRM$_TERM, (char *)&trm_mask, 0);
315+
(char *)( TRM$M_TM_NOECHO | TRM$M_TM_NOEDIT |
316+
TRM$M_TM_NOFILTR | TRM$M_TM_TRMNOECHO |
317+
TRM$M_TM_NORECALL) , 0);
318+
vul_item(&itmlst[1], sizeof(trm_mask), TRM$_TERM, (char *)&trm_mask, 0);
316319

320+
/* wait forever for a char */
317321
function = (IO$_READLBLK | IO$M_EXTEND);
318-
memset(inbuf, 0, nbytes);
322+
status = sys$qiow(0, iochan, function, &iosb, 0, 0,
323+
inbuf, nbytes-1, 0, 0, &itmlst, sizeof(itmlst));
324+
len = strlen(inbuf); /* how many chars we got? */
325+
326+
/* read immedatelly the rest in the IO queue */
327+
function = (IO$_READLBLK | IO$M_TIMED | IO$M_ESCAPE | IO$M_NOECHO | IO$M_NOFILTR);
328+
status = sys$qiow(0, iochan, function, &iosb, 0, 0,
329+
inbuf+len, nbytes-1-len, 0, 0, 0, 0);
330+
331+
len = strlen(inbuf); /* return the total length */
319332

320-
while (1)
321-
{
322-
status = sys$qiow(0, iochan, function, &iosb, 0, 0, inbuf, nbytes - 1,
323-
0, 0, &itmlst, sizeof(itmlst));
324-
len = strlen(inbuf);
325-
if (len > 0)
326-
break;
327-
}
328333
return len;
329334
}
330335

src/version.c

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

642642
static int included_patches[] =
643643
{ /* Add new patch number below this line */
644+
/**/
645+
10,
644646
/**/
645647
9,
646648
/**/

0 commit comments

Comments
 (0)