diff options
author | Benji Dial <benji@benjidial.net> | 2024-05-19 04:34:40 -0400 |
---|---|---|
committer | Benji Dial <benji@benjidial.net> | 2024-05-19 04:34:40 -0400 |
commit | e60fa7740cd7d245d1b22a25fea9df0768d32668 (patch) | |
tree | 728fa422d3a2abc66a3e2d89e4ef03b72074bb3e /libraries/daguerre/source/daguerre.cpp | |
parent | b1a912a8a6ff472a49b2e0a09cfd433adfc2cb24 (diff) | |
download | hilbert-os-e60fa7740cd7d245d1b22a25fea9df0768d32668.tar.gz |
mouse support (working in qemu, semi-working in virtualbox)
Diffstat (limited to 'libraries/daguerre/source/daguerre.cpp')
-rw-r--r-- | libraries/daguerre/source/daguerre.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/libraries/daguerre/source/daguerre.cpp b/libraries/daguerre/source/daguerre.cpp index fb3ddc7..7c13a88 100644 --- a/libraries/daguerre/source/daguerre.cpp +++ b/libraries/daguerre/source/daguerre.cpp @@ -8,15 +8,22 @@ namespace daguerre { return image<hilbert_color>(ptr, width, height, pitch, false); } + //TODO: make this more robust unsigned read_text_int(std::FILE *input) { unsigned n = 0; char ch; - while (true) { + std::fread(&ch, 1, 1, input); + if (ch == '#') { + do + std::fread(&ch, 1, 1, input); + while (ch != '\n'); std::fread(&ch, 1, 1, input); - if (ch < '0' || ch > '9') - return n; - n = n * 10 + ch - '0'; } + do { + n = n * 10 + ch - '0'; + std::fread(&ch, 1, 1, input); + } while (ch >= '0' && ch <= '9'); + return n; } bool try_load_ppm(std::FILE *input, image<rgb24> &into) { |