<commit_before><?php
/*
 * PHP-GTK - The PHP language bindings for GTK+
 *
 * Copyright (C) 2001-2008 <NAME> <<EMAIL>>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

class LineOutput {
    const MAX = 65000;
    protected $filename = null;
    protected $line     = array();
    protected $header = '';
    protected $body = array();
    protected $current = 0;

    function LineOutput($filename)
    {
        $this->body[0] = '';
        $this->filename = $filename;
        $this->line[0] = 0;
    }

    function get_total()
    {
        return count($this->line);
    }

    function get_current()
    {
        return $this->current;
    }

    function set_line($line, $filename)
    {
        if (WIN_OS) {
            $this->write(sprintf("//line %d \"%s\"\n", $line, $filename));
        } else {
            $this->write(sprintf("#line %d \"%s\"\n", $line, $filename));
        }
    }

    function reset_line()
    {
        $this->set_line($this->line[$this->current] + 1, $this->filename);
    }

    function save()
    {
        $files = '';
        foreach($this->body as $id => $data) {
            if ($id == 0) {
                $string = '';
            } else {
                $string =  '-' . $id;
            }
            $filename = substr($this->filename, 0, -2) . $string . '.c';
            $files .= ' ' . basename($filename);
            file_put_contents($filename, $this->header . $this->body[$id]);
        }
        file_put_contents('php://stdout', $files, FILE_APPEND);
    }

    function write($string)
    {
        $this->body[$this->current] .= $string;
        $this->line[$this->current] += substr_count($string, "\n");
    }<commit_msg>fix in the generator for compiling on macos. slightly cheeky, but working for now.<commit_after><?php
/*
 * PHP-GTK - The PHP language bindings for GTK+
 *
 * Copyright (C) 2001-2008 <NAME> <<EMAIL>>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

class LineOutput {
    const MAX = 65000;
    protected $filename = null;
    protected $line     = array();
    protected $header = '';
    protected $body = array();
    protected $current = 0;

    function LineOutput($filename)
    {
        $this->body[0] = '';
        $this->filename = $filename;
        $this->line[0] = 0;
    }

    function get_total()
    {
        return count($this->line);
    }

    function get_current()
    {
        return $this->current;
    }

    function set_line($line, $filename)
    {
        if (WIN_OS) {
            $this->write(sprintf("//line %d \"%s\"\n", $line, $filename));
        } else {
            $this->write(sprintf("#line %d \"%s\"\n", $line, $filename));
        }
    }

    function reset_line()
    {
        $this->set_line($this->line[$this->current] + 1, $this->filename);
    }

    function save()
    {
        $files = '';
        foreach($this->body as $id => $data) {
            if ($id == 0) {
                $string = '';
            } else {
                $string =  '-' . $id;
            }
            $filename = substr($this->filename, 0, -2) . $string . '.c';
            $files .= ' ' . basename($filename);
            
            $header = $this->header;
            
			// this is a cheeky fix for the link sysem failing on MacOS when these
			// files get broken into multiple files.
			// bob - 20100625			
			if(PHP_OS == "Darwin" && $id > 0) {
				$header = preg_replace('/^PHP_GTK_EXPORT_CE\(.+?\);$/ms','',$header);
			}
            
            file_put_contents($filename, $header . $this->body[$id]);
        }
        file_put_contents('php://stdout', $files, FILE_APPEND);
    }

    function write($string)
    {
        $this->body[$this->current] .= $string;
        $this->line[$this->current] += substr_count($string, "\n");
    }
{'fraction_non_alphanumeric': 0.14108767176311204, 'fraction_numerical': 0.016063479775498355, 'mean_word_length': 2.192093885114268, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 50, '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': '4858478', 'n_tokens_mistral': 1595, 'n_tokens_neox': 1493, 'n_words': 481}