[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]

Re: [ID 20000125.002] Problem in documentation of Fcntl constants



Avoiding the encapsulation vs. expose-the-ductwork debate, the point still
remains that that the :flock constants are prototyped as sub LOCK_SH {...}
not sub LOCK_SH() { ... }:

    *$AUTOLOAD = sub { $val };

causing a working C idiom LOCK_SH + LOCK_NB to fail in Perl.

Here's one possible fix against 5.5's Fcntl.pm, if a fix is desired
(sorry, no diff -u at this client's site):
-----------------------------------8<------------------------------------
53,92c53,93
< @EXPORT =
<   qw(
<       FD_CLOEXEC
<       F_DUPFD
<       F_EXLCK
<       F_GETFD
<       F_GETFL
<       F_GETLK
<       F_GETOWN
<       F_POSIX
<       F_RDLCK
<       F_SETFD
<       F_SETFL
<       F_SETLK
<       F_SETLKW
<       F_SETOWN
<       F_SHLCK
<       F_UNLCK
<       F_WRLCK
<       O_ACCMODE
<       O_APPEND
<       O_ASYNC
<       O_BINARY
<       O_CREAT
<       O_DEFER
<       O_DSYNC
<       O_EXCL
<       O_EXLOCK
<       O_NDELAY
<       O_NOCTTY
<       O_NONBLOCK
<       O_RDONLY
<       O_RDWR
<       O_RSYNC
<       O_SHLOCK
<       O_SYNC
<       O_TEXT
<       O_TRUNC
<       O_WRONLY
<      );
---
> BEGIN {
>     @EXPORT =
>       qw(
>           FD_CLOEXEC
>           F_DUPFD
>           F_EXLCK
>           F_GETFD
>           F_GETFL
>           F_GETLK
>           F_GETOWN
>           F_POSIX
>           F_RDLCK
>           F_SETFD
>           F_SETFL
>           F_SETLK
>           F_SETLKW
>           F_SETOWN
>           F_SHLCK
>           F_UNLCK
>           F_WRLCK
>           O_ACCMODE
>           O_APPEND
>           O_ASYNC
>           O_BINARY
>           O_CREAT
>           O_DEFER
>           O_DSYNC
>           O_EXCL
>           O_EXLOCK
>           O_NDELAY
>           O_NOCTTY
>           O_NONBLOCK
>           O_RDONLY
>           O_RDWR
>           O_RSYNC
>           O_SHLOCK
>           O_SYNC
>           O_TEXT
>           O_TRUNC
>           O_WRONLY
>        );
94,109c95,117
< # Other items we are prepared to export if requested
< @EXPORT_OK = qw(
<       FAPPEND
<       FASYNC
<       FCREAT
<       FDEFER
<       FEXCL
<       FNDELAY
<       FNONBLOCK
<       FSYNC
<       FTRUNC
<       LOCK_EX
<       LOCK_NB
<       LOCK_SH
<       LOCK_UN
< );
---
>     # Other items we are prepared to export if requested
>     @EXPORT_OK = qw(
>           FAPPEND
>           FASYNC
>           FCREAT
>           FDEFER
>           FEXCL
>           FNDELAY
>           FNONBLOCK
>           FSYNC
>           FTRUNC
>           LOCK_EX
>           LOCK_NB
>           LOCK_SH
>           LOCK_UN
>     );
>    for ( @EXPORT, @EXPORT_OK ) {
>         my $sub = "sub $_() ;" ;
>         eval $sub ;
>         die "$@: $sub" if $@ ;
>    }
> }
> 
114c122
<                    FNDELAY FNONBLOCK FSYNC FTRUNC)],
---
>                    FNDELAY FNONBLOCK FSYNC FTRUNC)],
131c139
<     *$AUTOLOAD = sub { $val };
---
>     *$AUTOLOAD = sub() { $val };


Follow-Ups from:
"Warren Odom" <warren-odom@stenocall.com>
References to:
Tom Christiansen <tchrist@chthon.perl.com>

[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]