From 146f07a9224bf9b86dc668de4e63cf3f994b7579 Mon Sep 17 00:00:00 2001 From: christos Date: Sat, 14 Feb 2004 18:23:45 +0000 Subject: [PATCH] Fix the non working unctrl mess: 1. delete the incorrect duplicate macro from unctrl.h 2. move unctrl macros from curses.h to unctrl.h and make curses.h include unctrl.h in curses.h instead of duplicating their definition. 3. constify unctrl arrays; make length unsigned. --- lib/libcurses/curses.h | 9 ++------- lib/libcurses/unctrl.c | 12 +++++++----- lib/libcurses/unctrl.h | 20 ++++++++++++++------ 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/lib/libcurses/curses.h b/lib/libcurses/curses.h index e74fe0d17654..c4d4e908fb70 100644 --- a/lib/libcurses/curses.h +++ b/lib/libcurses/curses.h @@ -1,4 +1,4 @@ -/* $NetBSD: curses.h,v 1.81 2003/12/23 23:12:44 christos Exp $ */ +/* $NetBSD: curses.h,v 1.82 2004/02/14 18:23:45 christos Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -181,12 +181,7 @@ typedef char bool; #define KEY_MOUSE 0x199 /* Mouse event has occurred */ #define KEY_MAX 0x199 /* maximum extended key value */ -/* 8-bit ASCII characters. */ -#define unctrl(c) __unctrl[((unsigned)c) & 0xff] -#define unctrllen(ch) __unctrllen[((unsigned)ch) & 0xff] - -extern char *__unctrl[256]; /* Control strings. */ -extern char __unctrllen[256]; /* Control strings length. */ +#include /* * A window an array of __LINE structures pointed to by the 'lines' pointer. diff --git a/lib/libcurses/unctrl.c b/lib/libcurses/unctrl.c index e852cd0446d6..d1506540983c 100644 --- a/lib/libcurses/unctrl.c +++ b/lib/libcurses/unctrl.c @@ -1,4 +1,4 @@ -/* $NetBSD: unctrl.c,v 1.9 2003/08/07 16:44:25 agc Exp $ */ +/* $NetBSD: unctrl.c,v 1.10 2004/02/14 18:23:45 christos Exp $ */ /* * Copyright (c) 1981, 1993 @@ -34,11 +34,13 @@ #if 0 static char sccsid[] = "@(#)unctrl.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: unctrl.c,v 1.9 2003/08/07 16:44:25 agc Exp $"); +__RCSID("$NetBSD: unctrl.c,v 1.10 2004/02/14 18:23:45 christos Exp $"); #endif -#endif /* not lint */ +#endif /* not lint */ -char *__unctrl[256] = { +#include + +const char * const __unctrl[256] = { "^@", "^A", "^B", "^C", "^D", "^E", "^F", "^G", "^H", "^I", "^J", "^K", "^L", "^M", "^N", "^O", "^P", "^Q", "^R", "^S", "^T", "^U", "^V", "^W", @@ -74,7 +76,7 @@ char *__unctrl[256] = { "0xf8", "0xf9", "0xfa", "0xfb", "0xfc", "0xfd", "0xfe", "0xff", }; -char __unctrllen[256] = { +const unsigned char __unctrllen[256] = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, diff --git a/lib/libcurses/unctrl.h b/lib/libcurses/unctrl.h index 5be474903877..3e38c4dd9c49 100644 --- a/lib/libcurses/unctrl.h +++ b/lib/libcurses/unctrl.h @@ -1,4 +1,4 @@ -/* $NetBSD: unctrl.h,v 1.2 2003/08/07 16:44:25 agc Exp $ */ +/* $NetBSD: unctrl.h,v 1.3 2004/02/14 18:23:45 christos Exp $ */ /* * Copyright (c) 1982, 1993 @@ -31,10 +31,18 @@ * @(#)unctrl.h 8.1 (Berkeley) 5/31/93 */ -/* - * unctrl.h - */ +#ifndef _UNCTRL_H_ +#define _UNCTRL_H_ -extern char *_unctrl[]; +#include -# define unctrl(ch) (_unctrl[ch & 0177]) +__BEGIN_DECLS +extern const char * const __unctrl[]; /* Control strings. */ +extern const unsigned char __unctrllen[]; /* Control strings length. */ +__END_DECLS + +/* 8-bit ASCII characters. */ +#define unctrl(c) __unctrl[((unsigned char)c) & 0xff] +#define unctrllen(c) __unctrllen[((unsigned char)c) & 0xff] + +#endif /* _UNCTRL_H_ */