![]() | Fun 0.41.5 The programming language that makes You have fun |
Implements the OP_INPUT_LINE opcode for interactive console input. More...

Go to the source code of this file.
Functions | |
| if (has_prompt) | |
| if (hidden) | |
| if (!buf) | |
| while ((ch=fgetc(stdin)) !=EOF) | |
| if (len+1 >=cap) | |
| push_value (vm, make_string(buf)) | |
| free (buf) | |
| if (tcgetattr(STDIN_FILENO, &t)==0) | |
Variables | |
| case | OP_INPUT_LINE |
| int | hidden = (inst.operand & 2) ? 1 : 0 |
| int | echo_disabled = 0 |
| size_t | cap = 128 |
| size_t | len = 0 |
| char * | buf = (char *)malloc(cap) |
| int | ch |
| push_done | __pad0__ |
| restore_echo_and_break | __pad1__ |
Implements the OP_INPUT_LINE opcode for interactive console input.
This snippet handles the OP_INPUT_LINE instruction in the VM dispatch. It can optionally print a prompt (taken from the stack) and can read input in a hidden mode (terminal echo disabled) suitable for passwords.
Operand bits (inst.operand):
Stack effects:
Behavior:
Errors and corner cases:
Example: // Bytecode: [optional PUSH prompt], OP_INPUT_LINE(operand) // operand bit0=1 (has prompt), bit1=2 (hidden) can be combined // Stack before (bit0=1): ["Enter password: "] // Stack after: ["user-typed-line"]
Definition in file input_line.c.
| free | ( | buf | ) |

| if | ( | ! | buf | ) |
| if | ( | has_prompt | ) |
| if | ( | hidden | ) |
Definition at line 87 of file input_line.c.
| if | ( | len+1 >= | cap | ) |
| if | ( | tcgetattr(STDIN_FILENO, &t) | = = 0 | ) |
Definition at line 176 of file input_line.c.
| push_value | ( | vm | , |
| make_string(buf) | ) |

| while | ( | (ch=fgetc(stdin)) ! | = EOF | ) |
| push_done __pad0__ |
Definition at line 155 of file input_line.c.
| restore_echo_and_break __pad1__ |
Definition at line 186 of file input_line.c.
Definition at line 103 of file input_line.c.
| size_t cap = 128 |
Definition at line 101 of file input_line.c.
| int ch |
Definition at line 111 of file input_line.c.
| int echo_disabled = 0 |
Definition at line 72 of file input_line.c.
| int hidden = (inst.operand & 2) ? 1 : 0 |
Definition at line 58 of file input_line.c.
| size_t len = 0 |
Definition at line 102 of file input_line.c.
| case OP_INPUT_LINE |
Definition at line 52 of file input_line.c.