57 int has_prompt = (inst.operand & 1) ? 1 : 0;
58 int hidden = (inst.operand & 2) ? 1 : 0;
61 Value pv = pop_value(vm);
75 HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
76 if (hStdin != INVALID_HANDLE_VALUE) {
78 if (GetConsoleMode(hStdin, &mode)) {
79 DWORD newMode = mode & ~(ENABLE_ECHO_INPUT);
80 if (SetConsoleMode(hStdin, newMode)) {
90 if (tcgetattr(STDIN_FILENO, &oldt) == 0) {
91 struct termios newt = oldt;
92 newt.c_lflag &= ~(ECHO);
93 if (tcsetattr(STDIN_FILENO, TCSANOW, &newt) == 0) {
105 fprintf(stderr,
"Runtime error: out of memory reading input");
108 goto restore_echo_and_break;
112 while ((
ch = fgetc(stdin)) != EOF) {
115 int next = fgetc(stdin);
116 if (next != EOF && next !=
'\n') {
126 char *nb = (
char *)realloc(
buf,
cap);
129 fprintf(stderr,
"Runtime error: out of memory reading input");
140 char *nb = (
char *)realloc(
buf,
len + 1);
143 fprintf(stderr,
"Runtime error: out of memory finalizing input");
159 HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
160 if (hStdin != INVALID_HANDLE_VALUE) {
162 if (GetConsoleMode(hStdin, &mode)) {
164 mode |= ENABLE_ECHO_INPUT;
165 SetConsoleMode(hStdin, mode);
176 if (tcgetattr(STDIN_FILENO, &
t) == 0) {
178 tcsetattr(STDIN_FILENO, TCSANOW, &
t);
186restore_echo_and_break:
Tagged union representing a Fun value.
Value make_string(const char *s)
Construct a string Value by duplicating the given C string.
void free_value(Value v)
Free dynamic storage owned by a Value.
char * value_to_string_alloc(const Value *v)
Allocate a printable C string for a Value.