<commit_before>package pty

import (
	"code.google.com/p/go-charset/charset"
	_ "code.google.com/p/go-charset/data"
	"errors"
	"fmt"
	"io"
	"os"
	"syscall"
	"unsafe"
)

type PTY struct {
	Master        *os.File
	MasterEncoded io.WriteCloser
	No            int
	Slave         *os.File
}

// see ioccom.h
const sys_IOCPARM_MASK = 0x1fff

func New() *PTY {
	p, err := os.OpenFile("/dev/ptmx", os.O_RDWR, 0)
	if err != nil {
		fmt.Println("open pty", err)
	}

	sname, err := ptsname(p)
	if err != nil {
		fmt.Println("ptsname", err)
	}

	err = grantpt(p)
	if err != nil {
		fmt.Println("grantpt", err)
	}

	err = unlockpt(p)
	if err != nil {
		fmt.Println("unlockpt", err)
	}

	t, err := os.OpenFile(sname, os.O_RDWR, 0)
	if err != nil {
		fmt.Println("open tty", err)
	}

	masterEncoded, err := charset.NewWriter("ISO-8859-1", p)
	if err != nil {
		fmt.Println("charset err", err)
	}

	pty := &PTY{
		Master:        p,
		Slave:         t,
		No:            0,
		MasterEncoded: masterEncoded,
	}

	return pty<commit_msg>some changes<commit_after>package pty

import (
	"code.google.com/p/go-charset/charset"
	_ "code.google.com/p/go-charset/data"
	"errors"
	"fmt"
	"io"
	"os"
	"syscall"
	"unsafe"
)

type PTY struct {
	Master        *os.File
	MasterEncoded io.WriteCloser
	No            int
	Slave         *os.File
}

// see ioccom.h
const sys_IOCPARM_MASK = 0x1fff

func New(ptsPath string) *PTY {
	pty, err := os.OpenFile(ptsPath+"/ptmx", os.O_RDWR, 0)
	if err != nil {
		fmt.Println("open pty", err)
	}

	sname, err := ptsname(pty)
	if err != nil {
		fmt.Println("ptsname", err)
	}

	err = grantpt(pty)
	if err != nil {
		fmt.Println("grantpt", err)
	}

	err = unlockpt(pty)
	if err != nil {
		fmt.Println("unlockpt", err)
	}

	tty, err := os.OpenFile(sname, os.O_RDWR, 0)
	if err != nil {
		fmt.Println("open tty", err)
	}

	masterEncoded, err := charset.NewWriter("ISO-8859-1", pty)
	if err != nil {
		fmt.Println("charset err", err)
	}

	p := &PTY{
		Master:        pty,
		Slave:         tty,
		No:            0,
		MasterEncoded: masterEncoded,
	}

	return p
{'fraction_non_alphanumeric': 0.16027197668771248, 'fraction_numerical': 0.009713453132588635, 'mean_word_length': 2.6917562724014337, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6221744', 'n_tokens_mistral': 948, 'n_tokens_neox': 889, 'n_words': 193}