commit b4ea08671081416e15e8acd9021f43b5cfff63ee
parent 94b1ab14c4a3130b517edec157e2ce6550b6396c
Author: Matsuda Kenji <info@mtkn.jp>
Date: Tue, 2 Apr 2024 17:30:15 +0900
fix bug
Diffstat:
3 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/sys/src/kernel/console.c b/sys/src/kernel/console.c
@@ -76,8 +76,8 @@ cons_printf(Console *con, char *fmt, ...)
char _buf[1024], *buf = _buf;
char *s;
- long long d, e;
- unsigned long long f, g, h;
+ long long d0, d1;
+ unsigned long long u0, u1, u2;
va_start(ap, fmt);
for (;*fmt;) {
@@ -97,40 +97,40 @@ cons_printf(Console *con, char *fmt, ...)
}
break;
case 'd':
- d = va_arg(ap, int);
- if (d == 0) {
+ d0 = va_arg(ap, int);
+ if (d0 == 0) {
*buf++ = '0';
break;
- } else if (d < 0) {
+ } else if (d0 < 0) {
*buf++ = '-';
- d = -d;
+ d0 = -d0;
}
- for (e = 1; e <= d; e *= 10) {
- if (e > e * 10) { // integer too big;
+ for (d1 = 1; d1 <= d0; d1 *= 10) {
+ if (d1 > d1 * 10) { // integer too big;
return -1;
}
}
- for (e /= 10; e >= 1; e /= 10) {
- *buf++ = '0' + ((d / e) % 10);
+ for (d1 /= 10; d1 >= 1; d1 /= 10) {
+ *buf++ = '0' + ((d0 / d1) % 10);
}
break;
case 'x':
- f = va_arg(ap, unsigned int);
- if (f == 0) {
+ u0 = va_arg(ap, unsigned int);
+ if (u0 == 0) {
*buf++ = '0';
break;
}
- for (g = 1; g <= f; g *= 0x10) {
- if (g > g * 0x10) { // integer too big.
+ for (u1 = 1; u1 <= u0; u1 *= 0x10) {
+ if (u1 > u1 * 0x10) { // integer too big.
return -1;
}
}
- for (g /= 0x10; g >= 1; g /= 0x10) {
- h = ((f / g) % 0x10);
- if (h < 0xa) {
- *buf++ = '0' + h;
+ for (u1 /= 0x10; u1 >= 1; u1 /= 0x10) {
+ u2 = ((u0 / u1) % 0x10);
+ if (u2 < 0xa) {
+ *buf++ = '0' + u2;
} else {
- *buf++ = 'a' + h - 0xa;
+ *buf++ = 'a' + u2 - 0xa;
}
}
break;
diff --git a/sys/src/kernel/draw.c b/sys/src/kernel/draw.c
@@ -33,7 +33,7 @@ line(Window *dst, Point p0, Point p1, RGBA32 col)
int dx = p1.x - p0.x;
int dy = p1.y - p0.y;
float err = 0;
- float derr = (float)dx / (float)dy;
+ float derr = (float)dy / (float)dx;
if (derr < 0) {
derr = -derr;
}
diff --git a/sys/src/kernel/main.c b/sys/src/kernel/main.c
@@ -12,7 +12,7 @@ kernel_main(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop)
gop->Mode->Info->VerticalResolution,
gop->Mode->Info->PixelsPerScanLine
);
- cons_print(&console, "Hello, World!\nNew Line.\tTab\tTab\rnEW\vVertical\n");
- cons_printf(&console, "digit: %d, str: %s, hex: 0x%x\n", 124, "abc", 0xdeadbeef);
+ line(&root_window, (Point){1000, 100}, (Point){1050, 140}, 0x000000);
+
for(;;);
}