From e21a19e6d78bb591899291470bf89900ac767077 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 3 Sep 2018 11:07:02 +0000 Subject: [PATCH] termcap headers cleanup. #error directive added to prevent crash caused by missing headers --- extra/libedit/sys.h | 27 +-------------------------- extra/libedit/terminal.c | 36 +++++++++++++++++++++++++----------- 2 files changed, 26 insertions(+), 37 deletions(-) diff --git a/extra/libedit/sys.h b/extra/libedit/sys.h index 33638d1565b..bb52ddda29a 100644 --- a/extra/libedit/sys.h +++ b/extra/libedit/sys.h @@ -1,7 +1,7 @@ /* $NetBSD: sys.h,v 1.17 2011/09/28 14:08:04 christos Exp $ */ /*- - * Copyright (c) 1992, 1993 + * Copyright (c) 1992, 2018 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by @@ -129,25 +129,6 @@ 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 - -/* XXXMYSQL: Bug#10218 Command line recall rolls into segfault */ -#if !HAVE_DECL_TGOTO -/* - 'tgoto' is not declared in the system header files, this causes - problems on 64-bit systems. The function returns a 64 bit pointer - but caller see it as "int" and it's thus truncated to 32-bit -*/ -extern char* tgoto(const char*, int, int); -#endif - #ifdef notdef # undef REGEX # undef REGEXP @@ -156,12 +137,6 @@ extern char* tgoto(const char*, int, int); /* * Broken hdrs. */ -extern int tgetent(const char *bp, char *name); -extern int tgetflag(const char *id); -extern int tgetnum(const char *id); -extern char *tgetstr(const char *id, char **area); -extern char *tgoto(const char *cap, int col, int row); -extern int tputs(const char *str, int affcnt, int (*putc)(int)); extern char *getenv(const char *); extern int fprintf(FILE *, const char *, ...); extern int sigsetmask(int); diff --git a/extra/libedit/terminal.c b/extra/libedit/terminal.c index cae2e910da1..a2e2301d51e 100644 --- a/extra/libedit/terminal.c +++ b/extra/libedit/terminal.c @@ -1,7 +1,7 @@ /* $NetBSD: terminal.c,v 1.10 2011/10/04 15:27:04 christos Exp $ */ /*- - * Copyright (c) 1992, 2015 + * Copyright (c) 1992, 2018 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by @@ -42,8 +42,6 @@ static char sccsid[] = "@(#)term.c 8.2 (Berkeley) 4/30/95"; /* * terminal.c: Editor/termcap-curses interface - * We have to declare a static variable here, since the - * termcap putchar routine does not take an argument! */ #include #include @@ -51,22 +49,38 @@ static char sccsid[] = "@(#)term.c 8.2 (Berkeley) 4/30/95"; #include #include #include -#if 0 /* TODO: do we need this */ -#ifdef HAVE_TERMCAP_H -#include -#endif -#endif #ifdef HAVE_CURSES_H #include #elif HAVE_NCURSES_H #include #endif +#if !HAVE_DECL_TGOTO +/* + Bug#10218 Command line recall rolls into segfault: + 'tgoto' is not declared in the system header files, this causes + problems on 64-bit systems. The function returns a 64 bit pointer + but caller see it as "int" and it's thus truncated to 32-bit + */ +extern char* tgoto(const char*, int, int); +#endif + /* Solaris's term.h does horrid things. */ -#if defined(HAVE_TERM_H) && !defined(__sun) -#include +#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**); +#else + #if defined(HAVE_TERM_H) + #include + #else + #error "missing api definition leads to crash on 64-bit systems" + #endif #endif - + #include #include