aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tokenize.c
diff options
context:
space:
mode:
Diffstat (limited to 'tokenize.c')
-rw-r--r--tokenize.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/tokenize.c b/tokenize.c
index d3371e1e..c5ba6e6b 100644
--- a/tokenize.c
+++ b/tokenize.c
@@ -62,6 +62,13 @@ const char *stream_name(int stream)
return input_streams[stream].name;
}
+int stream_prev(int stream)
+{
+ if (stream < 0 || stream > input_stream_nr)
+ return -1;
+ return input_streams[stream].prev;
+}
+
static struct position stream_pos(stream_t *stream)
{
struct position pos;
@@ -300,7 +307,7 @@ int *hash_stream(const char *name)
return input_stream_hashes + hash;
}
-int init_stream(const char *name, int fd, const char **next_path)
+int init_stream(const char *name, int fd, const char **next_path, int prev_stream)
{
int stream = input_stream_nr, *hash;
struct stream *current;
@@ -319,6 +326,7 @@ int init_stream(const char *name, int fd, const char **next_path)
current->next_path = next_path;
current->path = NULL;
current->constant = CONSTANT_FILE_MAYBE;
+ current->prev = prev_stream;
input_stream_nr = stream+1;
hash = hash_stream(name);
current->next_stream = *hash;
@@ -1006,14 +1014,14 @@ struct token * tokenize_buffer(void *buffer, unsigned long size, struct token **
return begin;
}
-struct token * tokenize(const char *name, int fd, struct token *endtoken, const char **next_path)
+struct token * tokenize(const char *name, int fd, int prev_stream, struct token *endtoken, const char **next_path)
{
struct token *begin, *end;
stream_t stream;
unsigned char buffer[BUFSIZE];
int idx;
- idx = init_stream(name, fd, next_path);
+ idx = init_stream(name, fd, next_path, prev_stream);
if (idx < 0) {
// info(endtoken->pos, "File %s is const", name);
return endtoken;