libtcc: new LIBTCCAPI tcc_set_options(TCCState*, const char*str)

This replaces       -> use instead:
-----------------------------------
- tcc_set_linker    -> tcc_set_options(s, "-Wl,...");
- tcc_set_warning   -> tcc_set_options(s, "-W...");
- tcc_enable_debug  -> tcc_set_options(s, "-g");

parse_args is moved to libtcc.c (now tcc_parse_args).

Also some cleanups:
- reorder TCCState members
- add some comments here and there
- do not use argv's directly, make string copies
- use const char* in tcc_set_linker
- tccpe: use fd instead of fp

tested with -D MEM_DEBUG: 0 bytes left
This commit is contained in:
grischka
2013-02-12 19:13:28 +01:00
parent 829655949b
commit 05108a3b0a
12 changed files with 909 additions and 987 deletions

18
tccpp.c
View File

@ -118,7 +118,7 @@ static void cstr_realloc(CString *cstr, int new_size)
}
/* add a byte */
PUB_FUNC void cstr_ccat(CString *cstr, int ch)
ST_FUNC void cstr_ccat(CString *cstr, int ch)
{
int size;
size = cstr->size + 1;
@ -128,7 +128,7 @@ PUB_FUNC void cstr_ccat(CString *cstr, int ch)
cstr->size = size;
}
PUB_FUNC void cstr_cat(CString *cstr, const char *str)
ST_FUNC void cstr_cat(CString *cstr, const char *str)
{
int c;
for(;;) {
@ -141,7 +141,7 @@ PUB_FUNC void cstr_cat(CString *cstr, const char *str)
}
/* add a wide char */
PUB_FUNC void cstr_wccat(CString *cstr, int ch)
ST_FUNC void cstr_wccat(CString *cstr, int ch)
{
int size;
size = cstr->size + sizeof(nwchar_t);
@ -151,20 +151,20 @@ PUB_FUNC void cstr_wccat(CString *cstr, int ch)
cstr->size = size;
}
PUB_FUNC void cstr_new(CString *cstr)
ST_FUNC void cstr_new(CString *cstr)
{
memset(cstr, 0, sizeof(CString));
}
/* free string and reset it to NULL */
PUB_FUNC void cstr_free(CString *cstr)
ST_FUNC void cstr_free(CString *cstr)
{
tcc_free(cstr->data_allocated);
cstr_new(cstr);
}
/* reset string to empty */
PUB_FUNC void cstr_reset(CString *cstr)
ST_FUNC void cstr_reset(CString *cstr)
{
cstr->size = 0;
}
@ -3112,17 +3112,17 @@ print_line:
: ""
;
iptr = iptr_new;
fprintf(s1->outfile, "# %d \"%s\"%s\n", file->line_num, file->filename, s);
fprintf(s1->ppfp, "# %d \"%s\"%s\n", file->line_num, file->filename, s);
} else {
while (d)
fputs("\n", s1->outfile), --d;
fputs("\n", s1->ppfp), --d;
}
line_ref = (file_ref = file)->line_num;
token_seen = tok != TOK_LINEFEED;
if (!token_seen)
continue;
}
fputs(get_tok_str(tok, &tokc), s1->outfile);
fputs(get_tok_str(tok, &tokc), s1->ppfp);
}
free_defines(define_start);
return 0;