mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-13 19:52:20 +00:00
libcmd/cmp: report read errors (Solaris patch 045-CR7025778)
This change is pulled from here: https://github.com/oracle/solaris-userland/blob/master/components/ksh93/patches/045-CR7025778.patch src/lib/libcmd/cmp.c: - If a read error occurs, issue an error message.
This commit is contained in:
parent
e20db01247
commit
4c75920baa
1 changed files with 6 additions and 0 deletions
|
@ -164,12 +164,16 @@ cmp(const char* file1, Sfio_t* f1, const char* file2, Sfio_t* f2, int flags, Sfo
|
|||
return ret;
|
||||
if (!(p1 = (unsigned char*)sfreserve(f1, SF_UNBOUND, 0)) || (c1 = sfvalue(f1)) <= 0)
|
||||
{
|
||||
if (sferror(f1))
|
||||
error(ERROR_exit(2), "read error on %s", file1);
|
||||
if ((e2 - p2) > 0 || sfreserve(f2, SF_UNBOUND, 0) && sfvalue(f2) > 0)
|
||||
{
|
||||
ret = 1;
|
||||
if (!(flags & CMP_SILENT))
|
||||
error(ERROR_exit(1), "EOF on %s", file1);
|
||||
}
|
||||
if (sferror(f2))
|
||||
error(ERROR_exit(2), "read error on %s", file2);
|
||||
return ret;
|
||||
}
|
||||
if (count > 0 && c1 > count)
|
||||
|
@ -181,6 +185,8 @@ cmp(const char* file1, Sfio_t* f1, const char* file2, Sfio_t* f2, int flags, Sfo
|
|||
{
|
||||
if (!(p2 = (unsigned char*)sfreserve(f2, SF_UNBOUND, 0)) || (c2 = sfvalue(f2)) <= 0)
|
||||
{
|
||||
if (sferror(f2))
|
||||
error(ERROR_exit(2), "read error on %s", file2);
|
||||
if (!(flags & CMP_SILENT))
|
||||
error(ERROR_exit(1), "EOF on %s", file2);
|
||||
return 1;
|
||||
|
|
Loading…
Reference in a new issue