commit 79a6971409ae7be1de3cd6592a56d0342292e92e
parent a4cedc15b54710816bcced567fd6841022256555
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Mon, 24 Feb 2025 11:22:21 +0100
Add detection of trailing chars in ascii files
Diffstat:
1 file changed, 22 insertions(+), 6 deletions(-)
diff --git a/src/sstl.c b/src/sstl.c
@@ -28,6 +28,7 @@
#include <string.h>
#include <stdio.h>
+#include <ctype.h>
#ifdef COMPILER_CL
#pragma warning(push)
@@ -534,6 +535,19 @@ load_ascii_stream
}
sa_release(name);
}
+ if(sstl->verbose) {
+ int tmp, non_space = 0;
+ size_t i = 0;
+ while (EOF != (tmp = fgetc(stream))) {
+ i++;
+ if(!isspace(tmp)) non_space = 1;
+ }
+ if(non_space) {
+ print_log(sstl, LOG_WARNING,
+ "%s: %u unexpected trailing characters.\n",
+ stream_name, i);
+ }
+ }
/* Register the solid */
solid.read_type = SSTL_ASCII;
@@ -608,12 +622,14 @@ load_binary_stream
sa_push(solid.indices, index);
}
}
- i = 0;
- while (1 == fread(header, 1, 1, stream)) i++;
- if(i) {
- print_log(sstl, LOG_WARNING,
- "%s: %u unexpected trailing bytes.\n",
- stream_name, i);
+ if(sstl->verbose) {
+ i = 0;
+ while (1 == fread(header, 1, 1, stream)) i++;
+ if(i) {
+ print_log(sstl, LOG_WARNING,
+ "%s: %u unexpected trailing bytes.\n",
+ stream_name, i);
+ }
}
/* Register the solid */