Skip to content

Commit

Permalink
- Fixed the interactive help when Sidef is installed.
Browse files Browse the repository at this point in the history
It now tries to use the `man` command, then it fallsback to `perldoc`.

- Minor code tweaks.
  • Loading branch information
trizen committed Dec 7, 2016
1 parent 433e387 commit 805fbc1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The Artistic License 2.0

Copyright (c) 2000-2006, The Perl Foundation.
Copyright (c) 2000-2006, The Perl Foundation.

Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Expand Down
23 changes: 15 additions & 8 deletions bin/sidef
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/perl

use utf8;
use 5.014;
use 5.016;

BEGIN { # support for running sidef locally from everywhere
require File::Spec;
Expand Down Expand Up @@ -321,7 +321,14 @@ HELP
last;
}
}
system 'perldoc', defined($pod) ? $pod : $ref;
if (defined($pod)) {
system 'perldoc', $pod;
$? && system 'man', $ref;
}
else {
system 'man', $ref;
$? && system 'perdoc', $ref;
}
}

redo;
Expand All @@ -344,7 +351,7 @@ sub code_interactive {
};

$init_sidef->();
$sidef->execute_code("1"); # warm-up
$sidef->execute_code(''); # warm-up

my ($copy_array, $copy_hash);

Expand All @@ -354,7 +361,7 @@ sub code_interactive {
my @copy;
foreach my $item (@$array) {
if (ref($item) eq 'ARRAY') {
push @copy, $copy_array->($item);
push @copy, __SUB__->($item);
}
elsif (ref($item) eq 'HASH') {
push @copy, $copy_hash->($item);
Expand All @@ -378,7 +385,7 @@ sub code_interactive {
$copy{$key} = $copy_array->($value);
}
elsif (ref($value) eq 'HASH') {
$copy{$key} = $copy_hash->($value);
$copy{$key} = __SUB__->($value);
}
else {
$copy{$key} = $value;
Expand Down Expand Up @@ -441,14 +448,14 @@ EOT
print <<'EOT';
This program is free software; you can redistribute it
and/or modify it under the same terms as Perl. For more
details, see the full text in the LICENSE file.
and/or modify it under the terms of the Artistic License (2.0).
For more details, see the full text in the LICENSE file.
This program is distributed in the hope that it will be
useful, but without any warranty; without even the implied
warranty of merchantability or fitness for a particular purpose.
See http://dev.perl.org/licenses/ for more information.
See http://www.perlfoundation.org/artistic_license_2_0 for more information.
EOT
redo MAINLOOP;
Expand Down
8 changes: 4 additions & 4 deletions lib/Sidef/Types/Number/Number.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3034,22 +3034,22 @@ package Sidef::Types::Number::Number {

sub rad2deg {
my ($x) = @_;
state $f = do {
state $factor = do {
Math::MPFR::Rmpfr_const_pi((my $pi = Math::MPFR::Rmpfr_init2($PREC)), $ROUND);
Math::MPFR::Rmpfr_ui_div((my $fr = Math::MPFR::Rmpfr_init2($PREC)), 180, $pi, $ROUND);
_mpfr2big($fr);
};
$f->mul($x);
$factor->mul($x);
}

sub deg2rad {
my ($x) = @_;
state $f = do {
state $factor = do {
Math::MPFR::Rmpfr_const_pi((my $pi = Math::MPFR::Rmpfr_init2($PREC)), $ROUND);
Math::MPFR::Rmpfr_div_ui((my $fr = Math::MPFR::Rmpfr_init2($PREC)), $pi, 180, $ROUND);
_mpfr2big($fr);
};
$f->mul($x);
$factor->mul($x);
}

sub rad2grad {
Expand Down

0 comments on commit 805fbc1

Please sign in to comment.