2 * $Header: /src/pub/tcsh/ed.init.c,v 3.48 2002/07/06 22:28:13 christos Exp $
3 * $DragonFly: src/contrib/tcsh/Attic/ed.init.c,v 1.2 2003/10/13 21:24:29 dillon Exp $
6 * ed.init.c: Editor initializations
9 * Copyright (c) 1980, 1991 The Regents of the University of California.
10 * All rights reserved.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTS_ION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 RCSID("$Id: ed.init.c,v 3.48 2002/07/06 22:28:13 christos Exp $")
44 /* ed.init.c -- init routines for the line editor */
45 /* #define DEBUG_TTY */
47 int Tty_raw_mode
= 0; /* Last tty change was to raw mode */
48 int MacroLvl
= -1; /* pointer to current macro nesting level; */
50 static int Tty_quote_mode
= 0; /* Last tty change was to quote mode */
51 static unsigned char vdisable
; /* The value of _POSIX_VDISABLE from
54 int Tty_eight_bit
= -1; /* does the tty handle eight bits */
56 extern bool GotTermCaps
;
58 static ttydata_t extty
, edtty
, tstty
;
62 #define SHTTY (insource ? OLDSTD : SHIN)
64 #define uc unsigned char
65 static unsigned char ttychars
[NN_IO
][C_NCC
] = {
67 (uc
)CINTR
, (uc
)CQUIT
, (uc
)CERASE
, (uc
)CKILL
,
68 (uc
)CEOF
, (uc
)CEOL
, (uc
)CEOL2
, (uc
)CSWTCH
,
69 (uc
)CDSWTCH
, (uc
)CERASE2
, (uc
)CSTART
, (uc
)CSTOP
,
70 (uc
)CWERASE
, (uc
)CSUSP
, (uc
)CDSUSP
, (uc
)CREPRINT
,
71 (uc
)CDISCARD
, (uc
)CLNEXT
, (uc
)CSTATUS
, (uc
)CPAGE
,
72 (uc
)CPGOFF
, (uc
)CKILL2
, (uc
)CBRK
, (uc
)CMIN
,
73 (uc
)CTIME
, (uc
)CCHECKPT
76 CINTR
, CQUIT
, CERASE
, CKILL
,
77 _POSIX_VDISABLE
, _POSIX_VDISABLE
, _POSIX_VDISABLE
, _POSIX_VDISABLE
,
78 _POSIX_VDISABLE
, CERASE2
, CSTART
, CSTOP
,
79 _POSIX_VDISABLE
, _POSIX_VDISABLE
, _POSIX_VDISABLE
, _POSIX_VDISABLE
,
80 CDISCARD
, _POSIX_VDISABLE
, _POSIX_VDISABLE
, _POSIX_VDISABLE
,
81 _POSIX_VDISABLE
, _POSIX_VDISABLE
, _POSIX_VDISABLE
, 1,
97 check_window_size(force
)
105 /* don't want to confuse things here */
107 omask
= sigblock(sigmask(SIG_WINDOW
)) & ~sigmask(SIG_WINDOW
);
109 (void) sighold(SIG_WINDOW
);
112 * From: bret@shark.agps.lanl.gov (Bret Thaeler) Avoid sunview bug, where a
113 * partially hidden window gets a SIG_WINDOW every time the text is
116 if (GetSize(&lins
, &cols
) || force
) {
122 ChangeSize(lins
, cols
);
126 ChangeSize(lins
, cols
);
129 (void) sigsetmask(omask
); /* can change it again */
131 (void) sigrelse(SIG_WINDOW
);
142 /* If we were called as a signal handler, restore it. */
144 sigset(snum
, window_change
);
145 #endif /* UNRELSIGS */
152 #endif /* SIG_WINDOW */
155 ed_set_tty_eight_bit()
157 if (tty_getty(SHTTY
, &extty
) == -1) {
159 xprintf("ed_set_tty_eight_bit: tty_getty: %s\n", strerror(errno
));
160 #endif /* DEBUG_TTY */
163 Tty_eight_bit
= tty_geteightbit(&extty
);
171 static int havesetup
= 0;
172 struct varent
*imode
;
174 if (havesetup
) /* if we have never been called */
177 #if defined(POSIX) && defined(_PC_VDISABLE) && !defined(BSD4_4) && \
178 !defined(WINNT_NATIVE)
182 if ((pcret
= fpathconf(SHTTY
, _PC_VDISABLE
)) == -1L)
183 vdisable
= (unsigned char) _POSIX_VDISABLE
;
185 vdisable
= (unsigned char) pcret
;
186 if (vdisable
!= (unsigned char) _POSIX_VDISABLE
&& rst
!= 0)
187 for (rst
= 0; rst
< C_NCC
; rst
++) {
188 if (ttychars
[ED_IO
][rst
] == (unsigned char) _POSIX_VDISABLE
)
189 ttychars
[ED_IO
][rst
] = vdisable
;
190 if (ttychars
[EX_IO
][rst
] == (unsigned char) _POSIX_VDISABLE
)
191 ttychars
[EX_IO
][rst
] = vdisable
;
194 #else /* ! POSIX || !_PC_VDISABLE || BSD4_4 || WINNT_NATIVE */
195 vdisable
= (unsigned char) _POSIX_VDISABLE
;
196 #endif /* POSIX && _PC_VDISABLE && !BSD4_4 && !WINNT_NATIVE */
198 if ((imode
= adrof(STRinputmode
)) != NULL
&& imode
->vec
!= NULL
) {
199 if (!Strcmp(*(imode
->vec
), STRinsert
))
200 inputmode
= MODE_INSERT
;
201 else if (!Strcmp(*(imode
->vec
), STRoverwrite
))
202 inputmode
= MODE_REPLACE
;
205 inputmode
= MODE_INSERT
;
209 SetKillRing(getn(varval(STRkillring
)));
212 if (tty_getty(SHTTY
, &extty
) == -1) {
214 xprintf("ed_Setup: tty_getty: %s\n", strerror(errno
));
215 # endif /* DEBUG_TTY */
219 tstty
= edtty
= extty
;
221 T_Speed
= tty_getspeed(&extty
);
222 T_Tabs
= tty_gettabs(&extty
);
223 Tty_eight_bit
= tty_geteightbit(&extty
);
225 # if defined(POSIX) || defined(TERMIO)
226 extty
.d_t
.c_iflag
&= ~ttylist
[EX_IO
][M_INPUT
].t_clrmask
;
227 extty
.d_t
.c_iflag
|= ttylist
[EX_IO
][M_INPUT
].t_setmask
;
229 extty
.d_t
.c_oflag
&= ~ttylist
[EX_IO
][M_OUTPUT
].t_clrmask
;
230 extty
.d_t
.c_oflag
|= ttylist
[EX_IO
][M_OUTPUT
].t_setmask
;
232 extty
.d_t
.c_cflag
&= ~ttylist
[EX_IO
][M_CONTROL
].t_clrmask
;
233 extty
.d_t
.c_cflag
|= ttylist
[EX_IO
][M_CONTROL
].t_setmask
;
235 extty
.d_t
.c_lflag
&= ~ttylist
[EX_IO
][M_LINED
].t_clrmask
;
236 extty
.d_t
.c_lflag
|= ttylist
[EX_IO
][M_LINED
].t_setmask
;
238 # if defined(IRIX3_3) && SYSVREL < 4
239 extty
.d_t
.c_line
= NTTYDISC
;
240 # endif /* IRIX3_3 && SYSVREL < 4 */
242 # else /* GSTTY */ /* V7, Berkeley style tty */
244 if (T_Tabs
) { /* order of &= and |= is important to XTABS */
245 extty
.d_t
.sg_flags
&= ~(ttylist
[EX_IO
][M_CONTROL
].t_clrmask
|XTABS
);
246 extty
.d_t
.sg_flags
|= ttylist
[EX_IO
][M_CONTROL
].t_setmask
;
249 extty
.d_t
.sg_flags
&= ~ttylist
[EX_IO
][M_CONTROL
].t_clrmask
;
250 extty
.d_t
.sg_flags
|= (ttylist
[EX_IO
][M_CONTROL
].t_setmask
|XTABS
);
253 extty
.d_lb
&= ~ttylist
[EX_IO
][M_LOCAL
].t_clrmask
;
254 extty
.d_lb
|= ttylist
[EX_IO
][M_LOCAL
].t_setmask
;
258 * Reset the tty chars to reasonable defaults
259 * If they are disabled, then enable them.
262 if (tty_cooked_mode(&tstty
)) {
263 tty_getchar(&tstty
, ttychars
[TS_IO
]);
265 * Don't affect CMIN and CTIME for the editor mode
267 for (rst
= 0; rst
< C_NCC
- 2; rst
++)
268 if (ttychars
[TS_IO
][rst
] != vdisable
&&
269 ttychars
[ED_IO
][rst
] != vdisable
)
270 ttychars
[ED_IO
][rst
] = ttychars
[TS_IO
][rst
];
271 for (rst
= 0; rst
< C_NCC
; rst
++)
272 if (ttychars
[TS_IO
][rst
] != vdisable
&&
273 ttychars
[EX_IO
][rst
] != vdisable
)
274 ttychars
[EX_IO
][rst
] = ttychars
[TS_IO
][rst
];
276 tty_setchar(&extty
, ttychars
[EX_IO
]);
277 if (tty_setty(SHTTY
, &extty
) == -1) {
279 xprintf("ed_Setup: tty_setty: %s\n", strerror(errno
));
280 # endif /* DEBUG_TTY */
285 tty_setchar(&extty
, ttychars
[EX_IO
]);
288 (void) sigset(SIG_WINDOW
, window_change
); /* for window systems */
290 #else /* WINNT_NATIVE */
293 xprintf("rst received in ed_Setup() %d\n", rst
);
295 #endif /* WINNT_NATIVE */
303 ResetInLine(1); /* reset the input pointers */
304 GettingInput
= 0; /* just in case */
306 /* XXX This code was here before the kill ring:
307 LastKill = KillBuf; / * no kill buffer * /
308 If there was any reason for that other than to make sure LastKill
309 was initialized, the code below should go in here instead - but
310 it doesn't seem reasonable to lose the entire kill ring (which is
311 "self-initializing") just because you set $term or whatever, so
312 presumably this whole '#ifdef notdef' should just be taken out. */
314 { /* no kill ring - why? */
316 for (i
= 0; i
< KillRingMax
; i
++) {
317 if (KillRing
[i
].buf
!= NULL
)
318 xfree((ptr_t
) KillRing
[i
].buf
);
319 KillRing
[i
].buf
= NULL
;
322 YankPos
= KillPos
= 0;
328 CheckMaps(); /* do a little error checking on key maps */
331 if (ed_Setup(0) == -1)
335 * if we have been called before but GotTermCaps isn't set, our TERM has
336 * changed, so get new termcaps and try again
340 GetTermCaps(); /* does the obvious, but gets term type each
344 # if defined(TERMIO) || defined(POSIX)
345 edtty
.d_t
.c_iflag
&= ~ttylist
[ED_IO
][M_INPUT
].t_clrmask
;
346 edtty
.d_t
.c_iflag
|= ttylist
[ED_IO
][M_INPUT
].t_setmask
;
348 edtty
.d_t
.c_oflag
&= ~ttylist
[ED_IO
][M_OUTPUT
].t_clrmask
;
349 edtty
.d_t
.c_oflag
|= ttylist
[ED_IO
][M_OUTPUT
].t_setmask
;
351 edtty
.d_t
.c_cflag
&= ~ttylist
[ED_IO
][M_CONTROL
].t_clrmask
;
352 edtty
.d_t
.c_cflag
|= ttylist
[ED_IO
][M_CONTROL
].t_setmask
;
354 edtty
.d_t
.c_lflag
&= ~ttylist
[ED_IO
][M_LINED
].t_clrmask
;
355 edtty
.d_t
.c_lflag
|= ttylist
[ED_IO
][M_LINED
].t_setmask
;
358 # if defined(IRIX3_3) && SYSVREL < 4
359 edtty
.d_t
.c_line
= NTTYDISC
;
360 # endif /* IRIX3_3 && SYSVREL < 4 */
364 if (T_Tabs
) { /* order of &= and |= is important to XTABS */
365 edtty
.d_t
.sg_flags
&= ~(ttylist
[ED_IO
][M_CONTROL
].t_clrmask
| XTABS
);
366 edtty
.d_t
.sg_flags
|= ttylist
[ED_IO
][M_CONTROL
].t_setmask
;
369 edtty
.d_t
.sg_flags
&= ~ttylist
[ED_IO
][M_CONTROL
].t_clrmask
;
370 edtty
.d_t
.sg_flags
|= (ttylist
[ED_IO
][M_CONTROL
].t_setmask
| XTABS
);
373 edtty
.d_lb
&= ~ttylist
[ED_IO
][M_LOCAL
].t_clrmask
;
374 edtty
.d_lb
|= ttylist
[ED_IO
][M_LOCAL
].t_setmask
;
375 # endif /* POSIX || TERMIO */
377 tty_setchar(&edtty
, ttychars
[ED_IO
]);
378 #endif /* WINNT_NATIVE */
382 * Check and re-init the line. set the terminal into 1 char at a time mode.
392 #else /* !WINNT_NATIVE */
394 tty_setdisc(SHTTY
, ED_IO
);
397 if (tty_getty(SHTTY
, &tstty
) == -1) {
399 xprintf("Rawmode: tty_getty: %s\n", strerror(errno
));
400 # endif /* DEBUG_TTY */
405 * We always keep up with the eight bit setting and the speed of the
406 * tty. But only we only believe changes that are made to cooked mode!
408 # if defined(POSIX) || defined(TERMIO)
409 Tty_eight_bit
= tty_geteightbit(&tstty
);
410 T_Speed
= tty_getspeed(&tstty
);
414 * Fix from: Steven (Steve) B. Green <xrsbg@charney.gsfc.nasa.gov>
415 * Speed was not being set up correctly under POSIX.
417 if (tty_getspeed(&extty
) != T_Speed
|| tty_getspeed(&edtty
) != T_Speed
) {
418 (void) cfsetispeed(&extty
.d_t
, T_Speed
);
419 (void) cfsetospeed(&extty
.d_t
, T_Speed
);
420 (void) cfsetispeed(&edtty
.d_t
, T_Speed
);
421 (void) cfsetospeed(&edtty
.d_t
, T_Speed
);
426 T_Speed
= tty_getspeed(&tstty
);
427 Tty_eight_bit
= tty_geteightbit(&tstty
);
429 if (extty
.d_t
.sg_ispeed
!= tstty
.d_t
.sg_ispeed
) {
430 extty
.d_t
.sg_ispeed
= tstty
.d_t
.sg_ispeed
;
431 edtty
.d_t
.sg_ispeed
= tstty
.d_t
.sg_ispeed
;
434 if (extty
.d_t
.sg_ospeed
!= tstty
.d_t
.sg_ospeed
) {
435 extty
.d_t
.sg_ospeed
= tstty
.d_t
.sg_ospeed
;
436 edtty
.d_t
.sg_ospeed
= tstty
.d_t
.sg_ospeed
;
438 # endif /* POSIX || TERMIO */
440 if (tty_cooked_mode(&tstty
)) {
442 * re-test for some things here (like maybe the user typed
445 if (tty_gettabs(&tstty
) == 0)
450 # if defined(POSIX) || defined(TERMIO)
451 extty
.d_t
.c_cflag
= tstty
.d_t
.c_cflag
;
452 extty
.d_t
.c_cflag
&= ~ttylist
[EX_IO
][M_CONTROL
].t_clrmask
;
453 extty
.d_t
.c_cflag
|= ttylist
[EX_IO
][M_CONTROL
].t_setmask
;
455 edtty
.d_t
.c_cflag
= tstty
.d_t
.c_cflag
;
456 edtty
.d_t
.c_cflag
&= ~ttylist
[ED_IO
][M_CONTROL
].t_clrmask
;
457 edtty
.d_t
.c_cflag
|= ttylist
[ED_IO
][M_CONTROL
].t_setmask
;
459 extty
.d_t
.c_lflag
= tstty
.d_t
.c_lflag
;
460 extty
.d_t
.c_lflag
&= ~ttylist
[EX_IO
][M_LINED
].t_clrmask
;
461 extty
.d_t
.c_lflag
|= ttylist
[EX_IO
][M_LINED
].t_setmask
;
463 edtty
.d_t
.c_lflag
= tstty
.d_t
.c_lflag
;
464 edtty
.d_t
.c_lflag
&= ~ttylist
[ED_IO
][M_LINED
].t_clrmask
;
465 edtty
.d_t
.c_lflag
|= ttylist
[ED_IO
][M_LINED
].t_setmask
;
467 extty
.d_t
.c_iflag
= tstty
.d_t
.c_iflag
;
468 extty
.d_t
.c_iflag
&= ~ttylist
[EX_IO
][M_INPUT
].t_clrmask
;
469 extty
.d_t
.c_iflag
|= ttylist
[EX_IO
][M_INPUT
].t_setmask
;
471 edtty
.d_t
.c_iflag
= tstty
.d_t
.c_iflag
;
472 edtty
.d_t
.c_iflag
&= ~ttylist
[ED_IO
][M_INPUT
].t_clrmask
;
473 edtty
.d_t
.c_iflag
|= ttylist
[ED_IO
][M_INPUT
].t_setmask
;
475 extty
.d_t
.c_oflag
= tstty
.d_t
.c_oflag
;
476 extty
.d_t
.c_oflag
&= ~ttylist
[EX_IO
][M_OUTPUT
].t_clrmask
;
477 extty
.d_t
.c_oflag
|= ttylist
[EX_IO
][M_OUTPUT
].t_setmask
;
479 edtty
.d_t
.c_oflag
= tstty
.d_t
.c_oflag
;
480 edtty
.d_t
.c_oflag
&= ~ttylist
[ED_IO
][M_OUTPUT
].t_clrmask
;
481 edtty
.d_t
.c_oflag
|= ttylist
[ED_IO
][M_OUTPUT
].t_setmask
;
485 extty
.d_t
.sg_flags
= tstty
.d_t
.sg_flags
;
487 extty
.d_t
.sg_flags
&= ~ttylist
[EX_IO
][M_CONTROL
].t_clrmask
;
488 extty
.d_t
.sg_flags
|= ttylist
[EX_IO
][M_CONTROL
].t_setmask
;
490 if (T_Tabs
) /* order of &= and |= is important to XTABS */
491 extty
.d_t
.sg_flags
&= ~XTABS
;
493 extty
.d_t
.sg_flags
|= XTABS
;
495 extty
.d_lb
= tstty
.d_lb
;
496 extty
.d_lb
&= ~ttylist
[EX_IO
][M_LOCAL
].t_clrmask
;
497 extty
.d_lb
|= ttylist
[EX_IO
][M_LOCAL
].t_setmask
;
499 edtty
.d_t
.sg_flags
= extty
.d_t
.sg_flags
;
500 if (T_Tabs
) { /* order of &= and |= is important to XTABS */
501 edtty
.d_t
.sg_flags
&=
502 ~(ttylist
[ED_IO
][M_CONTROL
].t_clrmask
|XTABS
);
503 edtty
.d_t
.sg_flags
|= ttylist
[ED_IO
][M_CONTROL
].t_setmask
;
506 edtty
.d_t
.sg_flags
&= ~ttylist
[ED_IO
][M_CONTROL
].t_clrmask
;
507 edtty
.d_t
.sg_flags
|=
508 (ttylist
[ED_IO
][M_CONTROL
].t_setmask
|XTABS
);
511 edtty
.d_lb
= tstty
.d_lb
;
512 edtty
.d_lb
&= ~ttylist
[ED_IO
][M_LOCAL
].t_clrmask
;
513 edtty
.d_lb
|= ttylist
[ED_IO
][M_LOCAL
].t_setmask
;
515 # endif /* TERMIO || POSIX */
521 tty_getchar(&tstty
, ttychars
[TS_IO
]);
523 * Check if the user made any changes.
524 * If he did, then propagate the changes to the
525 * edit and execute data structures.
527 for (i
= 0; i
< C_NCC
; i
++)
528 if (ttychars
[TS_IO
][i
] != ttychars
[EX_IO
][i
])
531 if (i
!= C_NCC
|| didsetty
) {
534 * Propagate changes only to the unprotected chars
535 * that have been modified just now.
537 for (i
= 0; i
< C_NCC
; i
++) {
538 if (!((ttylist
[ED_IO
][M_CHAR
].t_setmask
& C_SH(i
))) &&
539 (ttychars
[TS_IO
][i
] != ttychars
[EX_IO
][i
]))
540 ttychars
[ED_IO
][i
] = ttychars
[TS_IO
][i
];
541 if (ttylist
[ED_IO
][M_CHAR
].t_clrmask
& C_SH(i
))
542 ttychars
[ED_IO
][i
] = vdisable
;
544 tty_setchar(&edtty
, ttychars
[ED_IO
]);
546 for (i
= 0; i
< C_NCC
; i
++) {
547 if (!((ttylist
[EX_IO
][M_CHAR
].t_setmask
& C_SH(i
))) &&
548 (ttychars
[TS_IO
][i
] != ttychars
[EX_IO
][i
]))
549 ttychars
[EX_IO
][i
] = ttychars
[TS_IO
][i
];
550 if (ttylist
[EX_IO
][M_CHAR
].t_clrmask
& C_SH(i
))
551 ttychars
[EX_IO
][i
] = vdisable
;
553 tty_setchar(&extty
, ttychars
[EX_IO
]);
558 if (tty_setty(SHTTY
, &edtty
) == -1) {
560 xprintf("Rawmode: tty_setty: %s\n", strerror(errno
));
561 # endif /* DEBUG_TTY */
564 #endif /* WINNT_NATIVE */
566 flush(); /* flush any buffered output */
572 { /* set tty in normal setup */
576 signalfun_t orig_intr
;
579 tty_setdisc(SHTTY
, EX_IO
);
585 /* hold this for reseting tty */
587 orig_intr
= (signalfun_t
) signal(SIGINT
, SIG_IGN
);
591 * sigset doesn't return the previous handler if the signal is held,
592 * it will return SIG_HOLD instead. So instead of restoring the
593 * the signal we would end up installing a blocked SIGINT with a
594 * SIG_IGN signal handler. This is what happened when Cookedmode
595 * was called from sched_run, disabling interrupt for the rest
598 * This is what we do:
599 * - if the signal is blocked, keep it that way
600 * - else set it to SIG_IGN
602 * Casper Dik (casper@fwi.uva.nl)
604 orig_intr
= (signalfun_t
) sigset(SIGINT
, SIG_HOLD
);
605 if (orig_intr
!= SIG_HOLD
)
606 (void) sigset(SIGINT
, SIG_IGN
); /* returns SIG_HOLD */
607 # else /* !SIG_HOLD */
609 * No SIG_HOLD; probably no reliable signals as well.
611 orig_intr
= (signalfun_t
) sigset(SIGINT
, SIG_IGN
);
612 # endif /* SIG_HOLD */
613 # endif /* BSDSIGS */
614 if (tty_setty(SHTTY
, &extty
) == -1) {
616 xprintf("Cookedmode: tty_setty: %s\n", strerror(errno
));
617 # endif /* DEBUG_TTY */
621 (void) signal(SIGINT
, orig_intr
); /* take these again */
623 (void) sigset(SIGINT
, orig_intr
); /* take these again */
624 # endif /* BSDSIGS */
625 #endif /* WINNT_NATIVE */
635 Cursor
= InputBuf
; /* reset cursor */
637 InputLim
= &InputBuf
[INBUFSIZE
- 2];
640 CurrentKeyMap
= CcKeyMap
;
645 LastCmd
= F_UNASSIGNED
; /* previous command executed */
647 MacroLvl
= -1; /* no currently active macros */
650 static Char
*Input_Line
= NULL
;
658 * *Everyone* else has an int, but SunOS wants long!
659 * This breaks where int != long (alpha)
665 xfree((ptr_t
) Input_Line
);
671 #if defined(FIONREAD) && !defined(OREO)
672 (void) ioctl(SHIN
, FIONREAD
, (ioctl_t
) &chrs
);
676 chrs
= read(SHIN
, buf
, (size_t) min(chrs
, BUFSIZE
- 1));
679 Input_Line
= Strsave(str2short(buf
));
680 PushMacro(Input_Line
);
683 /* need to print errno message in case file is migrated */
685 stderror(ERR_SYSTEM
, progname
, strerror(errno
));
688 #endif /* FIONREAD && !OREO */
693 * Bugfix (in Swedish) by:
695 * SICS, PO Box 1263, S-163 13 SPANGA, SWEDEN
696 * {mcvax,munnari,cernvax,diku,inria,prlb2,penet,ukc,unido}!enea!sics.se!jw
697 * Internet: jw@sics.se
699 * (via Hans J Albertsson (thanks))
710 #if defined(TERMIO) || defined(POSIX)
711 qutty
.d_t
.c_iflag
&= ~ttylist
[QU_IO
][M_INPUT
].t_clrmask
;
712 qutty
.d_t
.c_iflag
|= ttylist
[QU_IO
][M_INPUT
].t_setmask
;
714 qutty
.d_t
.c_oflag
&= ~ttylist
[QU_IO
][M_OUTPUT
].t_clrmask
;
715 qutty
.d_t
.c_oflag
|= ttylist
[QU_IO
][M_OUTPUT
].t_setmask
;
717 qutty
.d_t
.c_cflag
&= ~ttylist
[QU_IO
][M_CONTROL
].t_clrmask
;
718 qutty
.d_t
.c_cflag
|= ttylist
[QU_IO
][M_CONTROL
].t_setmask
;
720 qutty
.d_t
.c_lflag
&= ~ttylist
[QU_IO
][M_LINED
].t_clrmask
;
721 qutty
.d_t
.c_lflag
|= ttylist
[QU_IO
][M_LINED
].t_setmask
;
723 qutty
.d_t
.sg_flags
&= ~ttylist
[QU_IO
][M_CONTROL
].t_clrmask
;
724 qutty
.d_t
.sg_flags
|= ttylist
[QU_IO
][M_CONTROL
].t_setmask
;
725 qutty
.d_lb
&= ~ttylist
[QU_IO
][M_LOCAL
].t_clrmask
;
726 qutty
.d_lb
|= ttylist
[QU_IO
][M_LOCAL
].t_setmask
;
728 #endif /* TERMIO || POSIX */
729 if (tty_setty(SHTTY
, &qutty
) == -1) {
731 xprintf("QuoteModeOn: tty_setty: %s\n", strerror(errno
));
732 #endif /* DEBUG_TTY */
735 #endif /* !WINNT_NATIVE */
746 if (tty_setty(SHTTY
, &edtty
) == -1) {
748 xprintf("QuoteModeOff: tty_setty: %s\n", strerror(errno
));
749 #endif /* DEBUG_TTY */