commit 76769f5

uint  ·  2026-10-03 15:23:51 +0000 UTC
parent 67b5ea9
Font: Replace strtoull with strtou64()
1 files changed,  +28, -1
+28, -1
 1@@ -8,6 +8,10 @@
 2 static void glyph_to_buf(i32 sgx, i32 egx, i32 sgy, i32 egy,
 3                          i32 gox, i32 goy, MausGlyph* g, u32 col_up,
 4                          u32* buf, u32 stride);
 5+static i8 parse_glyphs(FILE* f, MausFont* font, char* line, size_t line_size,
 6+                           i32* encoding, i32* advance, i32* bw, i32* bh,
 7+                           i32* xoff, i32* yoff, i8* seen);
 8+static u64 strtou64(const char* str);
 9 
10 /* "blit" a glpyh to some buffer */
11 static void glyph_to_buf(i32 sgx, i32 egx, i32 sgy, i32 egy,
12@@ -97,7 +101,7 @@ static i8 parse_glyphs(FILE* f, MausFont* font, char* line, size_t line_size,
13 					return 0;
14 				}
15 
16-				bits = strtoull(line, NULL, 16); /* hex to bits */
17+				bits = strtou64(line);
18 				for (x = 0; x < *bw; x++) {
19 					int bit = rowbits - 1 - x;
20 
21@@ -121,6 +125,29 @@ static i8 parse_glyphs(FILE* f, MausFont* font, char* line, size_t line_size,
22 	return 1;
23 }
24 
25+static u64 strtou64(const char* str)
26+{
27+	u64 n = 0;
28+	u8 c;
29+
30+	while (*str) {
31+		c = (u8)*str++;
32+
33+		if (c >= '0' && c <= '9')
34+			c = (u8)(c - '0');
35+		else if (c >= 'A' && c <= 'F')
36+			c = (u8)(c - 'A' + 10);
37+		else if (c >= 'a' && c <= 'f')
38+			c = (u8)(c - 'a' + 10);
39+		else
40+			break;
41+
42+		n = (n << 4) | c;
43+	}
44+
45+	return n;
46+}
47+
48 void maus_draw_text(Maus* mw, MausFont* font, i32 x, i32 y,
49                     const char* text, MausColor col)
50 {