Fixed if-else ambiguity bug.
[unix-history] / usr / src / usr.bin / more / ttyin.c
CommitLineData
bfe13c81
KB
1/*
2 * Copyright (c) 1988 Mark Nudleman
3 * Copyright (c) 1988 Regents of the University of California.
4 * All rights reserved.
5 *
f15db449 6 * %sccs.include.redist.c%
bfe13c81
KB
7 */
8
9#ifndef lint
f15db449 10static char sccsid[] = "@(#)ttyin.c 5.4 (Berkeley) %G%";
bfe13c81
KB
11#endif /* not lint */
12
13/*
14 * Routines dealing with getting input from the keyboard (i.e. from the user).
15 */
16
966c6ec0 17#include <less.h>
bfe13c81
KB
18
19static int tty;
20
21/*
22 * Open keyboard for input.
23 * (Just use file descriptor 2.)
24 */
bfe13c81
KB
25open_getchr()
26{
27 tty = 2;
28}
29
30/*
31 * Get a character from the keyboard.
32 */
bfe13c81
KB
33getchr()
34{
35 char c;
36 int result;
37
38 do
39 {
40 result = iread(tty, &c, 1);
41 if (result == READ_INTR)
42 return (READ_INTR);
43 if (result < 0)
44 {
45 /*
46 * Don't call error() here,
47 * because error calls getchr!
48 */
49 quit();
50 }
51 } while (result != 1);
52 return (c & 0177);
53}