summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2016-02-02 00:43:12 +0000
committerschwarze <schwarze@openbsd.org>2016-02-02 00:43:12 +0000
commit624bc356e5b392d3b59c6a1e54bd132e1385e296 (patch)
treedf3c75da2f35215a0ebd82c8e75593b015ff2375
parentsxidog attaches at sunxi not omap (diff)
downloadwireguard-openbsd-624bc356e5b392d3b59c6a1e54bd132e1385e296.tar.xz
wireguard-openbsd-624bc356e5b392d3b59c6a1e54bd132e1385e296.zip
Get rid of an ugly #ifdef in the middle of el_init() by
hiding the system dependencies away in "sys.h" where they belong. No binary change on OpenBSD. Seems reasonable to christos at NetBSD, too.
-rw-r--r--lib/libedit/el.c9
-rw-r--r--lib/libedit/sys.h7
2 files changed, 11 insertions, 5 deletions
diff --git a/lib/libedit/el.c b/lib/libedit/el.c
index 261596b5e4f..d557a9ae6fc 100644
--- a/lib/libedit/el.c
+++ b/lib/libedit/el.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: el.c,v 1.24 2016/01/30 17:32:52 schwarze Exp $ */
+/* $OpenBSD: el.c,v 1.25 2016/02/02 00:43:12 schwarze Exp $ */
/* $NetBSD: el.c,v 1.61 2011/01/27 23:11:40 christos Exp $ */
/*-
@@ -43,9 +43,12 @@
#include <stdlib.h>
#include <stdarg.h>
#include <ctype.h>
-#include <locale.h>
#include <limits.h>
+#ifdef WIDECHAR
+#include <locale.h>
#include <langinfo.h>
+#endif
+
#include "el.h"
/* el_init():
@@ -79,12 +82,10 @@ el_init(const char *prog, FILE *fin, FILE *fout, FILE *ferr)
* Initialize all the modules. Order is important!!!
*/
el->el_flags = 0;
-#ifdef WIDECHAR
if (setlocale(LC_CTYPE, NULL) != NULL){
if (strcmp(nl_langinfo(CODESET), "UTF-8") == 0)
el->el_flags |= CHARSET_IS_UTF8;
}
-#endif
if (terminal_init(el) == -1) {
free(el->el_prog);
diff --git a/lib/libedit/sys.h b/lib/libedit/sys.h
index 36cd00ce0ea..5b2d6dc2ae2 100644
--- a/lib/libedit/sys.h
+++ b/lib/libedit/sys.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sys.h,v 1.11 2016/01/30 17:32:52 schwarze Exp $ */
+/* $OpenBSD: sys.h,v 1.12 2016/02/02 00:43:12 schwarze Exp $ */
/* $NetBSD: sys.h,v 1.13 2009/12/30 22:37:40 christos Exp $ */
/*-
@@ -93,6 +93,11 @@ size_t strlcpy(char *dst, const char *src, size_t size);
char *fgetln(FILE *fp, size_t *len);
#endif
+#ifndef WIDECHAR
+#define setlocale(c, l) NULL
+#define nl_langinfo(i) ""
+#endif
+
#define REGEX /* Use POSIX.2 regular expression functions */
#undef REGEXP /* Use UNIX V8 regular expression functions */