projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
pc+-file-reader: Fix handling of short files.
[pspp]
/
src
/
data
/
pc+-file-reader.c
diff --git
a/src/data/pc+-file-reader.c
b/src/data/pc+-file-reader.c
index 0aa4587d38ca3ebe81fe2b3edd10f1edd2272be1..08e6470697361b871acecdd6d9174da670268e62 100644
(file)
--- a/
src/data/pc+-file-reader.c
+++ b/
src/data/pc+-file-reader.c
@@
-1,5
+1,5
@@
/* PSPP - a program for statistical analysis.
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-2000, 2006-2007, 2009-201
4
Free Software Foundation, Inc.
+ Copyright (C) 1997-2000, 2006-2007, 2009-201
5
Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@
-505,18
+505,20
@@
pcp_file_casereader_destroy (struct casereader *reader UNUSED, void *r_)
pcp_close (&r->any_reader);
}
pcp_close (&r->any_reader);
}
-/*
Returns true if FILE is an SPSS/PC+ system file,
-
false otherwise
. */
+/*
Detects whether FILE is an SPSS/PC+ system file. Returns 1 if so, 0 if
+
not, and a negative errno value if there is an error reading FILE
. */
static int
pcp_detect (FILE *file)
{
static const char signature[4] = "SPSS";
char buf[sizeof signature];
static int
pcp_detect (FILE *file)
{
static const char signature[4] = "SPSS";
char buf[sizeof signature];
- if (fseek (file, 0x104, SEEK_SET)
- || (fread (buf, sizeof buf, 1, file) != 1 && !feof (file)))
+ if (fseek (file, 0x104, SEEK_SET))
return -errno;
return -errno;
+ if (fread (buf, sizeof buf, 1, file) != 1)
+ return ferror (file) ? -errno : 0;
+
return !memcmp (buf, signature, sizeof buf);
}
\f
return !memcmp (buf, signature, sizeof buf);
}
\f