Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
slightly more consistent formatting
  • Loading branch information
kraih committed Mar 23, 2016
1 parent cb9eaf6 commit 4034b64
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Changes
@@ -1,5 +1,5 @@

6.57 2016-03-22
6.57 2016-03-23
- Fixed a few validation bugs in Mojolicious::Validator::Validation.
(Mikey, sri)

Expand Down
19 changes: 5 additions & 14 deletions lib/Mojo/Util.pm
Expand Up @@ -155,17 +155,13 @@ sub punycode_decode {
my $input = shift;
use integer;

my $n = PC_INITIAL_N;
my $i = 0;
my $bias = PC_INITIAL_BIAS;
my @output;
my ($n, $i, $bias, @output) = (PC_INITIAL_N, 0, PC_INITIAL_BIAS);

# Consume all code points before the last delimiter
push @output, split('', $1) if $input =~ s/(.*)\x2d//s;

while (length $input) {
my $oldi = $i;
my $w = 1;
my ($oldi, $w) = ($i, 1);

# Base to infinity in steps of base
for (my $k = PC_BASE; 1; $k += PC_BASE) {
Expand All @@ -192,25 +188,20 @@ sub punycode_encode {
my $output = shift;
use integer;

my $n = PC_INITIAL_N;
my $delta = 0;
my $bias = PC_INITIAL_BIAS;
my ($n, $delta, $bias) = (PC_INITIAL_N, 0, PC_INITIAL_BIAS);

# Extract basic code points
my $len = length $output;
my @input = map {ord} split '', $output;
my @chars = sort grep { $_ >= PC_INITIAL_N } @input;
$output =~ s/[^\x00-\x7f]+//gs;
my $h = my $basic = length $output;
$output .= "\x2d" if $basic > 0;

for my $m (@chars) {
for my $m (sort grep { $_ >= PC_INITIAL_N } @input) {
next if $m < $n;
$delta += ($m - $n) * ($h + 1);
$n = $m;

for (my $i = 0; $i < $len; $i++) {
my $c = $input[$i];
for my $c (@input) {

if ($c < $n) { $delta++ }
elsif ($c == $n) {
Expand Down

0 comments on commit 4034b64

Please sign in to comment.