diff options
| author | Stefan Eßer <se@FreeBSD.org> | 2022-03-07 22:08:20 +0000 |
|---|---|---|
| committer | Stefan Eßer <se@FreeBSD.org> | 2022-03-07 22:08:20 +0000 |
| commit | 3673adf1ee311d6f83176d3e43cf0efb314764e4 (patch) | |
| tree | e0025bff2224059a1b5a8b538cc8a7cd0a3df637 /include | |
| parent | 4dfc0fa2870c28e6a44c223860375a46e52fdade (diff) | |
Diffstat (limited to 'include')
| -rw-r--r-- | include/lang.h | 1 | ||||
| -rw-r--r-- | include/lex.h | 11 | ||||
| -rw-r--r-- | include/parse.h | 4 | ||||
| -rw-r--r-- | include/status.h | 4 | ||||
| -rw-r--r-- | include/version.h | 2 | ||||
| -rw-r--r-- | include/vm.h | 9 |
6 files changed, 24 insertions, 7 deletions
diff --git a/include/lang.h b/include/lang.h index 09b0d6072806..b7d12b53c7f3 100644 --- a/include/lang.h +++ b/include/lang.h @@ -37,6 +37,7 @@ #define BC_LANG_H #include <stdbool.h> + #if BC_C11 #include <assert.h> #endif // BC_C11 diff --git a/include/lex.h b/include/lex.h index 0e7af1742001..129b9940618f 100644 --- a/include/lex.h +++ b/include/lex.h @@ -491,6 +491,11 @@ typedef struct BcLex { /// if a string or comment are not properly terminated. bool is_stdin; + /// If this is true, the lexer is processing expressions from the + /// command-line and can ask for more data if a string or comment are not + /// properly terminated. + bool is_exprs; + } BcLex; /** @@ -519,8 +524,10 @@ void bc_lex_file(BcLex *l, const char *file); * @param l The lexer. * @param text The text to lex. * @param is_stdin True if the text is from stdin, false otherwise. + * @param is_exprs True if the text is from command-line expressions, false + * otherwise. */ -void bc_lex_text(BcLex *l, const char *text, bool is_stdin); +void bc_lex_text(BcLex *l, const char *text, bool is_stdin, bool is_exprs); /** * Generic next function for the parser to call. It takes care of calling the @@ -579,7 +586,7 @@ void bc_lex_invalidChar(BcLex *l, char c); /** * Reads a line from stdin and puts it into the lexer's buffer. - * @param l The lexer. + * @param l The lexer. */ bool bc_lex_readLine(BcLex *l); diff --git a/include/parse.h b/include/parse.h index 0088c1523ec6..35ca1652fc98 100644 --- a/include/parse.h +++ b/include/parse.h @@ -263,8 +263,10 @@ void bc_parse_pushName(const BcParse* p, char *name, bool var); * @param p The parser. * @param text The text to lex. * @param is_stdin True if the text is from stdin, false otherwise. + * @param is_exprs True if the text is from command-line expressions, false + * otherwise. */ -void bc_parse_text(BcParse *p, const char *text, bool is_stdin); +void bc_parse_text(BcParse *p, const char *text, bool is_stdin, bool is_exprs); // References to const 0 and 1 strings for special cases. bc and dc have // specific instructions for 0 and 1 because they pop up so often and (in the diff --git a/include/status.h b/include/status.h index 993b5e698fb3..df084c70c1b5 100644 --- a/include/status.h +++ b/include/status.h @@ -116,7 +116,7 @@ #endif // BC_DEBUG_CODE // We want to be able to use _Noreturn on C11 compilers. -#if __STDC_VERSION__ >= 201100L +#if __STDC_VERSION__ >= 201112L #include <stdnoreturn.h> #define BC_NORETURN _Noreturn @@ -401,7 +401,7 @@ typedef enum BcErr { /// Void value used in an expression error. BC_ERR_EXEC_VOID_VAL, - // Parse (and lex errors). + // Parse (and lex) errors. /// EOF encountered when not expected error. BC_ERR_PARSE_EOF, diff --git a/include/version.h b/include/version.h index 0c4122528e7d..a7d1640a87a2 100644 --- a/include/version.h +++ b/include/version.h @@ -37,6 +37,6 @@ #define BC_VERSION_H /// The current version. -#define VERSION 5.2.2 +#define VERSION 5.2.3 #endif // BC_VERSION_H diff --git a/include/vm.h b/include/vm.h index 6f69712a804b..cf7eb5238870 100644 --- a/include/vm.h +++ b/include/vm.h @@ -754,13 +754,20 @@ void* bc_vm_realloc(void *ptr, size_t n); char* bc_vm_strdup(const char *str); /** - * Reads a line into BcVm's buffer field. + * Reads a line from stdin into BcVm's buffer field. * @param clear True if the buffer should be cleared first, false otherwise. * @return True if a line was read, false otherwise. */ bool bc_vm_readLine(bool clear); /** + * Reads a line from the command-line expressions into BcVm's buffer field. + * @param clear True if the buffer should be cleared first, false otherwise. + * @return True if a line was read, false otherwise. + */ +bool bc_vm_readBuf(bool clear); + +/** * A convenience and portability function for OpenBSD's pledge(). * @param promises The promises to pledge(). * @param execpromises The exec promises to pledge(). |
