History

fixed __LINE__ token type

bellard committed 22 years ago

Commit c50af831 parent ec7d3631 file · +10 −7Browse files

Unified · Split

tcc.c+10−7
@@ -645,7 +645,7 @@ static char tok_two_chars[] = "<=\236>=\235!=\225&&\240||\241++\244--\242==\224< · 644 unmodified lines
645 645
646#define TOK_ASM_int TOK_INT646#define TOK_ASM_int TOK_INT
647 647
648enum {648enum tcc_token {
649 TOK_LAST = TOK_IDENT - 1,649 TOK_LAST = TOK_IDENT - 1,
650#define DEF(id, str) id,650#define DEF(id, str) id,
651#include "tcctok.h"651#include "tcctok.h"
@@ -3808,26 +3808,27 @@ static int macro_subst_tok(TokenString *tok_str, · 3156 unmodified lines
3808 Sym **nested_list, Sym *s, int can_read_stream)3808 Sym **nested_list, Sym *s, int can_read_stream)
3809{3809{
3810 Sym *args, *sa, *sa1;3810 Sym *args, *sa, *sa1;
3811 int mstr_allocated, parlevel, *mstr, t;3811 int mstr_allocated, parlevel, *mstr, t, t1;
3812 TokenString str;3812 TokenString str;
3813 char *cstrval;3813 char *cstrval;
3814 CValue cval;3814 CValue cval;
3815 CString cstr;3815 CString cstr;
3816 char buf[32];
3816 3817
3817 /* if symbol is a macro, prepare substitution */3818 /* if symbol is a macro, prepare substitution */
3818 3819
3819 /* special macros */3820 /* special macros */
3820 if (tok == TOK___LINE__) {3821 if (tok == TOK___LINE__) {
3821 cval.i = file->line_num;3822 snprintf(buf, sizeof(buf), "%d", file->line_num);
3822 tok_str_add2(tok_str, TOK_CINT, &cval);3823 cstrval = buf;
3824 t1 = TOK_PPNUM;
3825 goto add_cstr1;
3823 } else if (tok == TOK___FILE__) {3826 } else if (tok == TOK___FILE__) {
3824 cstrval = file->filename;3827 cstrval = file->filename;
3825 goto add_cstr;3828 goto add_cstr;
3826 tok_str_add2(tok_str, TOK_STR, &cval);
3827 } else if (tok == TOK___DATE__ || tok == TOK___TIME__) {3829 } else if (tok == TOK___DATE__ || tok == TOK___TIME__) {
3828 time_t ti;3830 time_t ti;
3829 struct tm *tm;3831 struct tm *tm;
3830 char buf[64];
3831 3832
3832 time(&ti);3833 time(&ti);
3833 tm = localtime(&ti);3834 tm = localtime(&ti);
@@ -3840,11 +3841,13 @@ static int macro_subst_tok(TokenString *tok_str, · 6 unmodified lines
3840 }3841 }
3841 cstrval = buf;3842 cstrval = buf;
3842 add_cstr:3843 add_cstr:
3844 t1 = TOK_STR;
3845 add_cstr1:
3843 cstr_new(&cstr);3846 cstr_new(&cstr);
3844 cstr_cat(&cstr, cstrval);3847 cstr_cat(&cstr, cstrval);
3845 cstr_ccat(&cstr, '\0');3848 cstr_ccat(&cstr, '\0');
3846 cval.cstr = &cstr;3849 cval.cstr = &cstr;
3847 tok_str_add2(tok_str, TOK_STR, &cval);3850 tok_str_add2(tok_str, t1, &cval);
3848 cstr_free(&cstr);3851 cstr_free(&cstr);
3849 } else {3852 } else {
3850 mstr = (int *)s->c;3853 mstr = (int *)s->c;

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