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
645645
646646 #define TOK_ASM_int TOK_INT
647647
648−enum {
648+enum tcc_token {
649649 TOK_LAST = TOK_IDENT - 1,
650650 #define DEF(id, str) id,
651651 #include "tcctok.h"
@@ -3808,26 +3808,27 @@ static int macro_subst_tok(TokenString *tok_str, · 3156 unmodified lines
38083808 Sym **nested_list, Sym *s, int can_read_stream)
38093809 {
38103810 Sym *args, *sa, *sa1;
3811− int mstr_allocated, parlevel, *mstr, t;
3811+ int mstr_allocated, parlevel, *mstr, t, t1;
38123812 TokenString str;
38133813 char *cstrval;
38143814 CValue cval;
38153815 CString cstr;
3816+ char buf[32];
38163817
38173818 /* if symbol is a macro, prepare substitution */
38183819
38193820 /* special macros */
38203821 if (tok == TOK___LINE__) {
3821− cval.i = file->line_num;
3822− tok_str_add2(tok_str, TOK_CINT, &cval);
3822+ snprintf(buf, sizeof(buf), "%d", file->line_num);
3823+ cstrval = buf;
3824+ t1 = TOK_PPNUM;
3825+ goto add_cstr1;
38233826 } else if (tok == TOK___FILE__) {
38243827 cstrval = file->filename;
38253828 goto add_cstr;
3826− tok_str_add2(tok_str, TOK_STR, &cval);
38273829 } else if (tok == TOK___DATE__ || tok == TOK___TIME__) {
38283830 time_t ti;
38293831 struct tm *tm;
3830− char buf[64];
38313832
38323833 time(&ti);
38333834 tm = localtime(&ti);
@@ -3840,11 +3841,13 @@ static int macro_subst_tok(TokenString *tok_str, · 6 unmodified lines
38403841 }
38413842 cstrval = buf;
38423843 add_cstr:
3844+ t1 = TOK_STR;
3845+ add_cstr1:
38433846 cstr_new(&cstr);
38443847 cstr_cat(&cstr, cstrval);
38453848 cstr_ccat(&cstr, '\0');
38463849 cval.cstr = &cstr;
3847− tok_str_add2(tok_str, TOK_STR, &cval);
3850+ tok_str_add2(tok_str, t1, &cval);
38483851 cstr_free(&cstr);
38493852 } else {
38503853 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