Skip to content

Commit

Permalink
Move a more functions to Parrot::Pmc2c::UtilFunctions.
Browse files Browse the repository at this point in the history
  • Loading branch information
jkeenan committed Feb 5, 2011
1 parent 8036e14 commit 1232e46
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 22 deletions.
23 changes: 1 addition & 22 deletions lib/Parrot/Pmc2c/PCCMETHOD.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use strict;
use warnings;
use Carp qw(longmess croak);
use Parrot::Pmc2c::PCCMETHOD_BITS;
use Parrot::Pmc2c::UtilFunctions qw( trim );

=head1 NAME
Expand Down Expand Up @@ -96,28 +97,6 @@ our $reg_type_info = {
at => PARROT_ARG_PMC, },
};

# Perl trim function to remove whitespace from the start and end of the string
sub trim {
my $string = shift;
$string =~ s/^\s+//;
$string =~ s/\s+$//;
return $string;
}

# Left trim function to remove leading whitespace
sub ltrim {
my $string = shift;
$string =~ s/^\s+//;
return $string;
}

# Right trim function to remove trailing whitespace
sub rtrim {
my $string = shift;
$string =~ s/\s+$//;
return $string;
}

=head3 C<parse_adverb_attributes>
builds and returs an adverb hash from an adverb string such as
Expand Down
23 changes: 23 additions & 0 deletions lib/Parrot/Pmc2c/UtilFunctions.pm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ our @EXPORT_OK = qw( count_newlines return_statement dont_edit dynext_load_code
args_from_parameter_list
passable_args_from_parameter_list
gen_multi_name
trim ltrim rtrim
);

=head1 NAME
Expand Down Expand Up @@ -308,6 +309,28 @@ sub gen_multi_name {
return $cache->{$name} = "mfl_$count";
}

# Perl trim function to remove whitespace from the start and end of the string
sub trim {
my $string = shift;
$string =~ s/^\s+//;
$string =~ s/\s+$//;
return $string;
}

# Left trim function to remove leading whitespace
sub ltrim {
my $string = shift;
$string =~ s/^\s+//;
return $string;
}

# Right trim function to remove trailing whitespace
sub rtrim {
my $string = shift;
$string =~ s/\s+$//;
return $string;
}

1;

# Local Variables:
Expand Down

0 comments on commit 1232e46

Please sign in to comment.