PATCH 1/2: Make gotoxy & siblings use unsigned variables

From: Nigel Cunningham
Date: Fri Jan 09 2004 - 13:46:12 EST


This patch makes console X and Y coordinates unsigned, rather than
signed. Issues with wide (> 128 char?) consoles, seen when developing
Software Suspend's 'nice display' are thus fixed. A brief examination of
related code showed that this use of signed variables was the exception
rather than the rule.

Regards,

Nigel

diff -ruN linux-2.6.1-rc3/drivers/char/vt.c console-patch-1/drivers/char/vt.c
--- linux-2.6.1-rc3/drivers/char/vt.c 2004-01-09 14:24:45.000000000 +1300
+++ console-patch-1/drivers/char/vt.c 2004-01-10 07:17:08.000000000 +1300
@@ -149,7 +149,7 @@
static void vc_init(unsigned int console, unsigned int rows,
unsigned int cols, int do_clear);
static void blank_screen(unsigned long dummy);
-static void gotoxy(int currcons, int new_x, int new_y);
+static void gotoxy(int currcons, unsigned int new_x, unsigned int new_y);
static void save_cur(int currcons);
static void reset_terminal(int currcons, int do_clear);
static void con_flush_chars(struct tty_struct *tty);
@@ -859,9 +859,9 @@
* might also be negative. If the given position is out of
* bounds, the cursor is placed at the nearest margin.
*/
-static void gotoxy(int currcons, int new_x, int new_y)
+static void gotoxy(int currcons, unsigned int new_x, unsigned int new_y)
{
- int min_y, max_y;
+ unsigned int min_y, max_y;

if (new_x < 0)
x = 0;
@@ -888,7 +888,7 @@
}

/* for absolute user moves, when decom is set */
-static void gotoxay(int currcons, int new_x, int new_y)
+static void gotoxay(int currcons, unsigned int new_x, unsigned int new_y)
{
gotoxy(currcons, new_x, decom ? (top+new_y) : new_y);
}
@@ -2996,13 +2996,13 @@
return screenpos(currcons, 2 * w_offset, viewed);
}

-void getconsxy(int currcons, char *p)
+void getconsxy(int currcons, unsigned char *p)
{
p[0] = x;
p[1] = y;
}

-void putconsxy(int currcons, char *p)
+void putconsxy(int currcons, unsigned char *p)
{
gotoxy(currcons, p[0], p[1]);
set_cursor(currcons);
diff -ruN linux-2.6.1-rc3/include/linux/selection.h console-patch-1/include/linux/selection.h
--- linux-2.6.1-rc3/include/linux/selection.h 2004-01-09 14:22:25.000000000 +1300
+++ console-patch-1/include/linux/selection.h 2004-01-10 07:17:08.000000000 +1300
@@ -36,8 +36,8 @@
extern void complement_pos(int currcons, int offset);
extern void invert_screen(int currcons, int offset, int count, int shift);

-extern void getconsxy(int currcons, char *p);
-extern void putconsxy(int currcons, char *p);
+extern void getconsxy(int currcons, unsigned char *p);
+extern void putconsxy(int currcons, unsigned char *p);

extern u16 vcs_scr_readw(int currcons, const u16 *org);
extern void vcs_scr_writew(int currcons, u16 val, u16 *org);

--
My work on Software Suspend is graciously brought to you by
LinuxFund.org.

Attachment: signature.asc
Description: This is a digitally signed message part