fix checks in *_num() functions: only when/where necessary

This commit is contained in:
marschap
2006-04-11 20:57:15 +00:00
parent 66e38659cb
commit 65a473f2b7
12 changed files with 34 additions and 27 deletions
+3
View File
@@ -884,6 +884,9 @@ CFontz633_num (Driver *drvthis, int x, int num)
PrivateData *p = drvthis->private_data;
unsigned char out[5];
if ((x <= 0) || (x > p->width))
return;
snprintf(out, sizeof(out), "%c%c%c", 28, x, num);
write(p->fd, out, 3);
*/
+1 -1
View File
@@ -1241,7 +1241,7 @@ char bignum_map[11][4][3] = {
if ((num < 0) || (num > 10))
return;
if ((p->width >= 20) && (p->height >= 4)) {
if (p->height >= 4) {
int y = (p->height - 2) / 2; /* center vertically */
int x2, y2;
+1 -1
View File
@@ -1002,7 +1002,7 @@ char bignum_map[11][4][3] = {
IOWarrior_init_num(drvthis);
if ((p->width >= 20) && (p->height >= 4)) {
if (p->height >= 4) {
int y = (p->height - 2) / 2; /* center vertically */
int x2, y2;
+3
View File
@@ -1127,6 +1127,9 @@ MtxOrb_num (Driver *drvthis, int pos, int val)
int x, y;
int c;
if ((val < 0) || (val > 10))
return;
debug(RPT_DEBUG, "MtxOrb: write big number %d at %d", val, pos);
/* Currently we are bignum but if bigalpha is there remove this line */
+1 -2
View File
@@ -382,9 +382,8 @@ glcdlib_set_char (Driver *drvthis, int n, char *dat)
MODULE_EXPORT void
glcdlib_num (Driver *drvthis, int x, int num)
{
x--;
glcdlibPD * pPD = drvthis->private_data;
glcddriverDrawBigNum(pPD->glcdDriver, x, num);
glcddriverDrawBigNum(pPD->glcdDriver, x - 1, num);
}
/////////////////////////////////////////////////////////////////
+4 -1
View File
@@ -544,8 +544,11 @@ glk_num(Driver *drvthis, int x, int num)
debug(RPT_DEBUG, "glk_num(%d, %d)", x, num);
if ((num < 0) || (num > 10))
return;
if ((x > 0) && (x <= p->width))
p->framebuf[x-1] = num + '0';
p->framebuf[x-1] = (num >= 10) ? ':' : (num + '0');
}
//////////////////////////////////////////////////////////////////////
+1 -1
View File
@@ -938,7 +938,7 @@ HD44780_num (Driver *drvthis, int x, int num)
if ((num < 0) || (num > 10))
return;
if ((p->width >= 20) && (p->height >= 4)) {
if (p->height >= 4) {
int y = (p->height - 2) / 2;
int x2, y2;
+1 -1
View File
@@ -706,7 +706,7 @@ lcterm_num (Driver *drvthis, int x, int num)
if ((num < 0) || (num > 10))
return;
if ((p->width >= 20) && (p->height >= 4)) {
if (p->height >= 4) {
int y = (p->height - 2) / 2;
int x2, y2;
+5 -6
View File
@@ -342,10 +342,7 @@ sed1520_num (Driver *drvthis, int x, int num)
x--;
// return on illegal char or illegal position
if ((x < 0) || (x >= WIDTH) || (num < 0) || (num > 10))
return;
// when char isn't colon, restrict the position even further
if ((num != 10) && (x >= WIDTH-2))
if ((x >= WIDTH) || (num < 0) || (num > 10))
return;
if (num == 10) { // colon
@@ -357,7 +354,8 @@ sed1520_num (Driver *drvthis, int x, int num)
if (*(fontbigdp[(z * 8) + i] + c) == '.')
s |= 0x80;
}
p->framebuf[((z + 1) * PIXELWIDTH) + (x * CELLWIDTH) + c] = s;
if ((x * CELLWIDTH + c >= 0) && (x * CELLWIDTH + c < PIXELWIDTH))
p->framebuf[((z + 1) * PIXELWIDTH) + (x * CELLWIDTH) + c] = s;
}
}
}
@@ -370,7 +368,8 @@ sed1520_num (Driver *drvthis, int x, int num)
if (*(fontbignum[num][z * 8 + i] + c) == '.')
s |= 0x80;
}
p->framebuf[((z + 1) * PIXELWIDTH) + (x * CELLWIDTH) + c] = s;
if ((x * CELLWIDTH + c >= 0) && (x * CELLWIDTH + c < PIXELWIDTH))
p->framebuf[((z + 1) * PIXELWIDTH) + (x * CELLWIDTH) + c] = s;
}
}
}
+3 -9
View File
@@ -273,10 +273,8 @@ stv5730_drawchar2fb (Driver *drvthis, int x, int y, unsigned char z)
{
PrivateData *p = drvthis->private_data;
if (x < 0 || x >= STV5730_WID || y < 0 || y >= STV5730_HGT)
return;
p->framebuf[(y * STV5730_WID) + x] = stv5730_to_ascii[(unsigned int) z];
if ((x >= 0) && (x < STV5730_WID) && (y >= 0) && (y < STV5730_HGT))
p->framebuf[(y * STV5730_WID) + x] = stv5730_to_ascii[(unsigned int) z];
}
/////////////////////////////////////////////////////////////////
@@ -553,11 +551,7 @@ stv5730_num (Driver *drvthis, int x, int num)
x--;
if (x < 0 || x > 19 || num < 0 || num > 10)
return;
if (num != 10 && (x < 0 || x > 17))
return;
if (num == 10 && (x < 0 || x > 19))
if ((x >= STV5730_WID) || (num < 0) || (num > 10))
return;
for (j = 1; j < 10; j++) {
+5 -2
View File
@@ -520,12 +520,15 @@ svgalib_drv_chr (Driver *drvthis, int x, int y, char c)
MODULE_EXPORT void
svgalib_drv_num (Driver *drvthis, int x, int num)
{
char c;
int y, dx;
char c;
debug(RPT_DEBUG, "%s(%p, %d, %d)", __FUNCTION__, drvthis, x, num);
c = '0' + num;
if ((num < 0) || (num > 10))
return;
c = (num >= 10) ? ':' : ('0' + num);
for (y = 1; y < 5; y++)
for (dx = 0; dx < 3; dx++)
+6 -3
View File
@@ -317,16 +317,19 @@ xosdlib_drv_chr (Driver *drvthis, int x, int y, char c)
MODULE_EXPORT void
xosdlib_drv_old_num (Driver *drvthis, int x, int num)
{
char c;
int y, dx;
char c;
debug(RPT_DEBUG, "%s(%p, %d, %d)", __FUNCTION__, drvthis, x, num);
c = '0' + num;
if ((num < 0) || (num > 10))
return;
c = (num >= 10) ? ':' : ('0' + num);
for (y = 1; y < 5; y++)
for (dx = 0; dx < 3; dx++)
xosdlib_drv_chr (drvthis, x + dx, y, c);
xosdlib_drv_chr(drvthis, x + dx, y, c);
}