History

use CH_EOB

bellard committed 23 years ago

Commit 2f219d81 parent 63965fc1 file · +16 −4Browse files

Unified · Split

tcc.c+16−4
@@ -1150,7 +1150,8 @@ TokenSym *tok_alloc(const char *str, int len) · 1149 unmodified lines
1150 ts->sym_identifier = NULL;1150 ts->sym_identifier = NULL;
1151 ts->len = len;1151 ts->len = len;
1152 ts->hash_next = NULL;1152 ts->hash_next = NULL;
1153 memcpy(ts->str, str, len + 1);1153 memcpy(ts->str, str, len);
1154 ts->str[len] = '\0';
1154 *pts = ts;1155 *pts = ts;
1155 return ts;1156 return ts;
1156}1157}
@@ -7557,24 +7558,35 @@ static int tcc_compile(TCCState *s1) · 6400 unmodified lines
7557 return s1->nb_errors != 0 ? -1 : 0;7558 return s1->nb_errors != 0 ? -1 : 0;
7558}7559}
7559 7560
7561#ifdef LIBTCC
7560int tcc_compile_string(TCCState *s, const char *str)7562int tcc_compile_string(TCCState *s, const char *str)
7561{7563{
7562 BufferedFile bf1, *bf = &bf1;7564 BufferedFile bf1, *bf = &bf1;
7563 int ret;7565 int ret, len;
7566 char *buf;
7564 7567
7565 /* init file structure */7568 /* init file structure */
7566 bf->fd = -1;7569 bf->fd = -1;
7567 bf->buf_ptr = (char *)str;7570 /* XXX: avoid copying */
7568 bf->buf_end = (char *)str + strlen(bf->buffer);7571 len = strlen(str);
7572 buf = tcc_malloc(len + 1);
7573 if (!buf)
7574 return -1;
7575 buf[len] = CH_EOB;
7576 bf->buf_ptr = buf;
7577 bf->buf_end = buf + len;
7569 pstrcpy(bf->filename, sizeof(bf->filename), "<string>");7578 pstrcpy(bf->filename, sizeof(bf->filename), "<string>");
7570 bf->line_num = 1;7579 bf->line_num = 1;
7571 file = bf;7580 file = bf;
7572 7581
7573 ret = tcc_compile(s);7582 ret = tcc_compile(s);
7574 7583
7584 tcc_free(buf);
7585
7575 /* currently, no need to close */7586 /* currently, no need to close */
7576 return ret;7587 return ret;
7577}7588}
7589#endif
7578 7590
7579/* define a preprocessor symbol. A value can also be provided with the '=' operator */7591/* define a preprocessor symbol. A value can also be provided with the '=' operator */
7580void tcc_define_symbol(TCCState *s1, const char *sym, const char *value)7592void tcc_define_symbol(TCCState *s1, const char *sym, const char *value)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t