ref: f4fb4f43d7e643d83e818924cfe0a1d28e908f7a
parent: 689cb60650e64a064899bcbd8ab47a6d4485ef32
author: Sabdenov Chingiz <sabdenovchingiz@yandex.ru>
date: Sat Nov 26 07:46:16 EST 2022
ps: ignore trailing spaces when checking EPS file header
--- a/ps.c
+++ b/ps.c
@@ -266,10 +266,15 @@
int nbb;
if (!(filp = fopen(eps, "r")))
return;
- if (!fgets(buf, sizeof(buf), filp) ||
- (strcmp(buf, "%!PS-Adobe-2.0 EPSF-1.2\n") &&
- strcmp(buf, "%!PS-Adobe-2.0 EPSF-2.0\n") &&
- strcmp(buf, "%!PS-Adobe-3.0 EPSF-3.0\n"))) {
+ if (!fgets(buf, sizeof(buf), filp)) {
+ fprintf(stderr, "warning: file %s is empty\n", eps);
+ fclose(filp);
+ return;
+ }
+ if (strncmp(buf, "%!PS-Adobe-2.0 EPSF-1.2", 23) &&
+ strncmp(buf, "%!PS-Adobe-2.0 EPSF-2.0", 23) &&
+ strncmp(buf, "%!PS-Adobe-3.0 EPSF-3.0", 23)) {
+ fprintf(stderr, "warning: unsupported EPSF version in %s\n", eps);
fclose(filp);
return;
}