History

clean '\t'

jiang committed 12 years ago

Commit 07614b51 parent c6345b55 files · +177 −177Browse files

Unified · Split

5 files
  1. libtcc.c +3 −3
  2. tccgen.c +3 −3
  3. tccpp.c +156 −156
  4. tcctok.h +1 −1
  5. tests/tcctest.c +14 −14
libtcc.c+3−3
@@ -879,10 +879,10 @@ static void tcc_cleanup(void) · 878 unmodified lines
879879 /* free tokens */
880880 n = tok_ident - TOK_IDENT;
881881 for(i = 0; i < n; i++){
882− def = &table_ident[i]->sym_define;
883− tcc_free(def->data);
882+ def = &table_ident[i]->sym_define;
883+ tcc_free(def->data);
884884 tcc_free(table_ident[i]);
885− }
885+ }
886886 tcc_free(table_ident);
887887
888888 /* free sym_pools */
tccgen.c+3−3
@@ -5234,13 +5234,13 @@ static void init_putz(CType *t, Section *sec, unsigned long c, int size) · 5233 unmodified lines
52345234 } else {
52355235 vpush_global_sym(&func_old_type, TOK_memset);
52365236 vseti(VT_LOCAL, c);
5237−# ifdef TCC_TARGET_ARM
5237+#ifdef TCC_TARGET_ARM
52385238 vpushs(size);
52395239 vpushi(0);
5240−# else
5240+#else
52415241 vpushi(0);
52425242 vpushs(size);
5243−# endif
5243+#endif
52445244 gfunc_call(3);
52455245 }
52465246 }
tccpp.c+156−156
@@ -1056,7 +1056,7 @@ static int macro_is_equal(const int *a, const int *b) · 1055 unmodified lines
10561056 ST_INLN void define_push(int v, int macro_type, int *str, Sym *first_arg)
10571057 {
10581058 Sym *s;
1059− CSym *def;
1059+ CSym *def;
10601060 s = define_find(v);
10611061 if (s && !macro_is_equal(s->d, str))
10621062 tcc_warning("%s redefined", get_tok_str(v, NULL));
@@ -1064,19 +1064,19 @@ ST_INLN void define_push(int v, int macro_type, int *str, Sym *first_arg) · 1 unmodified line
10641064 s->d = str;
10651065 s->next = first_arg;
10661066 def = &table_ident[v - TOK_IDENT]->sym_define;
1067− def->data[def->off] = s;
1067+ def->data[def->off] = s;
10681068 }
10691069
10701070 /* undefined a define symbol. Its name is just set to zero */
10711071 ST_FUNC void define_undef(Sym *s)
10721072 {
10731073 int v;
1074− CSym *def;
1074+ CSym *def;
10751075 v = s->v - TOK_IDENT;
10761076 if ((unsigned)v < (unsigned)(tok_ident - TOK_IDENT)){
1077− def = &table_ident[v]->sym_define;
1078− def->data[def->off] = NULL;
1079− }
1077+ def = &table_ident[v]->sym_define;
1078+ def->data[def->off] = NULL;
1079+ }
10801080 }
10811081
10821082 ST_INLN Sym *define_find(int v)
@@ -1085,7 +1085,7 @@ ST_INLN Sym *define_find(int v) · 2 unmodified lines
10851085 v -= TOK_IDENT;
10861086 if ((unsigned)v >= (unsigned)(tok_ident - TOK_IDENT))
10871087 return NULL;
1088− def = &table_ident[v]->sym_define;
1088+ def = &table_ident[v]->sym_define;
10891089 return def->data[def->off];
10901090 }
10911091
@@ -1094,7 +1094,7 @@ ST_FUNC void free_defines(Sym *b) · 2 unmodified lines
10941094 {
10951095 Sym *top, *tmp;
10961096 int v;
1097− CSym *def;
1097+ CSym *def;
10981098
10991099 top = define_stack;
11001100 while (top != b) {
@@ -1104,12 +1104,12 @@ ST_FUNC void free_defines(Sym *b) · 3 unmodified lines
11041104 tok_str_free(top->d);
11051105 v = top->v - TOK_IDENT;
11061106 if ((unsigned)v < (unsigned)(tok_ident - TOK_IDENT)){
1107− def = &table_ident[v]->sym_define;
1108− if(def->off)
1109− def->off = 0;
1107+ def = &table_ident[v]->sym_define;
1108+ if(def->off)
1109+ def->off = 0;
11101110 if(def->data[0])
1111− def->data[0] = NULL;
1112− }
1111+ def->data[0] = NULL;
1112+ }
11131113 sym_free(top);
11141114 top = tmp;
11151115 }
@@ -1398,8 +1398,8 @@ read_name: · 282 unmodified lines
13981398 } else
13991399 inp();
14001400 }
1401− if (ch != c)
1402− goto include_syntax;
1401+ if (ch != c)
1402+ goto include_syntax;
14031403 *p = '\0';
14041404 minp();
14051405 #if 0
@@ -1438,8 +1438,8 @@ read_name: · 32 unmodified lines
14381438 c = '>';
14391439 }
14401440 }
1441− if(!buf[0])
1442− tcc_error(" empty filename in #include");
1441+ if(!buf[0])
1442+ tcc_error(" empty filename in #include");
14431443
14441444 if (s1->include_stack_ptr >= s1->include_stack + INCLUDE_STACK_SIZE)
14451445 tcc_error("#include recursion too deep");
@@ -1588,9 +1588,9 @@ skip: · 142 unmodified lines
15881588 file->ifndef_macro = 0;
15891589 tok_flags |= TOK_FLAG_ENDIF;
15901590 }
1591− next_nomacro();
1592− if (tok != TOK_LINEFEED)
1593− tcc_warning("Ignoring: %s", get_tok_str(tok, &tokc));
1591+ next_nomacro();
1592+ if (tok != TOK_LINEFEED)
1593+ tcc_warning("Ignoring: %s", get_tok_str(tok, &tokc));
15941594 break;
15951595 case TOK_LINE:
15961596 next();
@@ -1626,144 +1626,144 @@ skip: · 29 unmodified lines
16261626 tcc_warning("#warning %s", buf);
16271627 break;
16281628 case TOK_PRAGMA:
1629− next();
1630− if (tok == TOK_pack && parse_flags & PARSE_FLAG_PACK) {
1631− /*
1632− This may be:
1633− #pragma pack(1) // set
1634− #pragma pack() // reset to default
1635− #pragma pack(push,1) // push & set
1636− #pragma pack(pop) // restore previous
1637− */
1638− next();
1639− skip('(');
1640− if (tok == TOK_ASM_pop) {
1641− next();
1642− if (s1->pack_stack_ptr <= s1->pack_stack) {
1629+ next();
1630+ if (tok == TOK_pack && parse_flags & PARSE_FLAG_PACK) {
1631+ /*
1632+ This may be:
1633+ #pragma pack(1) // set
1634+ #pragma pack() // reset to default
1635+ #pragma pack(push,1) // push & set
1636+ #pragma pack(pop) // restore previous
1637+ */
1638+ next();
1639+ skip('(');
1640+ if (tok == TOK_ASM_pop) {
1641+ next();
1642+ if (s1->pack_stack_ptr <= s1->pack_stack) {
16431643 stk_error:
1644− tcc_error("out of pack stack");
1645− }
1646− s1->pack_stack_ptr--;
1647− } else {
1648− int val = 0;
1649− if (tok != ')') {
1650− if (tok == TOK_ASM_push) {
1651− next();
1652− s1->pack_stack_ptr++;
1653− if (s1->pack_stack_ptr >= s1->pack_stack + PACK_STACK_SIZE)
1654− goto stk_error;
1655− skip(',');
1656− }
1657− if (tok != TOK_CINT) {
1644+ tcc_error("out of pack stack");
1645+ }
1646+ s1->pack_stack_ptr--;
1647+ } else {
1648+ int val = 0;
1649+ if (tok != ')') {
1650+ if (tok == TOK_ASM_push) {
1651+ next();
1652+ s1->pack_stack_ptr++;
1653+ if (s1->pack_stack_ptr >= s1->pack_stack + PACK_STACK_SIZE)
1654+ goto stk_error;
1655+ skip(',');
1656+ }
1657+ if (tok != TOK_CINT) {
16581658 pack_error:
1659− tcc_error("invalid pack pragma");
1660− }
1661− val = tokc.i;
1662− if (val < 1 || val > 16)
1663− goto pack_error;
1664− if (val < 1 || val > 16)
1665− tcc_error("Value must be greater than 1 is less than or equal to 16");
1666− if ((val & (val - 1)) != 0)
1667− tcc_error("Value must be a power of 2 curtain");
1668− next();
1669− }
1670− *s1->pack_stack_ptr = val;
1671− skip(')');
1672− }
1673− }else if (tok == TOK_PUSH_MACRO || tok == TOK_POP_MACRO) {
1674− TokenSym *ts;
1675− CSym *def;
1676− uint8_t *p1;
1677− int len, t;
1678− t = tok;
1679− ch = file->buf_ptr[0];
1680− skip_spaces();
1681− if (ch != '(')
1682− goto macro_xxx_syntax;
1683− /* XXX: incorrect if comments : use next_nomacro with a special mode */
1684− inp();
1685− skip_spaces();
1686− if (ch == '\"'){
1687− inp();
1688− p = buf;
1689− while (ch != '\"' && ch != '\n' && ch != CH_EOF) {
1690− if ((p - buf) < sizeof(buf) - 1)
1691− *p++ = ch;
1692− if (ch == CH_EOB) {
1693− --p;
1694− handle_stray();
1695− }else
1696− inp();
1697− }
1698− if(ch != '\"')
1699− goto macro_xxx_syntax;
1700− *p = '\0';
1701− minp();
1702− next();
1703− }else{
1704− /* computed #pragma macro_xxx for #define xxx */
1705− next();
1706− buf[0] = '\0';
1707− while (tok != ')') {
1708− if (tok != TOK_STR) {
1709− macro_xxx_syntax:
1710− tcc_error("'macro_xxx' expects (\"NAME\")");
1711− }
1712− pstrcat(buf, sizeof(buf), (char *)tokc.cstr->data);
1713− next();
1714− }
1715− }
1716− skip (')');
1717− if(!buf[0])
1718− tcc_error(" empty string in #pragma");
1719− /* find TokenSym */
1720− p = buf;
1721− while (is_space(*p))
1722− p++;
1723− p1 = p;
1724− for(;;){
1659+ tcc_error("invalid pack pragma");
1660+ }
1661+ val = tokc.i;
1662+ if (val < 1 || val > 16)
1663+ goto pack_error;
1664+ if (val < 1 || val > 16)
1665+ tcc_error("Value must be greater than 1 is less than or equal to 16");
1666+ if ((val & (val - 1)) != 0)
1667+ tcc_error("Value must be a power of 2 curtain");
1668+ next();
1669+ }
1670+ *s1->pack_stack_ptr = val;
1671+ skip(')');
1672+ }
1673+ }else if (tok == TOK_PUSH_MACRO || tok == TOK_POP_MACRO) {
1674+ TokenSym *ts;
1675+ CSym *def;
1676+ uint8_t *p1;
1677+ int len, t;
1678+ t = tok;
1679+ ch = file->buf_ptr[0];
1680+ skip_spaces();
1681+ if (ch != '(')
1682+ goto macro_xxx_syntax;
1683+ /* XXX: incorrect if comments : use next_nomacro with a special mode */
1684+ inp();
1685+ skip_spaces();
1686+ if (ch == '\"'){
1687+ inp();
1688+ p = buf;
1689+ while (ch != '\"' && ch != '\n' && ch != CH_EOF) {
1690+ if ((p - buf) < sizeof(buf) - 1)
1691+ *p++ = ch;
1692+ if (ch == CH_EOB) {
1693+ --p;
1694+ handle_stray();
1695+ }else
1696+ inp();
1697+ }
1698+ if(ch != '\"')
1699+ goto macro_xxx_syntax;
1700+ *p = '\0';
1701+ minp();
1702+ next();
1703+ }else{
1704+ /* computed #pragma macro_xxx for #define xxx */
1705+ next();
1706+ buf[0] = '\0';
1707+ while (tok != ')') {
1708+ if (tok != TOK_STR) {
1709+ macro_xxx_syntax:
1710+ tcc_error("'macro_xxx' expects (\"NAME\")");
1711+ }
1712+ pstrcat(buf, sizeof(buf), (char *)tokc.cstr->data);
1713+ next();
1714+ }
1715+ }
1716+ skip (')');
1717+ if(!buf[0])
1718+ tcc_error(" empty string in #pragma");
1719+ /* find TokenSym */
1720+ p = buf;
1721+ while (is_space(*p))
1722+ p++;
1723+ p1 = p;
1724+ for(;;){
17251725 if (!isidnum_table[p[0] - CH_EOF])
17261726 break;
1727− ++p;
1728− }
1729− len = p - p1;
1730− while (is_space(*p))
1731− p++;
1732− if(!p) //'\0'
1733− tcc_error("unrecognized string: %s", buf);
1734− ts = tok_alloc(p1, len);
1735− if(ts){
1736− def = &ts->sym_define;
1737− if(t == TOK_PUSH_MACRO){
1738− void *tmp = def->data[def->off];
1739− if(tmp){
1740− def->off++;
1741− if(def->off >= def->size){
1742− int size = def->size;
1743− size *= 2;
1744− if (size >= MACRO_STACK_SIZE)
1745− tcc_error("stack full");
1746− def->data = tcc_realloc(def->data, size*sizeof(Sym**));
1747− def->size = size;
1748− }
1749− def->data[def->off] = tmp;
1750− }
1751− }else{
1752− if(def->off){
1753− --def->off;
1754− }else{
1755− tcc_warning("stack empty");
1756− }
1757− }
1758− }
1759− }else{
1760− fputs("#pragma ", s1->ppfp);
1761− while (tok != TOK_LINEFEED){
1762− fputs(get_tok_str(tok, &tokc), s1->ppfp);
1763− next();
1764− }
1765− goto the_end;
1766− }
1727+ ++p;
1728+ }
1729+ len = p - p1;
1730+ while (is_space(*p))
1731+ p++;
1732+ if(!p) //'\0'
1733+ tcc_error("unrecognized string: %s", buf);
1734+ ts = tok_alloc(p1, len);
1735+ if(ts){
1736+ def = &ts->sym_define;
1737+ if(t == TOK_PUSH_MACRO){
1738+ void *tmp = def->data[def->off];
1739+ if(tmp){
1740+ def->off++;
1741+ if(def->off >= def->size){
1742+ int size = def->size;
1743+ size *= 2;
1744+ if (size >= MACRO_STACK_SIZE)
1745+ tcc_error("stack full");
1746+ def->data = tcc_realloc(def->data, size*sizeof(Sym**));
1747+ def->size = size;
1748+ }
1749+ def->data[def->off] = tmp;
1750+ }
1751+ }else{
1752+ if(def->off){
1753+ --def->off;
1754+ }else{
1755+ tcc_warning("stack empty");
1756+ }
1757+ }
1758+ }
1759+ }else{
1760+ fputs("#pragma ", s1->ppfp);
1761+ while (tok != TOK_LINEFEED){
1762+ fputs(get_tok_str(tok, &tokc), s1->ppfp);
1763+ next();
1764+ }
1765+ goto the_end;
1766+ }
17671767 break;
17681768 default:
17691769 if (tok == TOK_LINEFEED || tok == '!' || tok == TOK_PPNUM) {
@@ -3245,8 +3245,8 @@ ST_FUNC int tcc_preprocess(TCCState *s1) · 1475 unmodified lines
32453245 line_ref = 0;
32463246 file_ref = NULL;
32473247 iptr = s1->include_stack_ptr;
3248− tok = TOK_LINEFEED; /* print line */
3249− goto print_line;
3248+ tok = TOK_LINEFEED; /* print line */
3249+ goto print_line;
32503250 for (;;) {
32513251 next();
32523252 if (tok == TOK_EOF) {
tcctok.h+1−1
@@ -139,7 +139,7 @@ · 138 unmodified lines
139139 /* pragma */
140140 DEF(TOK_pack, "pack")
141141 DEF(TOK_PUSH_MACRO, "push_macro")
142− DEF(TOK_POP_MACRO, "pop_macro")
142+ DEF(TOK_POP_MACRO, "pop_macro")
143143 #if !defined(TCC_TARGET_I386) && !defined(TCC_TARGET_X86_64)
144144 /* already defined for assembler */
145145 DEF(TOK_ASM_push, "push")
tests/tcctest.c+14−14
@@ -380,21 +380,21 @@ comment · 379 unmodified lines
380380 comment. */
381381 TEST2 /* the comment */ ();
382382 /* macro_push and macro_pop test */
383− #define MACRO_TEST "macro_test1\n"
384− #pragma push_macro("MACRO_TEST")
385− #undef MACRO_TEST
386− #define MACRO_TEST "macro_test2\n"
387− printf(MACRO_TEST);
388− #pragma pop_macro("MACRO_TEST")
389− printf(MACRO_TEST);
383+ #define MACRO_TEST "macro_test1\n"
384+ #pragma push_macro("MACRO_TEST")
385+ #undef MACRO_TEST
386+ #define MACRO_TEST "macro_test2\n"
387+ printf(MACRO_TEST);
388+ #pragma pop_macro("MACRO_TEST")
389+ printf(MACRO_TEST);
390390 /* gcc does not support
391− #define MACRO_TEST_MACRO "MACRO_TEST"
392− #pragma push_macro(MACRO_TEST_MACRO)
393− #undef MACRO_TEST
394− #define MACRO_TEST "macro_test3\n"
395− printf(MACRO_TEST);
396− #pragma pop_macro(MACRO_TEST_MACRO)
397− printf(MACRO_TEST);
391+ #define MACRO_TEST_MACRO "MACRO_TEST"
392+ #pragma push_macro(MACRO_TEST_MACRO)
393+ #undef MACRO_TEST
394+ #define MACRO_TEST "macro_test3\n"
395+ printf(MACRO_TEST);
396+ #pragma pop_macro(MACRO_TEST_MACRO)
397+ printf(MACRO_TEST);
398398 */
399399 }
400400

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