From c69a205b4c3caa954b823dc6837f7e71adba27a4 Mon Sep 17 00:00:00 2001 From: Viktor Dukhovni Date: Tue, 15 Nov 2016 01:33:08 -0500 Subject: [PATCH] Properly integrate upstream vis/unvis Adding appropriate changes to configure.ac and config.h --- lib/libedit/config.h.in | 3 +++ lib/libedit/configure.ac | 17 ++++++++++++++++- lib/libedit/src/readline.c | 3 ++- lib/libedit/src/sys.h | 13 ++++--------- lib/libedit/src/unvis.c | 10 ++-------- lib/libedit/src/vis.c | 37 ++----------------------------------- lib/libedit/src/vis.h | 4 +--- 7 files changed, 30 insertions(+), 57 deletions(-) diff --git a/lib/libedit/config.h.in b/lib/libedit/config.h.in index 06db50685..ba283cc39 100644 --- a/lib/libedit/config.h.in +++ b/lib/libedit/config.h.in @@ -54,6 +54,9 @@ /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_NDIR_H +/* Define to 1 if if your system has SIZE_MAX */ +#undef HAVE_SIZE_MAX + /* Define to 1 if `stat' has the bug that it succeeds when given the zero-length file name argument. */ #undef HAVE_STAT_EMPTY_STRING_BUG diff --git a/lib/libedit/configure.ac b/lib/libedit/configure.ac index e9ea85268..d379a4caf 100644 --- a/lib/libedit/configure.ac +++ b/lib/libedit/configure.ac @@ -42,7 +42,7 @@ AC_CHECK_LIB(curses, tgetent,, AC_HEADER_DIRENT AC_HEADER_STDC AC_HEADER_SYS_WAIT -AC_CHECK_HEADERS([fcntl.h limits.h stdlib.h string.h sys/ioctl.h sys/param.h unistd.h curses.h ncurses.h sys/cdefs.h]) +AC_CHECK_HEADERS([fcntl.h limits.h stdint.h stdlib.h string.h sys/ioctl.h sys/param.h unistd.h curses.h ncurses.h sys/cdefs.h]) AC_CHECK_HEADER([termios.h], [], [AC_MSG_ERROR([termios.h is required!])],[]) @@ -61,6 +61,21 @@ AC_TYPE_PID_T AC_TYPE_SIZE_T AC_CHECK_TYPES([u_int32_t]) +AC_TRY_COMPILE([ +#include +#include +#if HAVE_STDINT_H +# include +#endif +], +[size_t x = SIZE_MAX;], +[have_size_max=yes], +[have_size_max=no]) +if test "$have_size_max" = yes; then + AC_DEFINE([HAVE_SIZE_MAX], [1], + [Define to 1 if if your system has SIZE_MAX]) +fi + # Checks for library functions. AC_FUNC_FORK AC_PROG_GCC_TRADITIONAL diff --git a/lib/libedit/src/readline.c b/lib/libedit/src/readline.c index 70ff6b03d..f4e0a39e3 100644 --- a/lib/libedit/src/readline.c +++ b/lib/libedit/src/readline.c @@ -34,6 +34,8 @@ __RCSID("$NetBSD: readline.c,v 1.139 2016/10/28 18:32:26 christos Exp $"); #endif /* not lint && not SCCSID */ +#include "config.h" + #include #include #include @@ -43,7 +45,6 @@ __RCSID("$NetBSD: readline.c,v 1.139 2016/10/28 18:32:26 christos Exp $"); #include #include #include -#include #include #include #include diff --git a/lib/libedit/src/sys.h b/lib/libedit/src/sys.h index dc0a8cb9a..1321c2096 100644 --- a/lib/libedit/src/sys.h +++ b/lib/libedit/src/sys.h @@ -44,6 +44,10 @@ #include #endif +#ifdef HAVE_STDINT_H +#include +#endif + #if !defined(__attribute__) && (defined(__cplusplus) || !defined(__GNUC__) || __GNUC__ == 2 && __GNUC_MINOR__ < 8) # define __attribute__(A) #endif @@ -101,13 +105,4 @@ typedef unsigned int u_int32_t; #define REGEX /* Use POSIX.2 regular expression functions */ #undef REGEXP /* Use UNIX V8 regular expression functions */ -#if defined(__sun) -extern int tgetent(char *, const char *); -extern int tgetflag(char *); -extern int tgetnum(char *); -extern int tputs(const char *, int, int (*)(int)); -extern char* tgoto(const char*, int, int); -extern char* tgetstr(char*, char**); -#endif - #endif /* _h_sys */ diff --git a/lib/libedit/src/unvis.c b/lib/libedit/src/unvis.c index 30fad8154..719f86a79 100644 --- a/lib/libedit/src/unvis.c +++ b/lib/libedit/src/unvis.c @@ -29,7 +29,7 @@ * SUCH DAMAGE. */ -#include +#include "config.h" #if defined(LIBC_SCCS) && !defined(lint) #if 0 static char sccsid[] = "@(#)unvis.c 8.1 (Berkeley) 6/4/93"; @@ -38,20 +38,14 @@ __RCSID("$NetBSD: unvis.c,v 1.44 2014/09/26 15:43:36 roy Exp $"); #endif #endif /* LIBC_SCCS and not lint */ -#include "namespace.h" #include #include #include -#include #include #include #include -#ifdef __weak_alias -__weak_alias(strnunvisx,_strnunvisx) -#endif - #if !HAVE_VIS /* * decode driven by state machine @@ -327,7 +321,7 @@ unvis(char *cp, int c, int *astate, int flag) *astate = SS(0, S_META1); else if (c == '^') *astate = SS(0, S_CTRL); - else + else goto bad; return UNVIS_NOCHAR; diff --git a/lib/libedit/src/vis.c b/lib/libedit/src/vis.c index b4a5f3291..1071803c4 100644 --- a/lib/libedit/src/vis.c +++ b/lib/libedit/src/vis.c @@ -55,16 +55,11 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include +#include "config.h" #if defined(LIBC_SCCS) && !defined(lint) __RCSID("$NetBSD: vis.c,v 1.71 2016/01/14 20:41:23 christos Exp $"); #endif /* LIBC_SCCS and not lint */ -#ifdef __FBSDID -__FBSDID("$FreeBSD$"); -#define _DIAGASSERT(x) assert(x) -#endif -#include "namespace.h" #include #include @@ -75,10 +70,6 @@ __FBSDID("$FreeBSD$"); #include #include -#ifdef __weak_alias -__weak_alias(strvisx,_strvisx) -#endif - #if !HAVE_VIS || !HAVE_SVIS #include #include @@ -97,7 +88,7 @@ static wchar_t *do_svis(wchar_t *, wint_t, int, wint_t, const wchar_t *); #undef BELL #define BELL L'\a' - + #if defined(LC_C_LOCALE) #define iscgraph(c) isgraph_l(c, LC_C_LOCALE) #else @@ -133,30 +124,6 @@ iscgraph(int c) { static const wchar_t char_shell[] = L"'`\";&<>()|{}]\\$!^~"; static const wchar_t char_glob[] = L"*?[#"; -#if !HAVE_NBTOOL_CONFIG_H -#ifndef __NetBSD__ -/* - * On NetBSD MB_LEN_MAX is currently 32 which does not fit on any integer - * integral type and it is probably wrong, since currently the maximum - * number of bytes and character needs is 6. Until this is fixed, the - * loops below are using sizeof(uint64_t) - 1 instead of MB_LEN_MAX, and - * the assertion is commented out. - */ -#ifdef __FreeBSD__ -/* - * On FreeBSD including for CTASSERT only works in kernel - * mode. - */ -#ifndef CTASSERT -#define CTASSERT(x) _CTASSERT(x, __LINE__) -#define _CTASSERT(x, y) __CTASSERT(x, y) -#define __CTASSERT(x, y) typedef char __assert ## y[(x) ? 1 : -1] -#endif -#endif /* __FreeBSD__ */ -CTASSERT(MB_LEN_MAX <= sizeof(uint64_t)); -#endif /* !__NetBSD__ */ -#endif - /* * This is do_hvis, for HTTP style (RFC 1808) */ diff --git a/lib/libedit/src/vis.h b/lib/libedit/src/vis.h index 501ad182e..a1b23c920 100644 --- a/lib/libedit/src/vis.h +++ b/lib/libedit/src/vis.h @@ -112,9 +112,7 @@ int strnunvis(char *, size_t, const char *); int strunvisx(char *, const char *, int); int strnunvisx(char *, size_t, const char *, int); -#ifndef __LIBC12_SOURCE__ -int unvis(char *, int, int *, int) __RENAME(__unvis50); -#endif +int unvis(char *, int, int *, int); __END_DECLS #endif /* !_VIS_H_ */