<commit_before>
package jcurses.system;

import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;

import jcurses.util.Rectangle;
import jcurses.util.TextUtils;

/**
 * This class is the 'work factory' of the jcurses library. It contains methods for primitive input and output operations and is only interface
 * to platform dependent libraries. A developer must not usually call methods of this class. These methods are used in implementing widgets
 * and in jcurses core.
 *
 */
@SuppressWarnings("rawtypes")
public class Toolkit {
    /**
     *  Effectively an enum
     */     
    public static final int VERTICAL = 0;
    /**
     *  Effectively an enum
     */     
    public static final int HORIZONTAL = 1;
    /**
     *  Effectively an enum
     */ 
    public static final short LL_CORNER = 2;
    /**
     *  Effectively an enum
     */ 
    public static final short LR_CORNER = 3;
    /**
     *  Effectively an enum
     */ 
    public static final short UL_CORNER = 4;
    /**
     *  Effectively an enum
     */ 
    public static final short UR_CORNER = 5;

    
    private static long []__attributes = {0 ,0 ,0} ;
    private static short []__basicColors = {0 ,0 ,0 ,0 ,0 ,0 ,0 ,0} ;
    private static short [][]__colorpairs = new short [8][8];
    private static Hashtable __clips = new Hashtable();
    private static short __maxColorPairNumber = - 1;
    private static String __encoding;
    // private static final String JAR_RESOURCE         = "jar:file:";
    // private static final String FILE_RESOURCE        = "file:";
    private static final String LIBRARY_NAME = "jcurses";

    static {
    	List<String> searchPaths = new ArrayList<String>();
    	final String osName = System.getProperty("os.name").toLowerCase();
    	String libExtension = null;
		if (osName.indexOf("linux") >= 0) {
    		libExtension = ".so";
		} else if (osName.indexOf("win") >= 0) {
    		libExtension = ".dll";
		} else if (osName.indexOf("mac") >= 0) {
    		libExtension = ".jnilib";	 // TODO not sure
    	}
    	// $PWD/jcurses.so
    	searchPaths.add(System.getProperty("user.dir") + "/" + LIBRARY_NAME + libExtension);
    	// $PWD/libjcurses.so
    	searchPaths.add(System.getProperty("user.dir") + "/lib" + LIBRARY_NAME + libExtension);
    	// $PWD/lib/jcurses.so
    	searchPaths.add(System.getProperty("user.dir") + "/lib/" + LIBRARY_NAME + libExtension);
    	// $PWD/lib/libjcurses.so
    	searchPaths.add(System.getProperty("user.dir") + "/lib/lib" + LIBRARY_NAME + libExtension);
    	
    	boolean foundInPath = false;
		for (String sp : searchPaths) {
    		try {
    			System.load(sp);
    			foundInPath = true;
    		} catch (UnsatisfiedLinkError e) {
    			System.out.println("Not found in " + sp);
    		}
    	}
		if (!foundInPath) {
			try {
				System.loadLibrary(LIBRARY_NAME);
			} catch (UnsatisfiedLinkError e) {
				System.out.println("Found Library neither in the default search paths, not in the java.system.path. Stopping");
				System.exit(-1);
			}
		}
        // loadLibrary();<commit_msg>More search paths for jcurses.(so|dll) in $PWD and $HOME<commit_after>
package jcurses.system;

import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;

import jcurses.util.Rectangle;
import jcurses.util.TextUtils;

/**
 * This class is the 'work factory' of the jcurses library. It contains methods for primitive input and output operations and is only interface
 * to platform dependent libraries. A developer must not usually call methods of this class. These methods are used in implementing widgets
 * and in jcurses core.
 *
 */
@SuppressWarnings("rawtypes")
public class Toolkit {
    /**
     *  Effectively an enum
     */     
    public static final int VERTICAL = 0;
    /**
     *  Effectively an enum
     */     
    public static final int HORIZONTAL = 1;
    /**
     *  Effectively an enum
     */ 
    public static final short LL_CORNER = 2;
    /**
     *  Effectively an enum
     */ 
    public static final short LR_CORNER = 3;
    /**
     *  Effectively an enum
     */ 
    public static final short UL_CORNER = 4;
    /**
     *  Effectively an enum
     */ 
    public static final short UR_CORNER = 5;

    
    private static long []__attributes = {0 ,0 ,0} ;
    private static short []__basicColors = {0 ,0 ,0 ,0 ,0 ,0 ,0 ,0} ;
    private static short [][]__colorpairs = new short [8][8];
    private static Hashtable __clips = new Hashtable();
    private static short __maxColorPairNumber = - 1;
    private static String __encoding;
    // private static final String JAR_RESOURCE         = "jar:file:";
    // private static final String FILE_RESOURCE        = "file:";
    private static final String LIBRARY_NAME = "jcurses";

    static {
    	List<String> searchPaths = new ArrayList<String>();
    	final String osName = System.getProperty("os.name").toLowerCase();
    	String libExtension = null;
		if (osName.indexOf("linux") >= 0) {
    		libExtension = ".so";
		} else if (osName.indexOf("win") >= 0) {
    		libExtension = ".dll";
		} else if (osName.indexOf("mac") >= 0) {
    		libExtension = ".jnilib"; // TODO not sure
    	}
    	// $PWD/jcurses.so
    	searchPaths.add(System.getProperty("user.dir") + "/" + LIBRARY_NAME + libExtension);
    	// $PWD/libjcurses.so
    	searchPaths.add(System.getProperty("user.dir") + "/lib" + LIBRARY_NAME + libExtension);
    	// $PWD/lib/jcurses.so
    	searchPaths.add(System.getProperty("user.dir") + "/lib/" + LIBRARY_NAME + libExtension);
    	// $PWD/lib/libjcurses.so
    	searchPaths.add(System.getProperty("user.dir") + "/lib/lib" + LIBRARY_NAME + libExtension);

    	// $HOME/jcurses.so
    	searchPaths.add(System.getProperty("user.home") + "/" + LIBRARY_NAME + libExtension);
    	// $HOME/libjcurses.so
    	searchPaths.add(System.getProperty("user.home") + "/lib" + LIBRARY_NAME + libExtension);
    	// $PWD/.local/lib/jcurses.so
    	searchPaths.add(System.getProperty("user.home") + ".local/lib/" + LIBRARY_NAME + libExtension);
    	// $PWD/.local/lib/libjcurses.so
    	searchPaths.add(System.getProperty("user.home") + ".local/lib/lib" + LIBRARY_NAME + libExtension);

    	
    	boolean foundInPath = false;
		for (String sp : searchPaths) {
    		try {
    			System.load(sp);
    			foundInPath = true;
    		} catch (UnsatisfiedLinkError e) {
    			System.out.println("Not found in " + sp);
    		}
    	}
		if (!foundInPath) {
			try {
				System.loadLibrary(LIBRARY_NAME);
			} catch (UnsatisfiedLinkError e) {
				System.out.println("Found Library neither in the default search paths, not in the java.system.path. Stopping");
				System.exit(-1);
			}
		}
        // loadLibrary();
{'fraction_non_alphanumeric': 0.12481557981705518, 'fraction_numerical': 0.007081735025081145, 'mean_word_length': 2.7682045580878265, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, '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': '6489046', 'n_tokens_mistral': 2278, 'n_tokens_neox': 2178, 'n_words': 568}