summaryrefslogtreecommitdiff
path: root/sys/lib/libsa
diff options
context:
space:
mode:
authorJasper Lievisse Adriaanse <jasper@cvs.openbsd.org>2014-07-12 21:54:59 +0000
committerJasper Lievisse Adriaanse <jasper@cvs.openbsd.org>2014-07-12 21:54:59 +0000
commit55a05995977ff661af3b9e512515abc461867ca5 (patch)
treed4bb8dcc9cdf6a4c586530a373c0849e4080678a /sys/lib/libsa
parent131b9116e2e83a04a7aab4b8596774aa49ed6935 (diff)
move getchar() into libsa where applicable
ok miod@
Diffstat (limited to 'sys/lib/libsa')
-rw-r--r--sys/lib/libsa/getchar.c53
-rw-r--r--sys/lib/libsa/stand.h3
2 files changed, 55 insertions, 1 deletions
diff --git a/sys/lib/libsa/getchar.c b/sys/lib/libsa/getchar.c
new file mode 100644
index 00000000000..9df45c7b657
--- /dev/null
+++ b/sys/lib/libsa/getchar.c
@@ -0,0 +1,53 @@
+/* $OpenBSD: getchar.c,v 1.1 2014/07/12 21:54:58 jasper Exp $ */
+
+/*
+ * Copyright (c) 1982, 1986, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#include "stand.h"
+
+int
+getchar(void)
+{
+ int c = cngetc();
+
+ if (c == '\r')
+ c = '\n';
+
+ if ((c < ' ' && c != '\n') || c == '\177')
+ return c;
+
+ putchar(c);
+
+ return c;
+}
diff --git a/sys/lib/libsa/stand.h b/sys/lib/libsa/stand.h
index 75c92df9c52..63f9b738e6b 100644
--- a/sys/lib/libsa/stand.h
+++ b/sys/lib/libsa/stand.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: stand.h,v 1.56 2013/12/28 02:51:07 deraadt Exp $ */
+/* $OpenBSD: stand.h,v 1.57 2014/07/12 21:54:58 jasper Exp $ */
/* $NetBSD: stand.h,v 1.18 1996/11/30 04:35:51 gwr Exp $ */
/*-
@@ -185,6 +185,7 @@ void cnputc(int);
int cngetc(void);
int cnischar(void);
int cnspeed(dev_t, int);
+int getchar(void);
u_int sleep(u_int);
void usleep(u_int);
char *ctime(const time_t *);