// reads Stdin only
768362
func (pr *Prompter) getExpressionWithLiner(env *Glisp) (readin string, xs []Sexp, err error) {

	line, err := pr.Getline(nil)
	if err != nil {
		return "", nil, err
	}

	err = UnexpectedEnd
	var x []Sexp

	// parse and pause the parser if we need more input.
	env.parser.ResetAddNewInput(bytes.NewBuffer([]byte(line + "\n")))
	x, err = env.parser.ParseTokens()

	if len(x) > 0 {
		xs = append(xs, x...)
	}

	for err == ErrMoreInputNeeded || err == UnexpectedEnd || err == ResetRequested {
		nextline, err := pr.Getline(&continuationPrompt)
		if err != nil {
			return "", nil, err
		}
		// provide more input
		env.parser.NewInput(bytes.NewBuffer([]byte(nextline + "\n")))

		// get parsed expression tree(s) back in x
		x, err = env.parser.ParseTokens()
		if len(x) > 0 {
			for i := range x {
				if x[i] == SexpEnd {
					P("found an SexpEnd token, omitting it")
					continue
				}
				xs = append(xs, x[i])
			}
		}
		switch err {
		case nil:
			line += "\n" + nextline
			// no problem, parsing went fine.
			return line, xs, nil
		case ResetRequested:
			continue
		case ErrMoreInputNeeded:
			continue
		default:
			return "", nil, fmt.Errorf("Error on line %d: %v\n", env.parser.lexer.Linenum(), err)
		}
	}
	return line, xs, nil
}
1022425
func (v *Buf) Read(p []byte) (n int, err error) {
	if len(p) == 0 {
		return 0, nil
	}
	if v.ptr >= int64(len(*v.buf)) {
		return 0, io.EOF
	}

	n = copy(p, (*v.buf)[v.ptr:])
	v.ptr += int64(n)
	return
}
968129
func (p *PAM) readStream(echo bool) (string, error) {
	reader := bufio.NewReader(p.stdin)
	text, err := reader.ReadString('\n')
	if err != nil {
		return "", trace.Wrap(err)
	}

	return text, nil
}
963408
func getStdinPipe(ctx *cmd.Context) (io.Reader, error) {
	if stdIn, ok := ctx.Stdin.(*os.File); ok && !terminal.IsTerminal(int(stdIn.Fd())) {
		// stdIn from pipe but not terminal
		stat, err := stdIn.Stat()
		if err != nil {
			return nil, err
		}
		content, err := ioutil.ReadAll(stdIn)
		if err != nil {
			return nil, err
		}
		if (stat.Mode()&os.ModeCharDevice) == 0 && len(content) > 0 {
			// workaround to get piped stdIn size because stat.Size() always == 0
			return bytes.NewReader(content), nil
		}
	}
	return nil, nil
}
313349
func (m *Meta) StdinPiped() bool {
	fi, err := wrappedstreams.Stdin().Stat()
	if err != nil {
		// If there is an error, let's just say its not piped
		return false
	}

	return fi.Mode()&os.ModeNamedPipe != 0
}
1077691
func (c *Connection) read() string {
	reply, err := c.bufin.ReadString('\n')

	if err != nil {
		fmt.Println("e ", err)
	}
	return reply
}
1068635
func bufferInput(conn net.Conn, stdin *os.File) {
	rd := bufio.NewReader(conn)
	defer conn.Close()
	for {
		lineIn, err := rd.ReadBytes('\n')
		if len(lineIn) == 0 && err != nil {
			return
		}
		_, err = stdin.Write(lineIn)
		if err != nil {
			return
		}
	}
}
516667
func main() {

	var inputbytes, utf8bytes, outputbytes []byte

	flag.Parse()

	// print help/version/list/usage...
	someSortOfHelp()

	// read input from stdin or file
	inputbytes = getInputBytes()

	// convert inputformat to UTF-8 (decode)
	utf8bytes = getUtf8FromInput(inputbytes)

	// convert UTF-8 to output format (encode)
	outputbytes = convertToDesired(utf8bytes)

	// write output to stdout or file
	writeOutput(outputbytes)

}
477983
func ReadString(r *bufio.Reader) Value {
	ReadWhitespace(r)
	if !ReadStringStart(r) {
		return nil
	}
	result := ReadDataUntil(r, untilFixed('"'))
	if !ReadStringEnd(r) {
		return nil
	}
	return Sstring(result)
}
382212
func readInput(config config, filename *string) (input string, err error) {
	if config.filenameIsCode {
		input, err = *filename, nil
		*filename = "<cmdline>"
	} else if *filename == "-" {
		var bytes []byte
		bytes, err = ioutil.ReadAll(os.Stdin)
		input = string(bytes)
		*filename = "<stdin>"
	} else {
		var bytes []byte
		bytes, err = ioutil.ReadFile(*filename)
		input = string(bytes)
	}
	return
}
94852
func (p *Peeker) Read() *Token {
	token := p.Peek()

	// As a special case, we will produce the EOF token forever once
	// it is reached.
	if token.Type != EOF {
		p.peeked = nil
	}

	return token
}
1296310
func (c *command) StdinPipe() (io.WriteCloser, error) {
	return ioutil.WriteNopCloser(c.conn), nil
}
540204
func TtyTerm() {
	os.Stdin = stdin
	syscall.Stdin = syscall.Handle(os.Stdin.Fd())
	setStdHandle(syscall.STD_INPUT_HANDLE, syscall.Stdin)
}
1218257
func (s *stream) readCommand() (dota.EDemoCommands, error) {
	c, err := s.readVarUint32()
	return dota.EDemoCommands(c), err
}
854183
func ReadString(r Reader) (String, error) {
	var s String
	err := s.ReadFrom(r, UNKNOWN_LEN)
	return s, err
}
373574
func Stdin() *os.File {
	stdin := os.Stdin
	if panicwrap.Wrapped(nil) {
		stdin = wrappedStdin
	}

	return stdin
}
167076
func (r *eofSignal) Read(buf []byte) (int, error) {
	if r.count == 0 {
		if r.eof != nil {
			r.eof <- struct{}{}
			r.eof = nil
		}
		return 0, io.EOF
	}

	max := len(buf)
	if int(r.count) < len(buf) {
		max = int(r.count)
	}
	n, err := r.wrapped.Read(buf[:max])
	r.count -= uint32(n)
	if (err != nil || r.count == 0) && r.eof != nil {
		r.eof <- struct{}{} // tell Peer that msg has been consumed
		r.eof = nil
	}
	return n, err
}