<commit_before>// Copyright 2008 <NAME> <<EMAIL>>
//
// This software may be used and distributed according to the terms
// of the Genyris License, in the file "LICENSE", incorporated herein by reference.
//
package org.genyris.load;

import java.io.Writer;

import org.genyris.core.Constants;
import org.genyris.core.Exp;
import org.genyris.core.StrinG;
import org.genyris.exception.GenyrisException;
import org.genyris.interp.ApplicableFunction;
import org.genyris.interp.Closure;
import org.genyris.interp.Environment;
import org.genyris.interp.Interpreter;
import org.genyris.io.NullWriter;

public class IncludeFunction extends ApplicableFunction {

    public IncludeFunction(Interpreter interp) {
        super(interp, Constants.PREFIX_SYSTEM + "include", true);
    }

    public Exp bindAndExecute(Closure proc, Exp[] arguments, Environment env)
            throws GenyrisException {
        Exp result;
        Writer out = new NullWriter();
        this.checkArguments(arguments, 1, 2);
        if (!(arguments[0] instanceof StrinG)) {
            throw new GenyrisException(
                    "non-string argument passed to include: "
                            + arguments[0].toString());
        }
        if (arguments.length > 1) {
            if (arguments[1] == TRUE) {
                out = _interp.getDefaultOutputWriter();
            }
        }
        String filename = arguments[0].toString();
        result = SourceLoader.loadScriptFromFile(_interp.getGlobalEnv(),
                _interp.getSymbolTable(), filename, out);

        return result;
    }
}
<commit_msg>Fix IDE complaints about resource leaks. Take 2.<commit_after>// Copyright 2008 <NAME> <<EMAIL>>
//
// This software may be used and distributed according to the terms
// of the Genyris License, in the file "LICENSE", incorporated herein by reference.
//
package org.genyris.load;

import java.io.IOException;
import java.io.Writer;

import org.genyris.core.Constants;
import org.genyris.core.Exp;
import org.genyris.core.StrinG;
import org.genyris.exception.GenyrisException;
import org.genyris.interp.ApplicableFunction;
import org.genyris.interp.Closure;
import org.genyris.interp.Environment;
import org.genyris.interp.Interpreter;
import org.genyris.io.NullWriter;

public class IncludeFunction extends ApplicableFunction {

    public IncludeFunction(Interpreter interp) {
        super(interp, Constants.PREFIX_SYSTEM + "include", true);
    }

    public Exp bindAndExecute(Closure proc, Exp[] arguments, Environment env)
            throws GenyrisException {
        Exp result = NIL;
        try {
            @SuppressWarnings("resource")
            Writer out = new NullWriter();
            this.checkArguments(arguments, 1, 2);
            if (!(arguments[0] instanceof StrinG)) {
                out.close();
                throw new GenyrisException("non-string argument passed to include: "
                        + arguments[0].toString());
            }
            if (arguments.length > 1) {
                if (arguments[1] == TRUE) {
                    out.close();
                    out = _interp.getDefaultOutputWriter();
                }
            }
            String filename = arguments[0].toString();
            result = SourceLoader.loadScriptFromFile(_interp.getGlobalEnv(),
                    _interp.getSymbolTable(), filename, out);
            out.close();
        } catch (IOException unknown) {
            throw new GenyrisException(unknown.getMessage());
        }
        return result;
    }
}

{'fraction_non_alphanumeric': 0.10186230248306997, 'fraction_numerical': 0.006489841986455982, 'mean_word_length': 2.506429277942631, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6601649', 'n_tokens_mistral': 998, 'n_tokens_neox': 961, 'n_words': 244}