coan 4.2.4
|
![]() |
Modules | |
Macro-generated code | |
Files | |
file | io.c |
file | io.h |
Defines | |
#define | STDIN_NAME "[stdin]" |
#define | LINE_START GET_PUBLIC(io,line_start) |
#define | LINE_END (GET_PUBLIC(io,line_start) + GET_PUBLIC(io,line_len)) |
#define | LINE_OFF(addr) (addr - LINE_START) |
#define | INSOURCE (GET_PUBLIC(io,line_num) != 0) |
Functions | |
char * | read_filename (void) |
FILE * | open_file (const char *file, const char *mode) |
void | open_io (char const *filename) |
void | close_io (int error) |
void | close_input (void) |
bool | get_line (void) |
char * | read_more (char const *readpos) |
bool | input_opened (void) |
void | ensure_buf (size_t extra) |
void | save_read_pos (char const *cp) |
char * | saved_read_pos (void) |
void | io_toplevel (void) |
size_t | read_offset (char const *readpos) |
char * | read_pos (size_t readoff) |
#define INSOURCE (GET_PUBLIC(io,line_num) != 0) |
To test whether parsing source text or commandline
Definition at line 63 of file io.h.
Referenced by configured_symbol_add(), configured_symbol_match_const(), dropping_line(), get_line(), symbol_define(), symbol_evaluate_status(), and symbol_undefine().
#define LINE_END (GET_PUBLIC(io,line_start) + GET_PUBLIC(io,line_len)) |
The start of the current line buffer
Definition at line 57 of file io.h.
Referenced by get_line(), readon(), and tail_edit().
#define LINE_OFF | ( | addr | ) | (addr - LINE_START) |
The offset of an address in the current line buffer
Definition at line 60 of file io.h.
Referenced by eval_table(), and eval_unary().
#define LINE_START GET_PUBLIC(io,line_start) |
The start of the current line buffer
Definition at line 54 of file io.h.
Referenced by delete_paren(), get_line(), printline_commented_out(), printline_cut(), read_offset(), read_pos(), restore_paren(), tail_edit(), and truncate_line().
#define STDIN_NAME "[stdin]" |
Nominal filename for the standard input stream
Definition at line 51 of file io.h.
Referenced by node_proc(), and open_io().
void close_input | ( | void | ) |
Close the current source file.
void close_io | ( | int | error | ) |
Finalise the current pairing of source input and processed output, if any.
error | 0 if no errors were raised in processing the input file that is to be closed, else the issue code of the error that aborted processing. |
If a file is associated with either of these streams, it is closed. The output file replaces the input file, if error
== 0 and the --replace
option is in force, and is also backed up beforehand, if the --backup
option is in force. If the function is called before any input has been opened it is a NOOP.
Definition at line 355 of file io.c.
References backup_infile(), delete_infile(), exitcode(), GET_PUBLIC, GET_STATE, io_toplevel(), replace_infile(), SET_PUBLIC, and SET_STATE.
Referenced by node_proc().
void ensure_buf | ( | size_t | extra | ) |
Ensure additional capacity in the input line-buffer.
extra | The number of additional bytes to ensure. The function will extend the line buffer as necessary to ensure that extra bytes are available. |
Definition at line 457 of file io.c.
References GET_PUBLIC, GET_STATE, line_len(), reallocate(), SET_PUBLIC, and SET_STATE.
Referenced by tail_edit().
bool get_line | ( | void | ) |
Try to read a line of input from the current source file.
Definition at line 404 of file io.c.
References clone(), extend_line(), GET_PUBLIC, GRIPE_MISSING_EOF_NEWLINE, INSOURCE, LINE_END, line_len(), LINE_START, report(), and SET_PUBLIC.
Referenced by eval_line().
bool input_opened | ( | void | ) |
void io_toplevel | ( | void | ) |
Reset the input filename to NULL and line number to 0
Definition at line 491 of file io.c.
References SET_PUBLIC.
Referenced by close_io(), exit_diagnostics(), and node_proc().
FILE* open_file | ( | const char * | file, |
const char * | mode | ||
) |
Open a named file for reading or writing
file | The name of the file to be opened |
mode | The read or write mode in which to open the file, "r" or "w" . |
Definition at line 344 of file io.c.
References bail(), and GRIPE_CANT_OPEN_INPUT.
Referenced by open_io(), open_output(), and parse_args_file().
void open_io | ( | char const * | filename | ) |
Open an input file and the appropriate output file.
filename | The name of the input file to open. An empty string, "", denotes the standard input |
Definition at line 390 of file io.c.
References configured_symbols_rewind(), GET_PUBLIC, open_file(), open_output(), SET_PUBLIC, SET_STATE, and STDIN_NAME.
Referenced by node_proc().
char* read_filename | ( | void | ) |
Read the name of a source file from stdin
. Filenames may contain spaces if quoted.
Definition at line 149 of file io.c.
References bail(), GET_STATE, GRIPE_EOF_IN_FILENAME, GRIPE_FILENAME_TOO_LONG, GRIPE_ILLEGAL_FILENAME, SET_STATE, and zallocate().
Referenced by finish_args().
char* read_more | ( | char const * | readpos | ) |
Read another line of input from the current source file to extend the current line when a line-continuation is found or when a newline is read within a C-comment.
readpos | The current text pointer in the line buffer. |
The function assumes that more input is available. If not an unexpected eof error is raised.
Definition at line 432 of file io.c.
References early_eof(), extend_line(), save_read_pos(), and saved_read_pos().
Referenced by chew_continuation(), and chew_on().
size_t read_offset | ( | char const * | readpos | ) |
Get the offset of an address in the input line buffer
Definition at line 443 of file io.c.
References LINE_START.
Referenced by canonical_string_parse_next_part(), chew_string(), chew_unbroken_string(), and eval_line().
char* read_pos | ( | size_t | readoff | ) |
Get the address of an ofset into the input line buffer
Definition at line 450 of file io.c.
References LINE_START.
Referenced by canonical_string_parse_next_part(), chew_string(), chew_unbroken_string(), and eval_line().
void save_read_pos | ( | char const * | cp | ) |
Save the current line buffer position.
cp | The current line buffer position. |
The position is saved as an offset into the line buffer so that the correct position can be recovered is the line buffer is moved.
Definition at line 479 of file io.c.
References GET_PUBLIC, saved_read_pos(), and SET_STATE.
Referenced by read_more().
char* saved_read_pos | ( | void | ) |
Get the last saved line buffer position.
The returned position equates to the last position saved even if the line buffer has moved in the interim.
Definition at line 485 of file io.c.
References GET_PUBLIC, GET_STATE, and saved_read_pos().
Referenced by read_more(), save_read_pos(), and saved_read_pos().