mirror of
https://github.com/Perl/perl5.git
synced 2026-01-26 08:38:23 +00:00
Fix PerlLIO_chsize() for platforms that don't have chsize()
This is the patch from the end of the thread that started here: http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2004-09/msg00055.html p4raw-id: //depot/perl@24092
This commit is contained in:
parent
d94a595083
commit
58e24efff3
15
doio.c
15
doio.c
@ -1242,14 +1242,15 @@ Perl_do_binmode(pTHX_ PerlIO *fp, int iotype, int mode)
|
||||
return PerlIO_binmode(aTHX_ fp, iotype, mode, name);
|
||||
}
|
||||
|
||||
#if !defined(HAS_TRUNCATE) && !defined(HAS_CHSIZE) && defined(F_FREESP)
|
||||
/* code courtesy of William Kucharski */
|
||||
#define HAS_CHSIZE
|
||||
|
||||
#if !defined(HAS_TRUNCATE) && !defined(HAS_CHSIZE)
|
||||
I32 my_chsize(fd, length)
|
||||
I32 fd; /* file descriptor */
|
||||
Off_t length; /* length to set file to */
|
||||
{
|
||||
#ifdef F_FREESP
|
||||
/* code courtesy of William Kucharski */
|
||||
#define HAS_CHSIZE
|
||||
|
||||
struct flock fl;
|
||||
Stat_t filebuf;
|
||||
|
||||
@ -1290,8 +1291,12 @@ Off_t length; /* length to set file to */
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
dTHX;
|
||||
DIE(aTHX_ "truncate not implemented");
|
||||
#endif /* F_FREESP */
|
||||
}
|
||||
#endif /* !HAS_TRUNCATE && !HAS_CHSIZE */
|
||||
|
||||
bool
|
||||
Perl_do_print(pTHX_ register SV *sv, PerlIO *fp)
|
||||
|
||||
@ -726,7 +726,13 @@ struct IPerlLIOInfo
|
||||
#define PerlLIO_access(file, mode) access((file), (mode))
|
||||
#define PerlLIO_chmod(file, mode) chmod((file), (mode))
|
||||
#define PerlLIO_chown(file, owner, grp) chown((file), (owner), (grp))
|
||||
#define PerlLIO_chsize(fd, size) chsize((fd), (size))
|
||||
#if defined(HAS_TRUNCATE)
|
||||
# define PerlLIO_chsize(fd, size) ftruncate((fd), (size))
|
||||
#elif defined(HAS_CHSIZE)
|
||||
# define PerlLIO_chsize(fd, size) chsize((fd), (size))
|
||||
#else
|
||||
# define PerlLIO_chsize(fd, size) my_chsize((fd), (size))
|
||||
#endif
|
||||
#define PerlLIO_close(fd) close((fd))
|
||||
#define PerlLIO_dup(fd) dup((fd))
|
||||
#define PerlLIO_dup2(fd1, fd2) dup2((fd1), (fd2))
|
||||
|
||||
4
pp_sys.c
4
pp_sys.c
@ -2110,7 +2110,6 @@ PP(pp_truncate)
|
||||
* might not be signed: if it is not, clever compilers will moan. */
|
||||
/* XXX Configure probe for the signedness of the length type of *truncate() needed? XXX */
|
||||
SETERRNO(0,0);
|
||||
#if defined(HAS_TRUNCATE) || defined(HAS_CHSIZE) || defined(F_FREESP)
|
||||
{
|
||||
int result = 1;
|
||||
GV *tmpgv;
|
||||
@ -2185,9 +2184,6 @@ PP(pp_truncate)
|
||||
SETERRNO(EBADF,RMS_IFI);
|
||||
RETPUSHUNDEF;
|
||||
}
|
||||
#else
|
||||
DIE(aTHX_ "truncate not implemented");
|
||||
#endif
|
||||
}
|
||||
|
||||
PP(pp_fcntl)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user