···11-/* $OpenBSD: devopen.c,v 1.10 2011/06/26 23:19:11 tedu Exp $ */
11+/* $OpenBSD: devopen.c,v 1.11 2014/07/12 21:54:58 jasper Exp $ */
2233/*
44 * Copyright (c) 1996-1999 Michael Shalayeff
···127127 pch_pos++;
128128 break;
129129 }
130130-}
131131-132132-int
133133-getchar(void)
134134-{
135135- register int c = cngetc();
136136-137137- if (c == '\r')
138138- c = '\n';
139139-140140- if ((c < ' ' && c != '\n') || c == '\177')
141141- return c;
142142-143143- putchar(c);
144144-145145- return c;
146130}
147131148132char ttyname_buf[8];
+53
sys/lib/libsa/getchar.c
···11+/* $OpenBSD: getchar.c,v 1.1 2014/07/12 21:54:58 jasper Exp $ */
22+33+/*
44+ * Copyright (c) 1982, 1986, 1990, 1993
55+ * The Regents of the University of California. All rights reserved.
66+ *
77+ * Redistribution and use in source and binary forms, with or without
88+ * modification, are permitted provided that the following conditions
99+ * are met:
1010+ * 1. Redistributions of source code must retain the above copyright
1111+ * notice, this list of conditions and the following disclaimer.
1212+ * 2. Redistributions in binary form must reproduce the above copyright
1313+ * notice, this list of conditions and the following disclaimer in the
1414+ * documentation and/or other materials provided with the distribution.
1515+ * 3. All advertising materials mentioning features or use of this software
1616+ * must display the following acknowledgement:
1717+ * This product includes software developed by the University of
1818+ * California, Berkeley and its contributors.
1919+ * 4. Neither the name of the University nor the names of its contributors
2020+ * may be used to endorse or promote products derived from this software
2121+ * without specific prior written permission.
2222+ *
2323+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2424+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2525+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2626+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2727+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2828+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2929+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3030+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3131+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3232+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3333+ * SUCH DAMAGE.
3434+ *
3535+ */
3636+3737+#include "stand.h"
3838+3939+int
4040+getchar(void)
4141+{
4242+ int c = cngetc();
4343+4444+ if (c == '\r')
4545+ c = '\n';
4646+4747+ if ((c < ' ' && c != '\n') || c == '\177')
4848+ return c;
4949+5050+ putchar(c);
5151+5252+ return c;
5353+}