<commit_before>package com.github.to2mbn.jmccc.exec;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.Arrays;
import java.util.Collection;
import com.github.to2mbn.jmccc.util.OsTypes;

public class LoggingMonitor extends ProcessMonitor {

    private class LogMonitor implements Runnable {

        /**
         * False for stdout, true for stderr
         */
        private boolean isErr;
        private InputStream in;

        public LogMonitor(boolean isErr, InputStream in) {
            this.isErr = isErr;
            this.in = in;
        }

        @Override
        public void run() {
            char[] eol = OsTypes.getLineSpearator().toCharArray();
            try {
                // no need for close this
                // because we don't need to close the base stream
                Reader reader = new InputStreamReader(in);

                StringBuilder buffer = new StringBuilder();
                int ch;
                while ((ch = reader.read()) != -1) {
                    buffer.append((char) ch);

                    // check eol
                    boolean isEOL = true;
                    for (int i = 0; i < eol.length; i++) {
                        if (eol[i] != buffer.charAt(buffer.length() - 1 - i)) {
                            isEOL = false;
                            break;
                        }
                    }

                    if (isEOL) {
                        buffer.delete(buffer.length() - eol.length, buffer.length());
                        String log = buffer.toString();
                        buffer.delete(0, buffer.length());
                        if (isErr) {
                            listener.onErrorLog(log);
                        } else {
                            listener.onLog(log);
                        }
                    }

                    if (Thread.interrupted()) {
                        return;
                    }
                }<commit_msg>fix line spliting invalid on windows<commit_after>package com.github.to2mbn.jmccc.exec;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.Arrays;
import java.util.Collection;
import com.github.to2mbn.jmccc.util.OsTypes;

public class LoggingMonitor extends ProcessMonitor {

    private class LogMonitor implements Runnable {

        /**
         * False for stdout, true for stderr
         */
        private boolean isErr;
        private InputStream in;

        public LogMonitor(boolean isErr, InputStream in) {
            this.isErr = isErr;
            this.in = in;
        }

        @Override
        public void run() {
            char[] eol = OsTypes.getLineSpearator().toCharArray();
            try {
                // no need for close this
                // because we don't need to close the base stream
                Reader reader = new InputStreamReader(in);

                StringBuilder buffer = new StringBuilder();
                int ch;
                while ((ch = reader.read()) != -1) {
                    buffer.append((char) ch);

                    if (buffer.length() >= eol.length) {
                        // check eol
                        boolean isEOL = true;
                        for (int i = 0; i < eol.length; i++) {
                            if (eol[i] != buffer.charAt(buffer.length() - eol.length + i)) {
                                isEOL = false;
                                break;
                            }
                        }

                        if (isEOL) {
                            buffer.delete(buffer.length() - eol.length, buffer.length());
                            String log = buffer.toString();
                            buffer.delete(0, buffer.length());
                            if (isErr) {
                                listener.onErrorLog(log);
                            } else {
                                listener.onLog(log);
                            }
                        }
                    }

                    if (Thread.interrupted()) {
                        return;
                    }
                }
{'fraction_non_alphanumeric': 0.0905686871050784, 'fraction_numerical': 0.0025743037678446056, 'mean_word_length': 1.0647342995169082, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, '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': '6344946', 'n_tokens_mistral': 1067, 'n_tokens_neox': 990, 'n_words': 254}