🔒 Repository is read-only – file editing is disabled.

recipes/gui/aalib/consolidate-1.patch main

716 linii Raw ← Powrót
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716
diff -Naur a/aalib.m4 b/aalib.m4
--- a/aalib.m4	2001-04-26 16:37:31.000000000 +0200
+++ b/aalib.m4	2024-12-10 21:58:38.476565788 +0100
@@ -9,7 +9,7 @@
 dnl AM_PATH_AALIB([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
 dnl Test for AALIB, and define AALIB_CFLAGS and AALIB_LIBS
 dnl
-AC_DEFUN(AM_PATH_AALIB,
+AC_DEFUN([AM_PATH_AALIB],
 [dnl 
 dnl Get the cflags and libraries from the aalib-config script
 dnl
@@ -40,14 +40,14 @@
   if test "$AALIB_CONFIG" = "no" ; then
     no_aalib=yes
   else
-    AALIB_CFLAGS=`$AALIB_CONFIG $aalibconf_args --cflags`
-    AALIB_LIBS=`$AALIB_CONFIG $aalibconf_args --libs`
+    AALIB_CFLAGS=`$AALIB_CONFIG $aalib_args --cflags`
+    AALIB_LIBS=`$AALIB_CONFIG $aalib_args --libs`
 
     aalib_major_version=`$AALIB_CONFIG $aalib_args --version | \
            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
     aalib_minor_version=`$AALIB_CONFIG $aalib_args --version | \
            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
-    aalib_micro_version=`$AALIB_CONFIG $aalib_config_args --version | \
+    aalib_micro_version=`$AALIB_CONFIG $aalib_args --version | \
            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
     if test "x$enable_aalibtest" = "xyes" ; then
       ac_save_CFLAGS="$CFLAGS"
diff -Naur a/src/aacurkbd.c b/src/aacurkbd.c
--- a/src/aacurkbd.c	2001-04-26 17:03:52.000000000 +0200
+++ b/src/aacurkbd.c	2024-12-10 21:59:49.320013675 +0100
@@ -112,7 +112,7 @@
 	return (AA_UP);
     case KEY_DOWN:
 	return (AA_DOWN);
-#ifdef KEY_MOUDE
+#ifdef KEY_MOUSE
     case KEY_MOUSE:
 #ifdef GPM_MOUSEDRIVER
 	if (!__curses_usegpm)
diff -Naur a/src/aacurses.c b/src/aacurses.c
--- a/src/aacurses.c	2001-04-26 16:37:31.000000000 +0200
+++ b/src/aacurses.c	2024-12-10 21:59:36.949986461 +0100
@@ -71,8 +71,8 @@
 {
     if (__resized_curses)
 	curses_uninit(c), curses_init(&c->params, NULL,&c->driverparams, NULL), __resized_curses = 0;
-    *width = stdscr->_maxx + 1;
-    *height = stdscr->_maxy + 1;
+    *width = getmaxx(stdscr);
+    *height = getmaxy(stdscr);
 #ifdef GPM_MOUSEDRIVER
     gpm_mx = *width;
     gpm_my = *height;
diff -Naur a/src/aafire.c b/src/aafire.c
--- a/src/aafire.c	2001-04-26 17:30:03.000000000 +0200
+++ b/src/aafire.c	2024-12-10 21:59:02.596593049 +0100
@@ -1,4 +1,5 @@
 #include <stdio.h>
+#include <stdlib.h>
 #include "aalib.h"
 
 #define XSIZ aa_imgwidth(context)
diff -Naur a/src/aainfo.c b/src/aainfo.c
--- a/src/aainfo.c	2001-04-26 16:37:31.000000000 +0200
+++ b/src/aainfo.c	2024-12-10 21:59:02.596593049 +0100
@@ -1,3 +1,4 @@
+#include <stdlib.h>
 
 #include "aalib.h"
 #include "aaint.h"
diff -Naur a/src/aakbdreg.c b/src/aakbdreg.c
--- a/src/aakbdreg.c	2001-04-26 16:37:31.000000000 +0200
+++ b/src/aakbdreg.c	2024-12-10 21:59:02.599926387 +0100
@@ -1,4 +1,5 @@
 #include <malloc.h>
+#include <string.h>
 #include "config.h"
 #include "aalib.h"
 #include "aaint.h"
diff -Naur a/src/aalib.c b/src/aalib.c
--- a/src/aalib.c	2001-04-26 16:37:31.000000000 +0200
+++ b/src/aalib.c	2024-12-10 21:59:02.599926387 +0100
@@ -1,4 +1,5 @@
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <malloc.h>
 #include "aalib.h"
diff -Naur a/src/aalinuxkbd.c b/src/aalinuxkbd.c
--- a/src/aalinuxkbd.c	2001-04-26 16:37:31.000000000 +0200
+++ b/src/aalinuxkbd.c	2024-12-10 21:59:27.373300696 +0100
@@ -8,6 +8,7 @@
  */
 
 #include "config.h"
+#include <stdlib.h>
 #ifdef LINUX_DRIVER
 #include <sys/time.h>
 #include <sys/types.h>
@@ -114,6 +115,7 @@
 static int vtswitch_allowed;
 
 static char key_down[128];
+static size_t key_down_size = 128;
 static int closed = 1;
 static int mypid;
 
@@ -165,10 +167,7 @@
 
 static void blank_key_down(void)
 {
-    int f;
-
-    for (f = 0; f < NR_KEYS; f++)
-	key_down[f] = 0;
+    memset(key_down, 0, key_down_size);
 }
 
 
@@ -200,7 +199,7 @@
 static int rawmode_init(void)
 {
     if (!closed)
-	return;
+	return 1;
     mypid = getpid();
     if (tty_fd == -1) {
 	tty_fd = fileno(stdin);
diff -Naur a/src/aalinuxkbd.c.orig b/src/aalinuxkbd.c.orig
--- a/src/aalinuxkbd.c.orig	1970-01-01 01:00:00.000000000 +0100
+++ b/src/aalinuxkbd.c.orig	2024-12-10 21:59:21.869957184 +0100
@@ -0,0 +1,497 @@
+/* Raw keyboard mode driver for linux console by Jan Hubicka.
+ * This driver is based on:
+ * librawkey v0.21 - (c) 1994, 1995 Russell Marks
+ * This library may be freely used/copied/modified provided this copyright
+ * notice is left intact.
+ *
+ * needs keymap support in kernel - been there since 0.99pl12 I think.
+ */
+
+#include "config.h"
+#include <stdlib.h>
+#ifdef LINUX_DRIVER
+#include <sys/time.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <termios.h>
+#include <sys/ioctl.h>
+#include <linux/kd.h>		/* RAW mode stuff, etc. */
+#include <linux/keyboard.h>	/* mainly for NR_KEYS */
+#include <linux/vt.h>		/* for VT stuff - nah, really? :) */
+#include <string.h>
+#include <setjmp.h>
+#ifdef GPM_MOUSEDRIVER
+#include <gpm.h>
+#endif
+#include "aalib.h"
+#include "aaint.h"
+static struct termios oldios;
+
+/* random keys not convered anywhere else below */
+#define ESCAPE_KEY	0x01
+#define ENTER_KEY	28
+#define BACKSPACE	14
+#define TAB_KEY		15
+
+/* shifts */
+#define LEFT_SHIFT	0x2A
+#define RIGHT_SHIFT	0x36
+#define LEFT_CTRL	0x1D
+#define LEFT_ALT	0x38
+
+/* NB: right ctrl sends 0xE0 then LEFT_CTRL, right alt sends 0xE0 then
+ * LEFT_ALT. If you want to do any shift handling, you probably want to
+ * just ignore 0xE0, and look for LEFT_CTRL and LEFT_ALT.
+ * note that using scan_keyboard() and is_key_pressed() does this for you.
+ */
+
+/* function keys */
+
+/* this macro lets you do things like FUNC_KEY(1), FUNC_KEY(2), etc. up to
+ * FUNC_KEY(12).
+ * don't use any side-effects with it.
+ */
+#define FUNC_KEY(z)	(0x3A+(z)+(((z)>10)?18:0))
+
+/* cursors, pgup, pgdn, etc. */
+
+#define CURSOR_LEFT	0x4B
+#define CURSOR_RIGHT	0x4D
+#define CURSOR_UP	0x48
+#define CURSOR_DOWN	0x50
+#define CURSORBLOCK_LEFT	105
+#define CURSORBLOCK_RIGHT	106
+#define CURSORBLOCK_UP	103
+#define CURSORBLOCK_DOWN	108
+#define KEYPAD_CENTER	0x4C	/* the '5' in the centre of the keypad */
+
+#define INSERT_KEY	0x52
+#define DELETE_KEY	0x53
+#define HOME_KEY	0x47
+#define END_KEY		0x4F
+#define PAGE_UP		0x49
+#define PAGE_DOWN	0x51
+
+/* NB: the 'grey' cursors, pgup, pgdn etc. generate 0xE0 before sending the
+ * above codes. The easiest way to deal with this is to ignore 0xE0. :)
+ */
+
+#define CAPS_LOCK	0x3A
+#define NUM_LOCK	0x45
+#define SCROLL_LOCK	0x46
+
+/* PrintScreen generates E0, 2A, E0, 37.        (0x63?)
+ * Pause generates E1, 10, 45.                        (0x77?)
+ * I leave it up to you how to figure those two out properly,
+ * but the easiest way is to ignore them. :-/
+ */
+
+#define GRAY_PLUS	0x4E
+#define GRAY_MINUS	0x4A
+#define GRAY_MULTIPLY	0x37	/* NB: also gen'd by PrtSc, see above */
+#define GRAY_DIVIDE	0x36	/* NB: prefixed by 0xE0 */
+
+
+
+/* for most other keys, you should use the keymap_trans() function to
+ * convert the scancode to whatever the keymap would normally generate.
+ */
+
+
+
+/* prototypes */
+
+/* NB: it is *vital* that you call rawmode_exit() when you finish, or
+ * else you'll be left with the keyboard translation in RAW mode! Not Good.
+ * Consider setting up a SIGSEGV handler that calls it, etc. just in case.
+ */
+
+static int keymap[2][NR_KEYS];	/* scancode -> ASCII translation */
+static int tty_fd = -1, restart_con, alt_pressed;
+static struct termios new_termio, old_termio;
+static int vtswitch_allowed;
+
+static char key_down[128];
+static size_t key_down_size = 128;
+static int closed = 1;
+static int mypid;
+
+
+/* it's really easy to translate the scancodes these days, we just
+ * use the keytable stuff!
+ *
+ * returns 0 on error, 1 if ok
+ */
+static int get_keyb_map(void)
+{
+    static struct kbentry keyb_ent;
+    int f;
+
+    keyb_ent.kb_table = 0;	/* unshifted */
+    for (f = 0; f < NR_KEYS; f++) {
+	keyb_ent.kb_index = f;
+
+	if (ioctl(tty_fd, KDGKBENT, (unsigned int) &keyb_ent))
+	    return (0);
+
+	keymap[0][f] = keyb_ent.kb_value;
+    }
+    keyb_ent.kb_table = 1;	/* unshifted */
+    for (f = 0; f < NR_KEYS; f++) {
+	keyb_ent.kb_index = f;
+
+	if (ioctl(tty_fd, KDGKBENT, (unsigned int) &keyb_ent))
+	    return (0);
+
+	keymap[1][f] = keyb_ent.kb_value;
+    }
+    return (1);
+}
+
+
+
+
+static void allow_switch(int on)
+{
+    vtswitch_allowed = on;
+}
+
+static void raw_mode(int tty_fd, int on)
+{
+    ioctl(tty_fd, KDSKBMODE, on ? K_MEDIUMRAW : K_XLATE);
+}
+
+
+static void blank_key_down(void)
+{
+    memset(key_down, 0, key_down_size);
+}
+
+
+static void vt_from_here(int num)
+{
+    ioctl(tty_fd, TCSETSW, &old_termio);
+    raw_mode(tty_fd, 0);	/* don't use rawmode_exit 'cos of other things it does */
+    ioctl(tty_fd, VT_RELDISP, VT_ACKACQ);
+    signal(SIGUSR1, vt_from_here);
+}
+
+
+static void vt_to_here(int num)
+{
+    struct termios ios;
+    ioctl(tty_fd, TCSETSW, &new_termio);
+    restart_con = 1;		/* we're back, say to start up again */
+    alt_pressed = 0;
+    raw_mode(tty_fd, 1);
+    ios = oldios;
+    ios.c_lflag &= ~ECHO;
+    tcsetattr(tty_fd, 0, &ios);
+    blank_key_down();
+    signal(SIGUSR2, vt_to_here);
+}
+
+
+/* returns 1 if ok, 0 otherwise */
+static int rawmode_init(void)
+{
+    if (!closed)
+	return;
+    mypid = getpid();
+    if (tty_fd == -1) {
+	tty_fd = fileno(stdin);
+	fcntl(tty_fd, F_SETFL, O_NONBLOCK);
+    }
+/* fix termio stuff so ^C-style interrupts are ignored */
+    ioctl(tty_fd, TCGETS, &old_termio);
+    new_termio = old_termio;
+    new_termio.c_lflag &= ~(ISIG | ICANON);
+    ioctl(tty_fd, TCSETSW, &new_termio);
+
+    if (get_keyb_map()) {
+	struct vt_mode vtm;
+	struct termios ios;
+
+	blank_key_down();
+	raw_mode(tty_fd, 1);
+	signal(SIGUSR1, vt_from_here);
+	signal(SIGUSR2, vt_to_here);
+	ioctl(tty_fd, VT_GETMODE, &vtm);
+	vtm.mode = VT_PROCESS;
+	vtm.relsig = SIGUSR1;
+	vtm.acqsig = SIGUSR2;
+	ioctl(tty_fd, VT_SETMODE, &vtm);
+
+	tcgetattr(tty_fd, &oldios);
+	ios = oldios;
+	ios.c_lflag &= ~ECHO;
+	tcsetattr(tty_fd, 0, &ios);
+	closed = 0;
+
+	return (1);
+    } else
+	return (0);
+}
+
+
+static void rawmode_exit(void)
+{
+    struct vt_mode vtm;
+
+    if (mypid != getpid())
+	return;
+    if (closed)
+	return;
+    closed = 1;
+    raw_mode(tty_fd, 0);
+    ioctl(tty_fd, VT_GETMODE, &vtm);
+    vtm.mode = VT_AUTO;
+    ioctl(tty_fd, VT_SETMODE, &vtm);
+    ioctl(tty_fd, TCSETSW, &old_termio);
+    fcntl(tty_fd, F_SETFL, 0);	/* allow for old versions of bash */
+    tty_fd = -1;
+    tcsetattr(tty_fd, 0, &oldios);
+}
+
+
+/* returns -1 if no keypresses pending, else returns scancode. */
+static int get_scancode(void)
+{
+    unsigned char c;
+
+    if (read(tty_fd, &c, 1) <= 0)
+	return (-1);
+
+    return ((int) c);
+}
+
+
+/* this is the routine you should call whenever you would normally
+ * read a keypress. However, to actually tell if a key is pressed,
+ * call is_key_pressed() with a scancode as arg.
+ */
+static int scan_keyboard(void)
+{
+    int c, key, flag;
+
+/* we use BFI to fix the PrtSc/Pause problem - i.e. we don't :^) */
+    while ((c = get_scancode()) == 0xE0);
+    if (c == 0xE1)
+	c = get_scancode();
+
+    if (c == -1)
+	return -1;		/* no key was pressed */
+
+    key = c & 127;
+    flag = (c & 128) ? 0 : 1;	/* 1 = down */
+
+    if (flag || key_down[key] != flag)
+      key_down[key] = flag;
+    else
+      return (scan_keyboard ());
+
+    if (key == LEFT_ALT)
+	alt_pressed = flag;
+
+    if (alt_pressed && flag && key >= FUNC_KEY(1) && key <= FUNC_KEY(10)) {
+	struct vt_stat vts;
+	int newvt;
+
+	ioctl(tty_fd, VT_GETSTATE, &vts);
+	newvt = c - FUNC_KEY(1) + 1;
+	if (vts.v_active != newvt && vtswitch_allowed) {
+	    ioctl(tty_fd, VT_ACTIVATE, newvt);
+	    restart_con = 0;
+	    while (restart_con == 0)
+		usleep(50000);
+	}
+	return -1;		/* Got VT switch */
+    }
+    if (flag && key == 46 && key_down[LEFT_CTRL])
+	raise(SIGINT);
+    return key;			/* No VT switch */
+}
+
+
+/* converts scancode to key binding */
+static int keymap_trans(int sc)
+{
+    if (sc < 0 || sc > 127)
+	return (-1);
+    return (keymap[key_down[LEFT_SHIFT] || key_down[RIGHT_SHIFT]][sc]);
+}
+
+
+
+
+
+static int iswaiting;
+static int __resized;
+#ifdef GPM_MOUSEDRIVER
+extern int __curses_usegpm;
+#endif
+static jmp_buf buf;
+#ifdef SIGWINCH
+static void handler(int i)
+{
+    __resized = 2;
+    signal(SIGWINCH, handler);
+    if (iswaiting)
+	longjmp(buf, 1);
+}
+#endif
+static char sig2catch[] =
+{SIGHUP, SIGINT, SIGQUIT, SIGILL,
+ SIGTRAP, SIGIOT, SIGBUS, SIGFPE,
+ SIGSEGV, SIGPIPE, SIGALRM, SIGTERM,
+ SIGXCPU, SIGXFSZ, SIGVTALRM,
+	   /* SIGPROF , */ SIGPWR};
+static struct sigaction old_signal_handler[sizeof(sig2catch)];
+static void exithandler(int v)
+{
+    int i;
+    printf("AAlib: signal %i received\n", v);
+    rawmode_exit();
+    for (i = 0; i < (int) sizeof(sig2catch); i++)
+	if (sig2catch[i] == v) {
+	    sigaction(v, old_signal_handler + i, NULL);
+	    raise(v);
+	    break;
+	}
+    if (i >= (int) sizeof(sig2catch)) {
+	printf("AA-lib: Aieeee! Illegal call to signal_handler, raising segfault.\n");
+	raise(SIGSEGV);
+    }
+}
+
+static int linux_init(struct aa_context *context, int mode)
+{
+    int i;
+    struct sigaction siga;
+    if (!(mode & AA_SENDRELEASE))
+	return 0;
+    if (!rawmode_init())
+	return 0;
+#ifdef SIGWINCH
+    signal(SIGWINCH, handler);
+#endif
+#ifdef GPM_MOUSEDRIVER
+    aa_recommendlowmouse("gpm");
+#endif
+    allow_switch(1);
+    atexit(rawmode_exit);
+    for (i = 0; i < (int) sizeof(sig2catch); i++) {
+	siga.sa_handler = exithandler;
+	siga.sa_flags = 0;
+	/*zero_sa_mask(&(siga.sa_mask)); */
+	memset(&siga.sa_mask, 0, sizeof(sigset_t));
+	sigaction((int) sig2catch[i], &siga, old_signal_handler + i);
+    }
+
+    return 1;
+}
+static void linux_uninit(aa_context * c)
+{
+#ifdef SIGWINCH
+    signal(SIGWINCH, SIG_IGN);	/*this line may cause problem... */
+#endif
+    rawmode_exit();
+}
+#ifdef GPM_MOUSEDRIVER
+extern int __gpm_user_handler(Gpm_Event * event, void *data);
+#endif
+static int linux_getchar(aa_context * c1, int wait)
+{
+#ifdef GPM_MOUSEDRIVER
+    static Gpm_Event e;
+#endif
+    int c;
+    int key;
+    struct timeval tv;
+    do {
+	fd_set readfds;
+	tv.tv_sec = 0;
+	tv.tv_usec = 0;
+	FD_ZERO(&readfds);
+	FD_SET(tty_fd, &readfds);
+#ifdef GPM_MOUSEDRIVER
+	if (gpm_visiblepointer)
+	    GPM_DRAWPOINTER(&e);
+	if (__curses_usegpm) {
+	    FD_SET(gpm_fd, &readfds);
+	}
+#endif
+#ifdef GPM_MOUSEDRIVER
+	select((__curses_usegpm ? gpm_fd : 0) + 1, &readfds, NULL, NULL, wait ? NULL : &tv);
+	if (__curses_usegpm && FD_ISSET(gpm_fd, &readfds)) {
+	    if (Gpm_GetEvent(&e) == 1) {
+		__gpm_user_handler(&e, NULL);
+		return AA_MOUSE;
+	    }
+	}
+#else
+	select(tty_fd, &readfds, NULL, NULL, wait ? NULL : &tv);
+#endif
+	c = scan_keyboard();
+	if (c != -1) {
+	    switch (c) {
+	    case ESCAPE_KEY:
+		key = AA_ESC;
+		break;
+	    case ENTER_KEY:
+		key = 13;
+		break;
+	    case BACKSPACE:
+		key = AA_BACKSPACE;
+		break;
+	    case CURSOR_LEFT:
+		key = AA_LEFT;
+		break;
+	    case CURSOR_RIGHT:
+		key = AA_RIGHT;
+		break;
+	    case CURSOR_UP:
+		key = AA_UP;
+		break;
+	    case CURSOR_DOWN:
+		key = AA_DOWN;
+		break;
+	    case CURSORBLOCK_LEFT:
+		key = AA_LEFT;
+		break;
+	    case CURSORBLOCK_RIGHT:
+		key = AA_RIGHT;
+		break;
+	    case CURSORBLOCK_UP:
+		key = AA_UP;
+		break;
+	    case CURSORBLOCK_DOWN:
+		key = AA_DOWN;
+		break;
+	    default:
+		key = keymap_trans(c) & 255;
+	    }
+	    if (!key_down[c])
+		key |= AA_RELEASE;
+	    return key;
+	} else
+	    key = AA_NONE;
+    }
+    while (wait);
+    return AA_NONE;
+}
+
+
+
+__AA_CONST struct aa_kbddriver kbd_linux_d =
+{
+    "linux", "Linux console raw keyboard driver 1.0",
+    AA_SENDRELEASE,
+    linux_init,
+    linux_uninit,
+    linux_getchar,
+};
+#endif
diff -Naur a/src/aamoureg.c b/src/aamoureg.c
--- a/src/aamoureg.c	2001-04-26 16:37:31.000000000 +0200
+++ b/src/aamoureg.c	2024-12-10 21:59:02.599926387 +0100
@@ -1,4 +1,5 @@
 #include <malloc.h>
+#include <string.h>
 #include "config.h"
 #include "aalib.h"
 #include "aaint.h"
diff -Naur a/src/aaregist.c b/src/aaregist.c
--- a/src/aaregist.c	2001-04-26 16:37:31.000000000 +0200
+++ b/src/aaregist.c	2024-12-10 21:59:02.599926387 +0100
@@ -1,4 +1,5 @@
 #include <malloc.h>
+#include <string.h>
 #include "config.h"
 #include "aalib.h"
 #include "aaint.h"
diff -Naur a/src/aarender.c b/src/aarender.c
--- a/src/aarender.c	2001-04-26 16:37:31.000000000 +0200
+++ b/src/aarender.c	2024-12-10 21:59:43.823334572 +0100
@@ -63,10 +63,10 @@
 	errors[0] = calloc(1, (x2 + 5) * sizeof(int));
 	if (errors[0] == NULL)
 	    dither = AA_ERRORDISTRIB;
-	errors[0] += 3;
 	errors[1] = calloc(1, (x2 + 5) * sizeof(int));
 	if (errors[1] == NULL)
 	    free(errors[0]), dither = AA_ERRORDISTRIB;
+	errors[0] += 3;
 	errors[1] += 3;
 	cur = 0;
     }
@@ -94,8 +94,8 @@
 	gamma = randomval / 2;
     mval = (c->parameters[c->filltable[255]].p[4]);
     for (y = y1; y < y2; y++) {
-	pos = 2 * y * wi;
-	pos1 = y * aa_scrwidth(c);
+	pos = 2 * (y * wi + x1);
+	pos1 = y * aa_scrwidth(c) + x1;
 	esum = 0;
 	for (x = x1; x < x2; x++) {
 	    i1 = table[((((int) c->imagebuffer[pos])))];
diff -Naur a/src/aasavefont.c b/src/aasavefont.c
--- a/src/aasavefont.c	2001-04-26 16:37:31.000000000 +0200
+++ b/src/aasavefont.c	2024-12-10 21:59:02.599926387 +0100
@@ -1,3 +1,4 @@
+#include <stdlib.h>
 #include "aalib.h"
 int main(int argc, char **argv)
 {
diff -Naur a/src/aastdin.c b/src/aastdin.c
--- a/src/aastdin.c	2001-04-26 16:37:31.000000000 +0200
+++ b/src/aastdin.c	2024-12-10 21:59:49.320013675 +0100
@@ -88,7 +88,7 @@
     if (c > 0 && c < 127 && c != 127)
 	return (c);
     switch (c) {
-#ifdef KEY_MOUDE
+#ifdef KEY_MOUSE
     case KEY_MOUSE:
 	return AA_MOUSE
 #endif
diff -Naur a/src/aatest.c b/src/aatest.c
--- a/src/aatest.c	2001-04-26 16:37:31.000000000 +0200
+++ b/src/aatest.c	2024-12-10 21:59:02.599926387 +0100
@@ -1,3 +1,5 @@
+#include <stdlib.h>
+#include <string.h>
 #include "aalib.h"
 int main(int argc, char **argv)
 {
diff -Naur a/src/aaxkbd.c b/src/aaxkbd.c
--- a/src/aaxkbd.c	2001-04-26 16:37:31.000000000 +0200
+++ b/src/aaxkbd.c	2024-12-10 21:59:02.599926387 +0100
@@ -7,6 +7,7 @@
 #include <X11/Xlib.h>
 #include <X11/keysymdef.h>
 #include <X11/keysym.h>
+#include <X11/Xutil.h>
 #include "aalib.h"
 #include "aaint.h"
 #include "aaxint.h"