view interps/clc-intercal/CLC-INTERCAL-ICALC-1.-94.-2/t/run-calculator @ 9071:581584df6d82

<fizzie> revert 942e964c81c1
author HackBot
date Sun, 25 Sep 2016 20:17:31 +0000
parents 859f9b4339e6
children
line wrap: on
line source

# run the calculator

# Copyright (c) 2006-2008 Claudio Calvelli, all rights reserved.

# CLC-INTERCAL is copyrighted software. However, permission to use, modify,
# and distribute it is granted provided that the conditions set out in the
# licence agreement are met. See files README and COPYING in the distribution.

use IPC::Open3 qw(open3);

my @libs = map { "-I$_" } @INC;
#my $rcfile = undef;
#for my $inc (@INC) {
#    my $f = "$inc/Language/INTERCAL/Include/system.sickrc";
#    -f $f or next;
#    $rcfile = $f;
#    last;
#}
#defined $rcfile or die "Could not find default system.sickrc?\n";

sub run_calculator {
    my ($mode, $language, @options) = @_;
    my ($rfh, $wfh);
    my @language = defined $language ? ("-l$language") : ();
    push @language, map { "-o$_" } @options;
    my $pid = open3($rfh, $wfh, $wfh, $^X, @libs,
		    'bin/intercalc', '--batch', "-m$mode", @language,
		    '--bug=0', '--ubug=0', '--nouserrc');
    my $so = select $rfh;
    $| = 1;
    select $so;
    ($pid, $rfh, $wfh);
}

1