Skip to content

Commit

Permalink
dc: add strict (#899)
Browse files Browse the repository at this point in the history
* Enabling strict will help catch some errors for future changes to dc
* Add explicit defined() checks for result of readline (suggested by diagnostics.pm when temporarily enabled)
  • Loading branch information
mknos authored Jan 3, 2025
1 parent 9df8833 commit 96df63b
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions bin/dc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ License:
=cut

use strict;

# dc.pl - an arbitrary precision RPN calculator, using only string ops
#
Expand Down Expand Up @@ -45,18 +46,15 @@ License:
## Limitations: scale <= 999; |obase| >= 1; input digits in [0..F]
## Completed: 1am Feb 4, 1997

eval 'exec /usr/local/bin/perl -S $0 ${1+"$@"}'
if $running_under_some_shell;

if (scalar(@ARGV) == 0) {
push @ARGV, "-";
}
my ($hold, $line);
@ARGV = ( '-' ) unless @ARGV;
$_ = "|P|K0|I10|O10|?";

for (;;) {
s/\|\?./|?/s;
if (/\|\?!*[lLsS;:<>=]?$/) {
last unless $line = <>;
$line = <>;
last unless defined $line;
$line =~ tr/|~/\36\37/;
$_ .= $line;
}
Expand Down Expand Up @@ -171,7 +169,8 @@ X^*dZkdXK-1+ktsc0kdSb-[Lbdlb*lc+tdSbO*-lb0!=aldx]dsaxLbsb]sad1!>a[[.]POX
goto Pop;

Input:
last unless $line = <STDIN>;
$line = <STDIN>;
last unless defined $line;
$line =~ tr/|~/\36\37/;
$_ .= "\n" . $line;
s/\|\?\?(.*)(\n.*)\n/|?$2~$1/s;
Expand Down Expand Up @@ -218,7 +217,8 @@ X^*dZkdXK-1+ktsc0kdSb-[Lbdlb*lc+tdSbO*-lb0!=aldx]dsaxLbsb]sad1!>a[[.]POX
String:
do {
if (/\|\?[^]]*$/) {
last unless $line = <>;
$line = <>;
last unless defined $line;
$line =~ tr/|~/\36\37/;
$_ .= $line;
}
Expand Down

0 comments on commit 96df63b

Please sign in to comment.