Skip to content

Commit

Permalink
Merge 79eaec4 into facfab6
Browse files Browse the repository at this point in the history
  • Loading branch information
scottchiefbaker committed May 15, 2021
2 parents facfab6 + 79eaec4 commit 333a8d2
Show file tree
Hide file tree
Showing 26 changed files with 357 additions and 72 deletions.
1 change: 1 addition & 0 deletions MANIFEST
Expand Up @@ -5958,6 +5958,7 @@ t/op/time.t See if time functions work
t/op/time_loop.t Test that very large values don't hang gmtime and localtime.
t/op/tr.t See if tr works
t/op/tr_latin1.t See if tr works, but file isn't encoded in UTF-8
t/op/trim.t See if trim works
t/op/try.t See if try works
t/op/undef.t See if undef works
t/op/universal.t See if UNIVERSAL class works
Expand Down
4 changes: 2 additions & 2 deletions ext/Opcode/Opcode.pm
Expand Up @@ -6,7 +6,7 @@ use strict;

our($VERSION, @ISA, @EXPORT_OK);

$VERSION = "1.50";
$VERSION = "1.51";

use Carp;
use Exporter ();
Expand Down Expand Up @@ -333,7 +333,7 @@ invert_opset function.
slt sgt sle sge seq sne scmp
isa
substr vec stringify study pos length index rindex ord chr
substr vec stringify study pos length index rindex ord chr trim
ucfirst lcfirst uc lc fc quotemeta trans transr chop schop
chomp schomp
Expand Down
6 changes: 3 additions & 3 deletions ext/Pod-Functions/t/Functions.t
Expand Up @@ -78,7 +78,7 @@ __DATA__
Functions for SCALARs or strings:
chomp, chop, chr, crypt, fc, hex, index, lc, lcfirst,
length, oct, ord, pack, q/STRING/, qq/STRING/, reverse,
rindex, sprintf, substr, tr///, uc, ucfirst, y///
rindex, sprintf, substr, tr///, trim, uc, ucfirst, y///
Regular expressions and pattern matching:
m//, pos, qr/STRING/, quotemeta, s///, split, study
Expand All @@ -100,8 +100,8 @@ Input and output functions:
binmode, close, closedir, dbmclose, dbmopen, die, eof,
fileno, flock, format, getc, print, printf, read, readdir,
readline, rewinddir, say, seek, seekdir, select, syscall,
sysread, sysseek, syswrite, tell, telldir, truncate, warn,
write
sysread, sysseek, syswrite, tell, telldir, trim, truncate,
warn, write
Functions for fixed-length data or records:
pack, read, syscall, sysread, sysseek, syswrite, unpack,
Expand Down
20 changes: 16 additions & 4 deletions feature.h
Expand Up @@ -27,9 +27,10 @@
#define FEATURE_SIGNATURES_BIT 0x1000
#define FEATURE_STATE_BIT 0x2000
#define FEATURE_SWITCH_BIT 0x4000
#define FEATURE_TRY_BIT 0x8000
#define FEATURE_UNIEVAL_BIT 0x10000
#define FEATURE_UNICODE_BIT 0x20000
#define FEATURE_TRIM_BIT 0x8000
#define FEATURE_TRY_BIT 0x10000
#define FEATURE_UNIEVAL_BIT 0x20000
#define FEATURE_UNICODE_BIT 0x40000

#define FEATURE_BUNDLE_DEFAULT 0
#define FEATURE_BUNDLE_510 1
Expand Down Expand Up @@ -79,6 +80,12 @@
FEATURE_IS_ENABLED_MASK(FEATURE_TRY_BIT) \
)

#define FEATURE_TRIM_IS_ENABLED \
( \
CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
FEATURE_IS_ENABLED_MASK(FEATURE_TRIM_BIT) \
)

#define FEATURE_STATE_IS_ENABLED \
( \
(CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_510 && \
Expand Down Expand Up @@ -345,7 +352,12 @@ S_magic_sethint_feature(pTHX_ SV *keysv, const char *keypv, STRLEN keylen,
return;

case 't':
if (keylen == sizeof("feature_try")-1
if (keylen == sizeof("feature_trim")-1
&& memcmp(subf+1, "rim", keylen - sizeof("feature_")) == 0) {
mask = FEATURE_TRIM_BIT;
break;
}
else if (keylen == sizeof("feature_try")-1
&& memcmp(subf+1, "ry", keylen - sizeof("feature_")) == 0) {
mask = FEATURE_TRY_BIT;
break;
Expand Down
13 changes: 11 additions & 2 deletions keywords.c
Expand Up @@ -516,7 +516,7 @@ Perl_keyword (pTHX_ const char *name, I32 len, bool all_keywords)
goto unknown;
}

case 4: /* 40 tokens of length 4 */
case 4: /* 41 tokens of length 4 */
switch (name[0])
{
case 'I':
Expand Down Expand Up @@ -931,6 +931,15 @@ Perl_keyword (pTHX_ const char *name, I32 len, bool all_keywords)
goto unknown;
}

case 'r':
if (name[2] == 'i' &&
name[3] == 'm')
{ /* trim */
return (all_keywords || FEATURE_TRIM_IS_ENABLED ? -KEY_trim : 0);
}

goto unknown;

default:
goto unknown;
}
Expand Down Expand Up @@ -3475,5 +3484,5 @@ Perl_keyword (pTHX_ const char *name, I32 len, bool all_keywords)
}

/* Generated from:
* 3a4f2004642b00b871c01cbdc018f6ca5ead6b4e0b2b184120c60b0b62a229dd regen/keywords.pl
* 5d7dce0e0105a5ae14e7847d3059d35cb604342c69755a0444c2f77333f23786 regen/keywords.pl
* ex: set ro: */
53 changes: 27 additions & 26 deletions keywords.h
Expand Up @@ -246,32 +246,33 @@
#define KEY_times 230
#define KEY_tr 231
#define KEY_try 232
#define KEY_truncate 233
#define KEY_uc 234
#define KEY_ucfirst 235
#define KEY_umask 236
#define KEY_undef 237
#define KEY_unless 238
#define KEY_unlink 239
#define KEY_unpack 240
#define KEY_unshift 241
#define KEY_untie 242
#define KEY_until 243
#define KEY_use 244
#define KEY_utime 245
#define KEY_values 246
#define KEY_vec 247
#define KEY_wait 248
#define KEY_waitpid 249
#define KEY_wantarray 250
#define KEY_warn 251
#define KEY_when 252
#define KEY_while 253
#define KEY_write 254
#define KEY_x 255
#define KEY_xor 256
#define KEY_y 257
#define KEY_trim 233
#define KEY_truncate 234
#define KEY_uc 235
#define KEY_ucfirst 236
#define KEY_umask 237
#define KEY_undef 238
#define KEY_unless 239
#define KEY_unlink 240
#define KEY_unpack 241
#define KEY_unshift 242
#define KEY_untie 243
#define KEY_until 244
#define KEY_use 245
#define KEY_utime 246
#define KEY_values 247
#define KEY_vec 248
#define KEY_wait 249
#define KEY_waitpid 250
#define KEY_wantarray 251
#define KEY_warn 252
#define KEY_when 253
#define KEY_while 254
#define KEY_write 255
#define KEY_x 256
#define KEY_xor 257
#define KEY_y 258

/* Generated from:
* 3a4f2004642b00b871c01cbdc018f6ca5ead6b4e0b2b184120c60b0b62a229dd regen/keywords.pl
* 5d7dce0e0105a5ae14e7847d3059d35cb604342c69755a0444c2f77333f23786 regen/keywords.pl
* ex: set ro: */
7 changes: 4 additions & 3 deletions lib/B/Deparse-core.t
Expand Up @@ -36,7 +36,7 @@ BEGIN {

use strict;
use Test::More;
plan tests => 3904;
plan tests => 3916;

use feature (sprintf(":%vd", $^V)); # to avoid relying on the feature
# logic to add CORE::
Expand Down Expand Up @@ -82,7 +82,7 @@ sub testit {
my $code_ref;
if ($lexsub) {
package lexsubtest;
no warnings 'experimental::lexical_subs', 'experimental::isa';
no warnings 'experimental::lexical_subs', 'experimental::isa', 'experimental::trim';
use feature 'lexical_subs';
no strict 'vars';
$code = "sub { state sub $keyword; ${vars}() = $expr }";
Expand All @@ -91,7 +91,7 @@ sub testit {
}
else {
package test;
no warnings 'experimental::isa';
no warnings 'experimental::isa', 'experimental::trim';
use subs ();
import subs $keyword;
$code = "no strict 'vars'; sub { ${vars}() = $expr }";
Expand Down Expand Up @@ -661,6 +661,7 @@ tie 234 p
tied 1 -
time 0 -
times 0 -
trim 1 -
truncate 2 p
uc 01 $
ucfirst 01 $
Expand Down
3 changes: 2 additions & 1 deletion lib/B/Deparse.pm
Expand Up @@ -52,7 +52,7 @@ use B qw(class main_root main_start main_cv svref_2object opnumber perlstring
MDEREF_SHIFT
);

$VERSION = '1.56';
$VERSION = '1.57';
use strict;
our $AUTOLOAD;
use warnings ();
Expand Down Expand Up @@ -2821,6 +2821,7 @@ sub pp_ucfirst { dq_unop(@_, "ucfirst") }
sub pp_lcfirst { dq_unop(@_, "lcfirst") }
sub pp_uc { dq_unop(@_, "uc") }
sub pp_lc { dq_unop(@_, "lc") }
sub pp_trim { dq_unop(@_, "trim") }
sub pp_quotemeta { maybe_targmy(@_, \&dq_unop, "quotemeta") }
sub pp_fc { dq_unop(@_, "fc") }

Expand Down
1 change: 1 addition & 0 deletions lib/B/Op_private.pm
Expand Up @@ -571,6 +571,7 @@ $bits{substcont}{0} = $bf[0];
$bits{telldir}{0} = $bf[0];
@{$bits{tie}}{3,2,1,0} = ($bf[4], $bf[4], $bf[4], $bf[4]);
$bits{tied}{0} = $bf[0];
$bits{trim}{0} = $bf[0];
@{$bits{truncate}}{3,2,1,0} = ($bf[4], $bf[4], $bf[4], $bf[4]);
$bits{uc}{0} = $bf[0];
$bits{ucfirst}{0} = $bf[0];
Expand Down
12 changes: 11 additions & 1 deletion lib/feature.pm
Expand Up @@ -12,6 +12,7 @@ our %feature = (
isa => 'feature_isa',
say => 'feature_say',
try => 'feature_try',
trim => 'feature_trim',
state => 'feature_state',
switch => 'feature_switch',
bitwise => 'feature_bitwise',
Expand All @@ -34,7 +35,7 @@ our %feature_bundle = (
"5.15" => [qw(bareword_filehandles current_sub evalbytes fc indirect multidimensional say state switch unicode_eval unicode_strings)],
"5.23" => [qw(bareword_filehandles current_sub evalbytes fc indirect multidimensional postderef_qq say state switch unicode_eval unicode_strings)],
"5.27" => [qw(bareword_filehandles bitwise current_sub evalbytes fc indirect multidimensional postderef_qq say state switch unicode_eval unicode_strings)],
"all" => [qw(bareword_filehandles bitwise current_sub declared_refs evalbytes fc indirect isa multidimensional postderef_qq refaliasing say signatures state switch try unicode_eval unicode_strings)],
"all" => [qw(bareword_filehandles bitwise current_sub declared_refs evalbytes fc indirect isa multidimensional postderef_qq refaliasing say signatures state switch trim try unicode_eval unicode_strings)],
"default" => [qw(bareword_filehandles indirect multidimensional)],
);

Expand Down Expand Up @@ -429,6 +430,15 @@ C<try> are caught by executing the body of the C<catch> block.
For more information, see L<perlsyn/"Try Catch Exception Handling">.
=head2 The 'trim' feature
C<use feature 'trim'> tells the compiler to enable the C<trim> function, which
removes leading and trailing whitespace from strings.
See L<perlfunc/trim> for details.
This feature is available from Perl 5.34 onwards.
=head1 FEATURE BUNDLES
It's possible to load multiple features together, using
Expand Down
21 changes: 13 additions & 8 deletions lib/warnings.pm
Expand Up @@ -5,7 +5,7 @@

package warnings;

our $VERSION = "1.51";
our $VERSION = "1.52";

# Verify that we're called correctly so that warnings will work.
# Can't use Carp, since Carp uses us!
Expand Down Expand Up @@ -111,7 +111,8 @@ our %Offsets = (
'experimental::isa' => 146,

# Warnings Categories added in Perl 5.033
'experimental::try' => 148,
'experimental::trim' => 148,
'experimental::try' => 150,
);

our %Bits = (
Expand All @@ -125,7 +126,7 @@ our %Bits = (
'digit' => "\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [31]
'exec' => "\x00\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [7]
'exiting' => "\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [3]
'experimental' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x55\x51\x15\x50\x51\x15", # [51..56,58..62,66..68,70..74]
'experimental' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x55\x51\x15\x50\x51\x55", # [51..56,58..62,66..68,70..75]
'experimental::alpha_assertions' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00", # [67]
'experimental::bitwise' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00", # [58]
'experimental::const_attr' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00", # [59]
Expand All @@ -140,7 +141,8 @@ our %Bits = (
'experimental::script_run' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00", # [68]
'experimental::signatures' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00", # [56]
'experimental::smartmatch' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00", # [54]
'experimental::try' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10", # [74]
'experimental::trim' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10", # [74]
'experimental::try' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40", # [75]
'experimental::uniprop_wildcards' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00", # [71]
'experimental::vlb' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01", # [72]
'experimental::win32_perlio' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00", # [62]
Expand Down Expand Up @@ -203,7 +205,7 @@ our %DeadBits = (
'digit' => "\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [31]
'exec' => "\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [7]
'exiting' => "\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [3]
'experimental' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\xaa\xa2\x2a\xa0\xa2\x2a", # [51..56,58..62,66..68,70..74]
'experimental' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\xaa\xa2\x2a\xa0\xa2\xaa", # [51..56,58..62,66..68,70..75]
'experimental::alpha_assertions' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00", # [67]
'experimental::bitwise' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x00", # [58]
'experimental::const_attr' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00", # [59]
Expand All @@ -218,7 +220,8 @@ our %DeadBits = (
'experimental::script_run' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00", # [68]
'experimental::signatures' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00", # [56]
'experimental::smartmatch' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x00\x00", # [54]
'experimental::try' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20", # [74]
'experimental::trim' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20", # [74]
'experimental::try' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80", # [75]
'experimental::uniprop_wildcards' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00", # [71]
'experimental::vlb' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02", # [72]
'experimental::win32_perlio' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00", # [62]
Expand Down Expand Up @@ -272,8 +275,8 @@ our %DeadBits = (

# These are used by various things, including our own tests
our $NONE = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
our $DEFAULT = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x00\x55\x51\x55\x50\x51\x15"; # [2,4,22,23,25,52..56,58..63,66..68,70..74]
our $LAST_BIT = 150 ;
our $DEFAULT = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x00\x55\x51\x55\x50\x51\x55"; # [2,4,22,23,25,52..56,58..63,66..68,70..75]
our $LAST_BIT = 152 ;
our $BYTES = 19 ;

sub Croaker
Expand Down Expand Up @@ -893,6 +896,8 @@ The current hierarchy is:
| |
| +- experimental::smartmatch
| |
| +- experimental::trim
| |
| +- experimental::try
| |
| +- experimental::uniprop_wildcards
Expand Down

0 comments on commit 333a8d2

Please sign in to comment.