summaryrefslogtreecommitdiff
path: root/libraries/daguerre/source
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/daguerre/source')
-rw-r--r--libraries/daguerre/source/daguerre.cpp15
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) {