summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Ing-Simmons <nik@tiuk.ti.com>2000-11-13 20:21:57 +0000
committerNick Ing-Simmons <nik@tiuk.ti.com>2000-11-13 20:21:57 +0000
commita10525673ecdf376a72ebd9267ef94c761ff1705 (patch)
tree610bbbc901ca3136c72e3313f193ab4b45c78455
parent14aaf8e8d5ef5f7630e198d7ed4c5b1ce477445f (diff)
parent436e486158da40087b7328d1a4e2be3abcd680f8 (diff)
downloadperl-a10525673ecdf376a72ebd9267ef94c761ff1705.tar.gz
Integrate mainline ...
p4raw-id: //depot/perlio@7675
-rw-r--r--Changes229
-rw-r--r--doop.c2
-rw-r--r--ext/IO/IO.xs11
-rw-r--r--ext/IO/lib/IO/Handle.pm44
-rw-r--r--ext/IO/lib/IO/Seekable.pm64
-rw-r--r--patchlevel.h2
-rw-r--r--perl.h6
-rw-r--r--perlio.c5
-rw-r--r--perlsfio.h2
-rw-r--r--pod/perlfunc.pod10
-rw-r--r--pod/perlunicode.pod12
-rw-r--r--pp.c39
-rw-r--r--regexp.h2
-rwxr-xr-xt/io/tell.t12
-rwxr-xr-xt/lib/io_xs.t1
-rwxr-xr-xt/op/bop.t36
-rw-r--r--utf8.c2
17 files changed, 429 insertions, 50 deletions
diff --git a/Changes b/Changes
index 795359cde6..1b2729edcd 100644
--- a/Changes
+++ b/Changes
@@ -32,6 +32,235 @@ Version v5.7.0 Development release working toward v5.8
--------------
____________________________________________________________________________
+[ 7673] By: jhi on 2000/11/13 14:42:42
+ Log: Remove the new two tests of lib/io_xs for now, they seem to
+ fail under perlio on some platforms.
+ Branch: perl
+ ! t/lib/io_xs.t
+____________________________________________________________________________
+[ 7672] By: jhi on 2000/11/13 13:57:53
+ Log: Make PerlIO_getpos() to behave like fgetpos() on return.
+ Branch: perl
+ ! perlio.c
+____________________________________________________________________________
+[ 7671] By: jhi on 2000/11/13 05:30:48
+ Log: Placate nervous compilers that see longer than ints switch()ing.
+ Branch: perl
+ ! utf8.c
+____________________________________________________________________________
+[ 7670] By: jhi on 2000/11/13 05:14:21
+ Log: fputs() does return EOF on error but here we don't care.
+ Branch: perl
+ ! perlio.c
+____________________________________________________________________________
+[ 7669] By: jhi on 2000/11/13 05:02:45
+ Log: Declare reg_data like reg_substr_data.
+ Branch: perl
+ ! regexp.h
+____________________________________________________________________________
+[ 7668] By: jhi on 2000/11/13 04:54:34
+ Log: Typos in #7667.
+ Branch: perl
+ ! perl.h
+____________________________________________________________________________
+[ 7667] By: jhi on 2000/11/13 04:49:49
+ Log: Cleanup messy #ifdef.
+ Branch: perl
+ ! perl.h
+____________________________________________________________________________
+[ 7666] By: jhi on 2000/11/13 04:17:34
+ Log: Subject: [ID 20001112.008] perlio.c's PerlIO_getpos ingores error return
+ From: Nicholas Clark <nick@talking.bollo.cx>
+ Date: Sun, 12 Nov 2000 21:14:11 +0000
+ Message-Id: <E13v4S3-0000iY-00@Bagpuss.unfortu.net>
+
+ Note: only one breakage of the two reported is fixed by this patch.
+ Branch: perl
+ ! perlio.c
+____________________________________________________________________________
+[ 7665] By: jhi on 2000/11/13 04:05:07
+ Log: Tweak the definition of the bit complement on UTF-8 data:
+ if none of the characters in the string are > 0xff,
+ the result is a complemented byte string, not a (UTF-8)
+ char string. Based on the summary in
+
+ Subject: Re: [ID 20000918.005] ~ on wide chars
+ From: sthoenna@efn.org (Yitzchak Scott-Thoennes)
+ Date: Fri, 10 Nov 2000 09:47:15 -0800
+ Message-ID: <jSDD6gzkgi/T092yn@efn.org>
+
+ This should give us the maximum backward (pre-char string)
+ compatibility and utf8 compatibility. The other alternative
+ would be to limit the bit complement to be always byte only,
+ taking the least significant byte of the chars.
+ Branch: perl
+ ! doop.c pod/perlunicode.pod pp.c t/op/bop.t
+____________________________________________________________________________
+[ 7664] By: jhi on 2000/11/13 00:23:44
+ Log: Couple of tests from #7660 salvaged.
+ Branch: perl
+ - t/op/tell.t
+ ! MANIFEST t/io/tell.t
+____________________________________________________________________________
+[ 7663] By: jhi on 2000/11/13 00:02:48
+ Log: Subject: [ID 20001112.007] sfio's sftell isn't ftell
+ From: Nicholas Clark <nick@talking.bollo.cx>
+ Date: Sun, 12 Nov 2000 21:23:43 +0000
+ Message-Id: <E13v4bH-0000lN-00@Bagpuss.unfortu.net>
+ Branch: perl
+ ! perlsfio.h
+____________________________________________________________________________
+[ 7662] By: jhi on 2000/11/13 00:01:39
+ Log: Subject: [ID 20001112.006] IO::Seekable::getpos doesn't check for fgetpos() failure
+ From: Nicholas Clark <nick@talking.bollo.cx>
+ Date: Sun, 12 Nov 2000 21:30:04 +0000
+ Message-Id: <E13v4hQ-0000mn-00@Bagpuss.unfortu.net>
+ Branch: perl
+ ! ext/IO/IO.xs ext/IO/lib/IO/Seekable.pm t/lib/io_xs.t
+____________________________________________________________________________
+[ 7661] By: jhi on 2000/11/12 23:57:29
+ Log: Document tell() on special streams.
+ Branch: perl
+ ! pod/perlfunc.pod
+____________________________________________________________________________
+[ 7660] By: jhi on 2000/11/12 23:54:22
+ Log: (Subsumed by #7664)
+ Branch: perl
+ + t/op/tell.t
+ ! MANIFEST
+____________________________________________________________________________
+[ 7659] By: jhi on 2000/11/12 22:55:25
+ Log: Many subdocumented return values of the IO extension now documented.
+ ungetc and write still left subdocumented.
+
+ Subject: [PATCH] (was Re: IO::Handle::ungetc)
+ From: Nicholas Clark <nick@talking.bollo.cx>
+ Date: Sun, 12 Nov 2000 21:35:53 +0000
+ Message-ID: <20001112213552.A3034@Bagpuss.unfortu.net>
+ Branch: perl
+ ! ext/IO/lib/IO/Handle.pm
+____________________________________________________________________________
+[ 7658] By: jhi on 2000/11/12 21:37:06
+ Log: Subject: [ID 20001112.004] man perlfunc omits tell()'s error return
+ From: Nicholas Clark <nick@talking.bollo.cx>
+ Date: Sun, 12 Nov 2000 20:03:22 +0000
+ Message-Id: <E13v3LV-0008Pd-00@Bagpuss.unfortu.net>
+ Branch: perl
+ ! pod/perlfunc.pod
+____________________________________________________________________________
+[ 7657] By: jhi on 2000/11/12 20:34:55
+ Log: Integrate perlio.
+ Branch: perl
+ !> perlio.c
+____________________________________________________________________________
+[ 7653] By: jhi on 2000/11/12 19:00:01
+ Log: Add HAS_FSYNC, lack noticed by Nicholas Clark.
+ Branch: perl
+ ! Configure Porting/Glossary Porting/config.sh Porting/config_H
+ ! config_h.SH configure.com epoc/config.sh uconfig.h uconfig.sh
+ ! vos/config.alpha.def vos/config.alpha.h vos/config.ga.def
+ ! vos/config.ga.h win32/config.bc win32/config.gc
+ ! win32/config.vc
+____________________________________________________________________________
+[ 7652] By: jhi on 2000/11/11 21:12:01
+ Log: Copy the s// information of README.hpux also to the perlrun.
+ Branch: perl
+ ! README.hpux pod/perlrun.pod
+____________________________________________________________________________
+[ 7651] By: jhi on 2000/11/11 21:03:13
+ Log: More README.solaris updates from Andy Dougherty.
+ Branch: perl
+ ! README.solaris
+____________________________________________________________________________
+[ 7650] By: jhi on 2000/11/11 18:38:57
+ Log: More descriptive error for unknown perlio layers.
+
+ Subject: [PATCHES Bleadperl] Re: PerlIO - what all of you can all do.
+ From: Dominic Dunlop <domo@computer.org>
+ Date: Sat, 11 Nov 2000 18:20:32 +0100
+ Message-Id: <p04320401b632c4c3335b@[192.168.1.4]>
+ Branch: perl
+ ! perlio.c pod/perldiag.pod
+____________________________________________________________________________
+[ 7649] By: jhi on 2000/11/11 18:37:52
+ Log: MachTen doesn't really do mmap() and munmap().
+
+ Subject: [PATCHES Bleadperl] Re: PerlIO - what all of you can all do.
+ From: Dominic Dunlop <domo@computer.org>
+ Date: Sat, 11 Nov 2000 18:20:32 +0100
+ Message-Id: <p04320401b632c4c3335b@[192.168.1.4]>
+ Branch: perl
+ ! hints/machten.sh
+____________________________________________________________________________
+[ 7648] By: jhi on 2000/11/11 18:36:46
+ Log: Subject: [PATCH] fwd: Re: [ID 20001105.011] Perl 5.6.0 documentation glitch
+ From: rspier@pobox.com (Robert Spier)
+ Date: Sat, 11 Nov 2000 12:22:15 -0500 (EST)
+ Message-ID: <14861.32839.491271.985797@rls.cx>
+ Branch: perl
+ ! Porting/Contract pod/perltoot.pod
+____________________________________________________________________________
+[ 7646] By: jhi on 2000/11/11 18:33:23
+ Log: Add getpagesize() probing, on non-UNIX guess 'undef'.
+ Branch: perl
+ ! Configure Porting/Glossary Porting/config.sh Porting/config_H
+ ! config_h.SH configure.com epoc/config.sh uconfig.h uconfig.sh
+ ! vos/config.alpha.def vos/config.alpha.h vos/config.ga.def
+ ! vos/config.ga.h win32/config.bc win32/config.gc
+ ! win32/config.vc
+____________________________________________________________________________
+[ 7645] By: jhi on 2000/11/11 16:45:15
+ Log: Use sysconf() or getpagesize() to find out the pagesize.
+ Branch: perl
+ ! perlio.c
+____________________________________________________________________________
+[ 7644] By: jhi on 2000/11/11 15:46:08
+ Log: Integrate perlio.
+ Branch: perl
+ !> perlio.c
+____________________________________________________________________________
+[ 7643] By: jhi on 2000/11/11 15:33:36
+ Log: Subject: Re: [PATCH] README.solaris
+ From: Lupe Christoph <lupe@lupe-christoph.de>
+ Date: Sat, 11 Nov 2000 14:08:10 +0100
+ Message-ID: <20001111140810.C10394@alanya.lupe-christoph.de>
+ Branch: perl
+ ! README.solaris
+____________________________________________________________________________
+[ 7642] By: jhi on 2000/11/11 15:22:12
+ Log: Subject: [PATCH perl@7638] cygwin port
+ From: "Eric Fifer" <egf7@columbia.edu>
+ Date: Fri, 10 Nov 2000 19:30:30 -0000
+ Message-ID: <000001c04b4c$b96b7980$243670c2@fifer>
+ Branch: perl
+ ! README.cygwin lib/ExtUtils/MM_Cygwin.pm
+____________________________________________________________________________
+[ 7640] By: jhi on 2000/11/11 02:05:02
+ Log: Add more encoding tables.
+ Branch: perl
+ + ext/Encode/Encode/cp1006.enc ext/Encode/Encode/cp424.enc
+ + ext/Encode/Encode/cp856.enc ext/Encode/Encode/gsm0338.enc
+ + ext/Encode/Encode/iso8859-10.enc
+ + ext/Encode/Encode/iso8859-13.enc
+ + ext/Encode/Encode/iso8859-14.enc
+ + ext/Encode/Encode/iso8859-15.enc
+ ! MANIFEST
+____________________________________________________________________________
+[ 7639] By: jhi on 2000/11/10 18:49:25
+ Log: Subject: [PATCH] README.solaris
+ From: Andy Dougherty <doughera@lafayette.edu>
+ Date: Fri, 10 Nov 2000 12:18:00 -0500 (EST)
+ Message-ID: <Pine.SOL.4.10.10011101217100.28341-100000@maxwell.phys.lafayette.edu>
+ Branch: perl
+ + README.solaris
+ ! INSTALL MANIFEST hints/solaris_2.sh pod/buildtoc.PL
+ ! pod/perl.pod pod/perltoc.pod
+____________________________________________________________________________
+[ 7638] By: jhi on 2000/11/10 15:04:15
+ Log: Update Changes.
+ Branch: perl
+ ! Changes patchlevel.h
+____________________________________________________________________________
[ 7637] By: jhi on 2000/11/10 14:14:28
Log: Explain better why certain regex tests are skipped.
diff --git a/doop.c b/doop.c
index 9fd7dfa49f..3d22eb41fe 100644
--- a/doop.c
+++ b/doop.c
@@ -926,7 +926,7 @@ Perl_do_vop(pTHX_ I32 optype, SV *sv, SV *left, SV *right)
if (left_utf && !right_utf)
sv_utf8_upgrade(right);
- if (!left_utf && right_utf)
+ else if (!left_utf && right_utf)
sv_utf8_upgrade(left);
if (sv != left || (optype != OP_BIT_AND && !SvOK(sv) && !SvGMAGICAL(sv)))
diff --git a/ext/IO/IO.xs b/ext/IO/IO.xs
index 1b79cfd4c0..6da48dca15 100644
--- a/ext/IO/IO.xs
+++ b/ext/IO/IO.xs
@@ -142,12 +142,17 @@ fgetpos(handle)
CODE:
if (handle) {
Fpos_t pos;
+ if (
#ifdef PerlIO
- PerlIO_getpos(handle, &pos);
+ PerlIO_getpos(handle, &pos)
#else
- fgetpos(handle, &pos);
+ fgetpos(handle, &pos)
#endif
- ST(0) = sv_2mortal(newSVpv((char*)&pos, sizeof(Fpos_t)));
+ ) {
+ ST(0) = &PL_sv_undef;
+ } else {
+ ST(0) = sv_2mortal(newSVpv((char*)&pos, sizeof(Fpos_t)));
+ }
}
else {
ST(0) = &PL_sv_undef;
diff --git a/ext/IO/lib/IO/Handle.pm b/ext/IO/lib/IO/Handle.pm
index b6cb410b57..9266f331d8 100644
--- a/ext/IO/lib/IO/Handle.pm
+++ b/ext/IO/lib/IO/Handle.pm
@@ -110,7 +110,8 @@ or a file descriptor number.
=item $io->opened
-Returns true if the object is currently a valid file descriptor.
+Returns true if the object is currently a valid file descriptor, false
+otherwise.
=item $io->getline
@@ -139,31 +140,37 @@ called C<format_write>.
=item $io->error
Returns a true value if the given handle has experienced any errors
-since it was opened or since the last call to C<clearerr>.
+since it was opened or since the last call to C<clearerr>, or if the
+handle is invalid. It only returns false for a valid handle with no
+outstanding errors.
=item $io->clearerr
-Clear the given handle's error indicator.
+Clear the given handle's error indicator. Returns -1 if the handle is
+invalid, 0 otherwise.
=item $io->sync
C<sync> synchronizes a file's in-memory state with that on the
physical medium. C<sync> does not operate at the perlio api level, but
-operates on the file descriptor, this means that any data held at the
-perlio api level will not be synchronized. To synchronize data that is
-buffered at the perlio api level you must use the flush method. C<sync>
-is not implemented on all platforms. See L<fsync(3c)>.
+operates on the file descriptor (similar to sysread, sysseek and
+systell). This means that any data held at the perlio api level will not
+be synchronized. To synchronize data that is buffered at the perlio api
+level you must use the flush method. C<sync> is not implemented on all
+platforms. Returns 0 on success, -1 on error, -1 for an invalid handle.
+See L<fsync(3c)>.
=item $io->flush
C<flush> causes perl to flush any buffered data at the perlio api level.
Any unread data in the buffer will be discarded, and any unwritten data
-will be written to the underlying file descriptor.
+will be written to the underlying file descriptor. Returns 0 on success,
+or a negative value on error.
=item $io->printflush ( ARGS )
Turns on autoflush, print ARGS and then restores the autoflush status of the
-C<IO::Handle> object.
+C<IO::Handle> object. Returns the return value from print.
=item $io->blocking ( [ BOOL ] )
@@ -183,11 +190,17 @@ C<IO::Handle::setbuf> and C<IO::Handle::setvbuf> set the buffering
policy for an IO::Handle. The calling sequences for the Perl functions
are the same as their C counterparts--including the constants C<_IOFBF>,
C<_IOLBF>, and C<_IONBF> for setvbuf()--except that the buffer parameter
-specifies a scalar variable to use as a buffer. WARNING: A variable
-used as a buffer by C<setbuf> or C<setvbuf> must not be modified in any
-way until the IO::Handle is closed or C<setbuf> or C<setvbuf> is called
-again, or memory corruption may result! Note that you need to import
-the constants C<_IOFBF>, C<_IOLBF>, and C<_IONBF> explicitly.
+specifies a scalar variable to use as a buffer. You should only
+change the buffer before any I/O, or immediately after calling flush.
+
+WARNING: A variable used as a buffer by C<setbuf> or C<setvbuf> B<must not
+be modified> in any way until the IO::Handle is closed or C<setbuf> or
+C<setvbuf> is called again, or memory corruption may result! Remember that
+the order of global destruction is undefined, so even if your buffer
+variable remains in scope until program termination, it may be undefined
+before the file IO::Handle is closed. Note that you need to import the
+constants C<_IOFBF>, C<_IOLBF>, and C<_IONBF> explicitly. Like C, setbuf
+returns nothing, setvbuf returns 0 on success, -1 on failure.
Lastly, there is a special method for working under B<-T> and setuid/gid
scripts:
@@ -199,7 +212,8 @@ scripts:
Marks the object as taint-clean, and as such data read from it will also
be considered taint-clean. Note that this is a very trusting action to
take, and appropriate consideration for the data source and potential
-vulnerability should be kept in mind.
+vulnerability should be kept in mind. Returns 0 on success, -1 if setting
+the taint-clean flag failed. (eg invalid handle)
=back
diff --git a/ext/IO/lib/IO/Seekable.pm b/ext/IO/lib/IO/Seekable.pm
index e09d48b9bf..77e0c3a380 100644
--- a/ext/IO/lib/IO/Seekable.pm
+++ b/ext/IO/lib/IO/Seekable.pm
@@ -18,19 +18,69 @@ C<IO::Seekable> does not have a constructor of its own as it is intended to
be inherited by other C<IO::Handle> based objects. It provides methods
which allow seeking of the file descriptors.
-If the C functions fgetpos() and fsetpos() are available, then
-C<$io-E<lt>getpos> returns an opaque value that represents the
-current position of the IO::File, and C<$io-E<gt>setpos(POS)> uses
-that value to return to a previously visited position.
+=over 4
+=item $io->getpos
+
+Returns an opaque value that represents the current position of the
+IO::File, or C<undef> if this is not possible (eg an unseekable stream such
+as a terminal, pipe or socket). If the fgetpos() function is available in
+your C library it is used to implements getpos, else perl emulates getpos
+using C's ftell() function.
+
+=item $io->setpos
+
+Uses the value of a previous getpos call to return to a previously visited
+position. Returns 0 on success, -1 on failure.
+
+=back
+
See L<perlfunc> for complete descriptions of each of the following
supported C<IO::Seekable> methods, which are just front ends for the
corresponding built-in functions:
- $io->seek( POS, WHENCE )
- $io->sysseek( POS, WHENCE )
- $io->tell
+=over 4
+
+=item $io->setpos ( POS, WHENCE )
+
+Seek the IO::File to position POS, relative to WHENCE:
+
+=over 8
+
+=item WHENCE=0 (SEEK_SET)
+
+POS is absolute position. (Seek relative to the start of the file)
+
+=item WHENCE=1 (SEEK_CUR)
+
+POS is an offset from the current position. (Seek relative to current)
+
+=item WHENCE=1 (SEEK_END)
+
+POS is an offset from the end of the file. (Seek relative to end)
+
+=back
+
+The SEEK_* constants can be imported from the C<Fcntl> module if you
+don't wish to use the numbers C<0> C<1> or C<2> in your code.
+
+Returns C<1> upon success, C<0> otherwise.
+
+=item $io->sysseek( POS, WHENCE )
+
+Similar to $io->seek, but sets the IO::File's position using the system
+call lseek(2) directly, so will confuse most perl IO operators except
+sysread and syswrite (see L<perlfunc> for full details)
+
+Returns the new position, or C<undef> on failure. A position
+of zero is returned as the string C<"0 but true">
+
+=item $io->tell
+
+Returns the IO::File's current position, or -1 on error.
+=back
+
=head1 SEE ALSO
L<perlfunc>,
diff --git a/patchlevel.h b/patchlevel.h
index 16f903c70c..2bc6b17828 100644
--- a/patchlevel.h
+++ b/patchlevel.h
@@ -70,7 +70,7 @@
#if !defined(PERL_PATCHLEVEL_H_IMPLICIT) && !defined(LOCAL_PATCH_COUNT)
static char *local_patches[] = {
NULL
- ,"DEVEL7637"
+ ,"DEVEL7673"
,NULL
};
diff --git a/perl.h b/perl.h
index 80bf5ae87d..6f822dcf4a 100644
--- a/perl.h
+++ b/perl.h
@@ -2198,8 +2198,12 @@ char *crypt (const char*, const char*);
# ifndef getenv
char *getenv (const char*);
# endif /* !getenv */
-# if !defined(EPOC) && !(defined(__hpux) && defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64) && !defined(HAS_LSEEK_PROTO)
+# if !defined(HAS_LSEEK_PROTO) && !defined(EPOC) && !defined(__hpux)
+# ifdef _FILE_OFFSET_BITS
+# if _FILE_OFFSET_BITS == 64
Off_t lseek (int,Off_t,int);
+# endif
+# endif
# endif
# endif /* !DONT_DECLARE_STD */
char *getlogin (void);
diff --git a/perlio.c b/perlio.c
index a0e6bc00b7..8d54f77f42 100644
--- a/perlio.c
+++ b/perlio.c
@@ -2314,7 +2314,7 @@ int
PerlIO_getpos(PerlIO *f, Fpos_t *pos)
{
*pos = PerlIO_tell(f);
- return 0;
+ return *pos == -1 ? -1 : 0;
}
#else
#ifndef PERLIO_IS_STDIO
@@ -2359,7 +2359,8 @@ PerlIO_vsprintf(char *s, int n, const char *fmt, va_list ap)
if (strlen(s) >= (STRLEN)n)
{
dTHX;
- PerlIO_puts(Perl_error_log,"panic: sprintf overflow - memory corrupted!\n");
+ (void)PerlIO_puts(Perl_error_log,
+ "panic: sprintf overflow - memory corrupted!\n");
my_exit(1);
}
}
diff --git a/perlsfio.h b/perlsfio.h
index a736371a32..22f5427f8c 100644
--- a/perlsfio.h
+++ b/perlsfio.h
@@ -35,7 +35,7 @@ extern int _stdprintf _ARG_((const char*, ...));
#define PerlIO_fileno(f) sffileno(f)
#define PerlIO_clearerr(f) sfclrerr(f)
#define PerlIO_flush(f) sfsync(f)
-#define PerlIO_tell(f) sftell(f)
+#define PerlIO_tell(f) sfseek(f,0,1|SF_SHARE)
#define PerlIO_seek(f,o,w) sfseek(f,o,w)
#define PerlIO_rewind(f) (void) sfseek((f),0L,0)
#define PerlIO_tmpfile() sftmp(0)
diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod
index 558ae4edd1..2049dd57a2 100644
--- a/pod/perlfunc.pod
+++ b/pod/perlfunc.pod
@@ -5068,9 +5068,13 @@ case the SCALAR is empty you can use OFFSET but only zero offset.
=item tell
-Returns the current position for FILEHANDLE. FILEHANDLE may be an
-expression whose value gives the name of the actual filehandle. If
-FILEHANDLE is omitted, assumes the file last read.
+Returns the current position for FILEHANDLE, or -1 on error. FILEHANDLE
+may be an expression whose value gives the name of the actual filehandle.
+If FILEHANDLE is omitted, assumes the file last read.
+
+The return value of tell() for the standard streams like the STDIN
+depends on the operating system: it may return -1 or something else.
+tell() on pipes, fifos, and sockets usually returns -1.
There is no C<systell> function. Use C<sysseek(FH, 0, 1)> for that.
diff --git a/pod/perlunicode.pod b/pod/perlunicode.pod
index e567e183e1..30a4482260 100644
--- a/pod/perlunicode.pod
+++ b/pod/perlunicode.pod
@@ -198,6 +198,18 @@ byte-oriented C<chr()> and C<ord()> under utf8.
=item *
+The bit string operators C<& | ^ ~> can operate on character data.
+However, for backward compatibility reasons (bit string operations
+when the characters all are less than 256 in ordinal value) one cannot
+mix C<~> (the bit complement) and characters both less than 256 and
+equal or greater than 256. Most importantly, the DeMorgan's laws
+(C<~($x|$y) eq ~$x&~$y>, C<~($x&$y) eq ~$x|~$y>) won't hold.
+Another way to look at this is that the complement cannot return
+B<both> the 8-bit (byte) wide bit complement, and the full character
+wide bit complement.
+
+=item *
+
And finally, C<scalar reverse()> reverses by character rather than by byte.
=back
diff --git a/pp.c b/pp.c
index cc3f7ebf06..2a414b85af 100644
--- a/pp.c
+++ b/pp.c
@@ -1476,31 +1476,50 @@ PP(pp_complement)
tmps = (U8*)SvPV_force(TARG, len);
anum = len;
if (SvUTF8(TARG)) {
- /* Calculate exact length, let's not estimate */
+ /* Calculate exact length, let's not estimate. */
STRLEN targlen = 0;
U8 *result;
U8 *send;
STRLEN l;
+ UV nchar = 0;
+ UV nwide = 0;
send = tmps + len;
while (tmps < send) {
UV c = utf8_to_uv(tmps, 0, &l, UTF8_ALLOW_ANY);
tmps += UTF8SKIP(tmps);
targlen += UNISKIP(~c);
+ nchar++;
+ if (c > 0xff)
+ nwide++;
}
/* Now rewind strings and write them. */
tmps -= len;
- Newz(0, result, targlen + 1, U8);
- while (tmps < send) {
- UV c = utf8_to_uv(tmps, 0, &l, UTF8_ALLOW_ANY);
- tmps += UTF8SKIP(tmps);
- result = uv_to_utf8(result,(UV)~c);
+
+ if (nwide) {
+ Newz(0, result, targlen + 1, U8);
+ while (tmps < send) {
+ UV c = utf8_to_uv(tmps, 0, &l, UTF8_ALLOW_ANY);
+ tmps += UTF8SKIP(tmps);
+ result = uv_to_utf8(result, ~c);
+ }
+ *result = '\0';
+ result -= targlen;
+ sv_setpvn(TARG, (char*)result, targlen);
+ SvUTF8_on(TARG);
+ }
+ else {
+ Newz(0, result, nchar + 1, U8);
+ while (tmps < send) {
+ U8 c = (U8)utf8_to_uv(tmps, 0, &l, UTF8_ALLOW_ANY);
+ tmps += UTF8SKIP(tmps);
+ *result++ = ~c;
+ }
+ *result = '\0';
+ result -= nchar;
+ sv_setpvn(TARG, (char*)result, nchar);
}
- *result = '\0';
- result -= targlen;
- sv_setpvn(TARG, (char*)result, targlen);
- SvUTF8_on(TARG);
Safefree(result);
SETs(TARG);
RETURN;
diff --git a/regexp.h b/regexp.h
index ca0e9ed5da..3c71060a40 100644
--- a/regexp.h
+++ b/regexp.h
@@ -19,6 +19,8 @@ typedef struct regnode regnode;
struct reg_substr_data;
+struct reg_data;
+
typedef struct regexp {
I32 *startp;
I32 *endp;
diff --git a/t/io/tell.t b/t/io/tell.t
index b89aefb230..560836d5e0 100755
--- a/t/io/tell.t
+++ b/t/io/tell.t
@@ -2,7 +2,7 @@
# $RCSfile: tell.t,v $$Revision$$Date$
-print "1..21\n";
+print "1..23\n";
$TST = 'tst';
@@ -82,3 +82,13 @@ if ($. == $curline) { print "ok 20\n"; } else { print "not ok 20\n"; }
tell other;
if ($. == 7) { print "ok 21\n"; } else { print "not ok 21\n"; }
}
+
+close(other);
+if (tell(other) == -1) { print "ok 22\n"; } else { print "not ok 22\n"; }
+
+if (tell(ether) == -1) { print "ok 23\n"; } else { print "not ok 23\n"; }
+
+# ftell(STDIN) (or any std streams) is undefined, it can return -1 or
+# something else. ftell() on pipes, fifos, and sockets is defined to
+# return -1.
+
diff --git a/t/lib/io_xs.t b/t/lib/io_xs.t
index 9305c31986..2449fc45c1 100755
--- a/t/lib/io_xs.t
+++ b/t/lib/io_xs.t
@@ -40,3 +40,4 @@ print scalar <$x>;
$! = 0;
$x->setpos(undef);
print $! ? "ok 4 # $!\n" : "not ok 4\n";
+
diff --git a/t/op/bop.t b/t/op/bop.t
index fd080e6be8..3fad2fd172 100755
--- a/t/op/bop.t
+++ b/t/op/bop.t
@@ -9,7 +9,7 @@ BEGIN {
@INC = '../lib';
}
-print "1..38\n";
+print "1..40\n";
# numerics
print ((0xdead & 0xbeef) == 0x9ead ? "ok 1\n" : "not ok 1\n");
@@ -107,7 +107,7 @@ for (0x100...0xFFF) {
if $a ne chr(~$_) or length($a) != 1 or ~$a ne chr($_);
}
if (@not36) {
- print "# test 36 failed: @not36\n";
+ print "# test 36 failed\n";
print "not ";
}
print "ok 36\n";
@@ -120,14 +120,42 @@ for my $i (0xEEE...0xF00) {
push @not37, sprintf("%#03X %#03X", $i, $j)
if $a ne chr(~$i).chr(~$j) or
length($a) != 2 or
- ~$a ne chr($i).chr($j);
+ ~$a ne chr($i).chr($j);
}
}
if (@not37) {
- print "# test 37 failed: @not37\n";
+ print "# test 37 failed\n";
print "not ";
}
print "ok 37\n";
print "not " unless ~chr(~0) eq "\0";
print "ok 38\n";
+
+my @not39;
+
+for my $i (0x100..0x120) {
+ for my $j (0x100...0x120) {
+ push @not39, sprintf("%#03X %#03X", $i, $j)
+ if ~(chr($i)|chr($j)) ne (~chr($i)&~chr($j));
+ }
+}
+if (@not39) {
+ print "# test 39 failed\n";
+ print "not ";
+}
+print "ok 39\n";
+
+my @not40;
+
+for my $i (0x100..0x120) {
+ for my $j (0x100...0x120) {
+ push @not40, sprintf("%#03X %#03X", $i, $j)
+ if ~(chr($i)&chr($j)) ne (~chr($i)|~chr($j));
+ }
+}
+if (@not40) {
+ print "# test 40 failed\n";
+ print "not ";
+}
+print "ok 40\n";
diff --git a/utf8.c b/utf8.c
index 8ce0d216a1..6ddf42bf5c 100644
--- a/utf8.c
+++ b/utf8.c
@@ -1089,7 +1089,7 @@ Perl_swash_fetch(pTHX_ SV *sv, U8 *ptr)
Copy(ptr, PL_last_swash_key, klen, U8);
}
- switch ((slen << 3) / needents) {
+ switch ((int)((slen << 3) / needents)) {
case 1:
bit = 1 << (off & 7);
off >>= 3;