aboutsummaryrefslogtreecommitdiff
path: root/tccpp.c
diff options
context:
space:
mode:
authorgrischka <grischka>2010-11-25 13:29:15 +0100
committergrischka <grischka>2010-11-25 13:29:15 +0100
commite97bf88badfd72676ebdba0b6027370edfb2e584 (patch)
tree2d7428aabda476e8e65cdd78a7c62fa1ae843ea4 /tccpp.c
parentf1c9f649da5b852929e537101edbbaabe99cb90c (diff)
downloadtinycc-e97bf88badfd72676ebdba0b6027370edfb2e584.tar.gz
tinycc-e97bf88badfd72676ebdba0b6027370edfb2e584.tar.bz2
libtcc: new function tcc_open_bf to create BufferedFile
Use it in: - tcc_open - tcc_compile_string - tcc_define_symbol - tcc_assemble_inline
Diffstat (limited to 'tccpp.c')
-rw-r--r--tccpp.c31
1 files changed, 13 insertions, 18 deletions
diff --git a/tccpp.c b/tccpp.c
index 2b735d1..41e6455 100644
--- a/tccpp.c
+++ b/tccpp.c
@@ -1433,10 +1433,9 @@ ST_FUNC void preprocess(int is_bof)
n = s1->nb_include_paths + s1->nb_sysinclude_paths;
for (i = -2; i < n; ++i) {
char buf1[sizeof file->filename];
- BufferedFile *f;
CachedInclude *e;
const char *path;
- int size;
+ int size, fd;
if (i == -2) {
/* check absolute include path */
@@ -1471,21 +1470,21 @@ ST_FUNC void preprocess(int is_bof)
#ifdef INC_DEBUG
printf("%s: skipping %s\n", file->filename, buf);
#endif
- f = NULL;
- } else {
- f = tcc_open(s1, buf1);
- if (!f)
+ fd = 0;
+ } else {
+ fd = tcc_open(s1, buf1);
+ if (fd < 0)
continue;
}
if (tok == TOK_INCLUDE_NEXT) {
tok = TOK_INCLUDE;
- if (f)
- tcc_close(f);
+ if (fd)
+ tcc_close();
continue;
}
- if (!f)
+ if (0 == fd)
goto include_done;
#ifdef INC_DEBUG
@@ -1494,17 +1493,14 @@ ST_FUNC void preprocess(int is_bof)
/* update target deps */
dynarray_add((void ***)&s1->target_deps, &s1->nb_target_deps,
tcc_strdup(buf1));
-
/* XXX: fix current line init */
/* push current file in stack */
- *s1->include_stack_ptr++ = file;
- f->inc_type = c;
- pstrcpy(f->inc_filename, sizeof(f->inc_filename), buf1);
- file = f;
+ *s1->include_stack_ptr++ = file->prev;
+ file->inc_type = c;
+ pstrcpy(file->inc_filename, sizeof(file->inc_filename), buf1);
/* add include file debug info */
- if (s1->do_debug) {
+ if (s1->do_debug)
put_stabs(file->filename, N_BINCL, 0, 0, 0);
- }
tok_flags |= TOK_FLAG_BOF | TOK_FLAG_BOL;
ch = file->buf_ptr[0];
goto the_end;
@@ -2134,9 +2130,8 @@ static inline void next_nomacro1(void)
put_stabd(N_EINCL, 0, 0);
}
/* pop include stack */
- tcc_close(file);
+ tcc_close();
s1->include_stack_ptr--;
- file = *s1->include_stack_ptr;
p = file->buf_ptr;
goto redo_no_start;
}