From c8d67a7da2dc146c959bfa34f055f80b5c39044e Mon Sep 17 00:00:00 2001 From: christos Date: Sat, 17 Jan 2004 17:57:40 +0000 Subject: [PATCH] portability fixes. --- lib/libedit/read.c | 8 ++++---- lib/libedit/readline.c | 8 ++++---- lib/libedit/readline/readline.h | 4 +++- lib/libedit/sys.h | 12 +++++++++++- lib/libedit/term.c | 19 ++++++++++++------- 5 files changed, 34 insertions(+), 17 deletions(-) diff --git a/lib/libedit/read.c b/lib/libedit/read.c index d94b962c75b0..9ecacb9504b3 100644 --- a/lib/libedit/read.c +++ b/lib/libedit/read.c @@ -1,4 +1,4 @@ -/* $NetBSD: read.c,v 1.30 2003/10/18 23:48:42 christos Exp $ */ +/* $NetBSD: read.c,v 1.31 2004/01/17 17:57:40 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)read.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: read.c,v 1.30 2003/10/18 23:48:42 christos Exp $"); +__RCSID("$NetBSD: read.c,v 1.31 2004/01/17 17:57:40 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -508,7 +508,7 @@ el_gets(EditLine *el, int *nread) el->el_chared.c_redo.pos < el->el_chared.c_redo.lim) { if (cmdnum == VI_DELETE_PREV_CHAR && el->el_chared.c_redo.pos != el->el_chared.c_redo.buf - && isprint(el->el_chared.c_redo.pos[-1])) + && isprint((unsigned char)el->el_chared.c_redo.pos[-1])) el->el_chared.c_redo.pos--; else *el->el_chared.c_redo.pos++ = ch; @@ -553,7 +553,7 @@ el_gets(EditLine *el, int *nread) if ((el->el_flags & UNBUFFERED) == 0) num = 0; else if (num == -1) { - *el->el_line.lastchar++ = CTRL('d'); + *el->el_line.lastchar++ = CONTROL('d'); el->el_line.cursor = el->el_line.lastchar; num = 1; } diff --git a/lib/libedit/readline.c b/lib/libedit/readline.c index aa0397496deb..6d0fb6011d3a 100644 --- a/lib/libedit/readline.c +++ b/lib/libedit/readline.c @@ -1,4 +1,4 @@ -/* $NetBSD: readline.c,v 1.44 2003/12/05 13:37:48 lukem Exp $ */ +/* $NetBSD: readline.c,v 1.45 2004/01/17 17:57:40 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: readline.c,v 1.44 2003/12/05 13:37:48 lukem Exp $"); +__RCSID("$NetBSD: readline.c,v 1.45 2004/01/17 17:57:40 christos Exp $"); #endif /* not lint && not SCCSID */ #include @@ -61,10 +61,10 @@ __RCSID("$NetBSD: readline.c,v 1.44 2003/12/05 13:37:48 lukem Exp $"); #ifdef HAVE_ALLOCA_H #include #endif -#include "histedit.h" -#include "readline/readline.h" #include "el.h" #include "fcns.h" /* for EL_NUM_FCNS */ +#include "histedit.h" +#include "readline/readline.h" /* for rl_complete() */ #define TAB '\r' diff --git a/lib/libedit/readline/readline.h b/lib/libedit/readline/readline.h index 59f5f0970fe1..b44f40baaabf 100644 --- a/lib/libedit/readline/readline.h +++ b/lib/libedit/readline/readline.h @@ -1,4 +1,4 @@ -/* $NetBSD: readline.h,v 1.10 2003/10/27 22:26:35 christos Exp $ */ +/* $NetBSD: readline.h,v 1.11 2004/01/17 17:57:40 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -71,7 +71,9 @@ typedef KEYMAP_ENTRY *Keymap; #ifndef CTRL #include +#if !defined(__sun__) && !defined(__hpux__) #include +#endif #ifndef CTRL #define CTRL(c) ((c) & 037) #endif diff --git a/lib/libedit/sys.h b/lib/libedit/sys.h index 39ef09aed3e5..e593ec41ce7c 100644 --- a/lib/libedit/sys.h +++ b/lib/libedit/sys.h @@ -1,4 +1,4 @@ -/* $NetBSD: sys.h,v 1.8 2003/08/07 16:44:33 agc Exp $ */ +/* $NetBSD: sys.h,v 1.9 2004/01/17 17:57:40 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -48,6 +48,16 @@ # define __attribute__(A) #endif +#ifndef __BEGIN_DECLS +# ifdef __cplusplus +# define __BEGIN_DECLS extern "C" { +# define __END_DECLS } +# else +# define __BEGIN_DECLS +# define __END_DECLS +# endif +#endif + #ifndef public # define public /* Externally visible functions/variables */ #endif diff --git a/lib/libedit/term.c b/lib/libedit/term.c index 9bb6f88ea763..2337412c9b76 100644 --- a/lib/libedit/term.c +++ b/lib/libedit/term.c @@ -1,4 +1,4 @@ -/* $NetBSD: term.c,v 1.38 2003/09/14 21:48:55 christos Exp $ */ +/* $NetBSD: term.c,v 1.39 2004/01/17 17:57:40 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)term.c 8.2 (Berkeley) 4/30/95"; #else -__RCSID("$NetBSD: term.c,v 1.38 2003/09/14 21:48:55 christos Exp $"); +__RCSID("$NetBSD: term.c,v 1.39 2004/01/17 17:57:40 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -941,8 +941,11 @@ term_set(EditLine *el, const char *term) /* Get the size */ Val(T_co) = tgetnum("co"); Val(T_li) = tgetnum("li"); - for (t = tstr; t->name != NULL; t++) - term_alloc(el, t, tgetstr(t->name, &area)); + for (t = tstr; t->name != NULL; t++) { + /* XXX: some systems tgetstr needs non const */ + term_alloc(el, t, tgetstr(strchr(t->name, *t->name), + &area)); + } } if (Val(T_co) < 2) @@ -1424,7 +1427,7 @@ term_echotc(EditLine *el, int argc __attribute__((__unused__)), } (void) fprintf(el->el_outfile, fmtd, 0); #else - (void) fprintf(el->el_outfile, fmtd, el->el_tty.t_speed); + (void) fprintf(el->el_outfile, fmtd, (int)el->el_tty.t_speed); #endif return (0); } else if (strcmp(*argv, "rows") == 0 || strcmp(*argv, "lines") == 0) { @@ -1443,8 +1446,10 @@ term_echotc(EditLine *el, int argc __attribute__((__unused__)), scap = el->el_term.t_str[t - tstr]; break; } - if (t->name == NULL) - scap = tgetstr(*argv, &area); + if (t->name == NULL) { + /* XXX: some systems tgetstr needs non const */ + scap = tgetstr(strchr(*argv, **argv), &area); + } if (!scap || scap[0] == '\0') { if (!silent) (void) fprintf(el->el_errfile,