add INCLUDE and INCLUDED

This commit is contained in:
2021-11-22 10:41:55 +01:00
parent d0cead3c42
commit 042a08bcad
10 changed files with 158 additions and 50 deletions
+5 -4
View File
@@ -20,6 +20,7 @@ struct fh_input_spec_s {
fh_input_refill_t refill_input_buffer;
fh_input_free_t free_self;
uint32_t linenum;
char *cwd; // CWD of the input, used for relative includes. malloc'd (strdup)
// saved values, filled when pushing
char saved_buffer[INPUT_BUFFER_SIZE];
@@ -32,17 +33,17 @@ struct fh_input_spec_s {
/**
* Push current input spec and state, replace with new one
*/
void fh_push_input(struct fh_thread_s *fh, struct fh_input_spec_s *newinput);
enum fh_error fh_push_input(struct fh_thread_s *fh, struct fh_input_spec_s *newinput);
/**
* Discard current input spec, restore previous.
* fh->input will be NULL if this was the topmost one
*/
void fh_pop_input(struct fh_thread_s *fh);
enum fh_error fh_pop_input(struct fh_thread_s *fh);
struct fh_input_spec_s *fh_create_input_from_filename(char *path);
struct fh_input_spec_s *fh_create_input_from_filestruct(FILE *f);
struct fh_input_spec_s *fh_create_input_from_string(char *str, size_t len);
struct fh_input_spec_s *fh_create_input_from_filestruct(FILE *f, const char *path);
struct fh_input_spec_s *fh_create_input_from_string(char *str, size_t len, const char *cwd); // cwd is strduped.
void fh_input_teardown(struct fh_thread_s *fh);
#endif //FORTH_FH_INPUT_H
+2
View File
@@ -17,6 +17,8 @@
#include <stdlib.h>
#include <stddef.h>
#include <inttypes.h>
#include <unistd.h>
#include <linux/limits.h> // PATH_MAX
#include "fh_config.h"
#include "fh_error.h"