<commit_before>// +build windows

package isatty

import (
    "os"
    "syscall"
    "unsafe"
)

var (
    kernel32        = syscall.MustLoadDLL("kernel32.dll")
    fGetConsoleMode = kernel32.MustFindProc("GetConsoleMode")
)

func Isatty(file *os.File) bool {
    var x uint32
    return getConsoleMode(syscall.Handle(file.Fd()), &x) == nil
}

func getConsoleMode(hConsoleHandle syscall.Handle, lpMode *uint32) error {
    ret, _, err := syscall.Syscall(fGetConsoleMode.Addr(), 2,
        uintptr(hConsoleHandle),
        uintptr(unsafe.Pointer(lpMode)),
        0)

    if int(ret) == 0 {
        if err != 0 {
            return error(err)
        } else {
            return syscall.EINVAL
        }
    }
    return
}<commit_msg>Fix on Windows<commit_after>// +build windows

package isatty

import (
    "os"
    "syscall"
    "unsafe"
)

var (
    kernel32        = syscall.MustLoadDLL("kernel32.dll")
    fGetConsoleMode = kernel32.MustFindProc("GetConsoleMode")
)

func Isatty(file *os.File) bool {
    var x uint32
    return getConsoleMode(syscall.Handle(file.Fd()), &x) == nil
}

func getConsoleMode(hConsoleHandle syscall.Handle, lpMode *uint32) error {
    ret, _, err := syscall.Syscall(fGetConsoleMode.Addr(), 2,
        uintptr(hConsoleHandle),
        uintptr(unsafe.Pointer(lpMode)),
        0)

    if int(ret) == 0 {
        if err != 0 {
            return error(err)
        } else {
            return syscall.EINVAL
        }
    }
    return nil
}
{'fraction_non_alphanumeric': 0.12219959266802444, 'fraction_numerical': 0.019008825526137134, 'mean_word_length': 2.44392523364486, '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': '7202477', 'n_tokens_mistral': 532, 'n_tokens_neox': 476, 'n_words': 103}