Files
pkgsrc-ng/mail/ja-mh/patches/patch-al
T
2013-09-26 17:14:40 +02:00

204 lines
4.8 KiB
Plaintext

$NetBSD: patch-al,v 1.5 2013/03/28 21:31:25 joerg Exp $
* Add DragonFly support.
* Don't declare errno.
--- uip/vmh.c.orig 2013-03-28 18:02:16.000000000 +0000
+++ uip/vmh.c
@@ -113,13 +113,20 @@ void __cputchar __P((int));
#define SMALLMOVE 1
#define LARGEMOVE 10
+#ifndef A_CHARTEXT
+#define A_CHARTEXT 0xff
+#endif
#define XYZ /* XXX */
-#if (defined(__FreeBSD__) && __FreeBSD__ >= 5) || (defined(linux))
+#if (defined(__FreeBSD__) && __FreeBSD__ >= 5) || (defined(linux)) || defined(__DragonFly__)
struct ldat
{
+#ifdef __DragonFly__
+ char *text;
+#else
NCURSES_CH_T *text;
+#endif
NCURSES_SIZE_T firstchar;
NCURSES_SIZE_T lastchar;
NCURSES_SIZE_T oldindex;
@@ -222,6 +229,15 @@ static struct ltchars ltc;
#endif
#endif /* TIOCGLTC */
+#ifdef __NetBSD__
+static char *tc_CE, *tc_CM, *tc_SO, *tc_SE, *tc_US, *tc_UE;
+#define CE tc_CE
+#define CM tc_CM
+#define SO tc_SO
+#define SE tc_SE
+#define US tc_US
+#define UE tc_UE
+#endif
#if !defined(SYS5) && !defined(BSD44) && !defined(TERMINFO)
int _putchar ();
@@ -239,7 +255,6 @@ static TYPESIG TSTPser ();
/* MISCELLANY */
-extern int errno;
#if !defined(BSD44) && !defined(__GNU_LIBRARY__)
extern int sys_nerr;
extern char *sys_errlist[];
@@ -248,7 +263,9 @@ extern char *sys_errlist[];
static void adorn ();
static vmh(), lreset(), linsert(), ladvance(), lretreat(), lgo();
-static TTYon(), TTYoff(), foreground();
+static foreground();
+static void TTYon (void);
+static void TTYoff (void);
static int PEERinit(), pINI(), pLOOP(), pTTY(), pWIN(), WINinit();
static int WINgetstr(), WINless(), WINputc(), TTYinit(), pWINaux();
/* */
@@ -348,7 +365,11 @@ static vmh () {
wclrtoeol (Command);
wrefresh (Command);
- switch (WINgetstr (Command, buffer)) {
+#ifndef JAPAN
+ switch (WINgetstr (Command, buffer, sizeof(buffer))) {
+#else
+ switch (WINgetstr (Command, (unsigned char *)buffer, sizeof(buffer))) {
+#endif
case NOTOK:
break;
@@ -808,6 +829,9 @@ static int WINinit (nprog) {
sideground ();
#ifndef TERMINFO
+#ifdef __NetBSD__
+ CM = getcap("cm");
+#endif
if (CM == NULL)
#else /* TERMINFO */
if (cursor_address == NULL) /* assume mtr wanted "cm", not "CM" */
@@ -822,6 +846,15 @@ static int WINinit (nprog) {
#ifndef TERMINFO
if (tgetflag ("xt") || tgetnum ("sg") > 0)
SO = SE = US = UE = NULL;
+#ifdef __NetBSD__
+ else {
+ SO = getcap("so");
+ SE = getcap("se");
+ US = getcap("us");
+ UE = getcap("ue");
+ }
+ CE = getcap("ce");
+#endif
#else /* TERMINFO */
/*
* If termcap mapped directly to terminfo, we'd use the following:
@@ -862,21 +895,36 @@ static int WINinit (nprog) {
/* */
-static int WINgetstr (w, buffer)
+static int WINgetstr (w, buffer, size)
register WINDOW *w;
+#ifndef JAPAN
char *buffer;
+#else /* JAPAN */
+unsigned char *buffer;
+#endif /* JAPAN */
+size_t size;
{
register int c;
+#ifndef JAPAN
register char *bp;
+#else /* JAPAN */
+ register unsigned char *bp;
+#endif /* JAPAN */
bp = buffer;
*bp = 0;
+ --size;
for (;;) {
- switch (c = wgetch (w) & 0xff) {
- case ERR:
- adios (NULLCP, "wgetch lost");
+ c = wgetch(w);
+ if (c == ERR)
+ adios (NULLCP, "wgetch lost");
+ if (bp - buffer >= size &&
+ !(c == intrc || c == EOFC || c == ERASE || c == KILL ||
+ c == WERASC || c == '\r' || c == '\n'))
+ continue;
+ switch (c &= A_CHARTEXT) {
case '\f':
wrefresh (curscr);
break;
@@ -1382,7 +1430,7 @@ WINDOW *w;
lp -> l_buf[i] = w -> lines[getcury(w)] -> line[i].ch;
#else
wmove(w, getcury(w), i);
- lp -> l_buf[i] = winch(w); /* 8bit ?? */
+ lp -> l_buf[i] = winch(w) & A_CHARTEXT;
#endif
}
lp -> l_buf[getmaxx(w)] = '\0';
@@ -1413,8 +1461,12 @@ WINDOW *w;
}
#endif /* __NCURSES_H */
for (cp = lp -> l_buf + strlen (lp -> l_buf) - 1; cp >= lp -> l_buf; cp--)
+#ifndef JAPAN
if (isspace (*cp))
- *cp = 0;
+#else /* JAPAN */
+ if (isspace ((unsigned char)(*cp)))
+#endif /* JAPAN */
+ *cp = '\0';
else
break;
@@ -1539,7 +1591,7 @@ static int TTYinit (nprog) {
/* */
-static TTYon () {
+static void TTYon (void) {
if (tty_ready == DONE)
return;
@@ -1573,13 +1625,15 @@ static TTYon () {
/* */
-static TTYoff () {
+static void TTYoff (void) {
if (tty_ready == NOTOK)
return;
INTR = intrc;
#ifndef SYS5
+#ifndef __NetBSD__
(void) ioctl (fileno (stdin), TIOCSETC, (char *) &tc);
+#endif
#else /* SYS5 */
#if defined(TCGETATTR) && !defined(TCSETA) && defined(TCSANOW)
(void) tcsetattr (fileno (stdin), TCSANOW, &sg);
@@ -1591,6 +1645,9 @@ static TTYoff () {
leaveok (curscr, TRUE);
mvcur (0, COLS - 1, LINES - 1, 0);
endwin ();
+#ifdef __NetBSD__
+ (void) ioctl (fileno (stdin), TIOCSETC, (char *) &tc);
+#endif
if (tty_ready == DONE) {
#ifndef TERMINFO
if (CE)