| @@ -1056,7 +1056,7 @@ static int macro_is_equal(const int *a, const int *b) · 1055 unmodified lines |
| 1056 | 1056 | ST_INLN void define_push(int v, int macro_type, int *str, Sym *first_arg) |
| 1057 | 1057 | { |
| 1058 | 1058 | Sym *s; |
| 1059 | | − CSym *def; |
| 1059 | + CSym *def; |
| 1060 | 1060 | s = define_find(v); |
| 1061 | 1061 | if (s && !macro_is_equal(s->d, str)) |
| 1062 | 1062 | 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 |
| 1064 | 1064 | s->d = str; |
| 1065 | 1065 | s->next = first_arg; |
| 1066 | 1066 | def = &table_ident[v - TOK_IDENT]->sym_define; |
| 1067 | | − def->data[def->off] = s; |
| 1067 | + def->data[def->off] = s; |
| 1068 | 1068 | } |
| 1069 | 1069 | |
| 1070 | 1070 | /* undefined a define symbol. Its name is just set to zero */ |
| 1071 | 1071 | ST_FUNC void define_undef(Sym *s) |
| 1072 | 1072 | { |
| 1073 | 1073 | int v; |
| 1074 | | − CSym *def; |
| 1074 | + CSym *def; |
| 1075 | 1075 | v = s->v - TOK_IDENT; |
| 1076 | 1076 | 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 | + } |
| 1080 | 1080 | } |
| 1081 | 1081 | |
| 1082 | 1082 | ST_INLN Sym *define_find(int v) |
| @@ -1085,7 +1085,7 @@ ST_INLN Sym *define_find(int v) · 2 unmodified lines |
| 1085 | 1085 | v -= TOK_IDENT; |
| 1086 | 1086 | if ((unsigned)v >= (unsigned)(tok_ident - TOK_IDENT)) |
| 1087 | 1087 | return NULL; |
| 1088 | | − def = &table_ident[v]->sym_define; |
| 1088 | + def = &table_ident[v]->sym_define; |
| 1089 | 1089 | return def->data[def->off]; |
| 1090 | 1090 | } |
| 1091 | 1091 | |
| @@ -1094,7 +1094,7 @@ ST_FUNC void free_defines(Sym *b) · 2 unmodified lines |
| 1094 | 1094 | { |
| 1095 | 1095 | Sym *top, *tmp; |
| 1096 | 1096 | int v; |
| 1097 | | − CSym *def; |
| 1097 | + CSym *def; |
| 1098 | 1098 | |
| 1099 | 1099 | top = define_stack; |
| 1100 | 1100 | while (top != b) { |
| @@ -1104,12 +1104,12 @@ ST_FUNC void free_defines(Sym *b) · 3 unmodified lines |
| 1104 | 1104 | tok_str_free(top->d); |
| 1105 | 1105 | v = top->v - TOK_IDENT; |
| 1106 | 1106 | 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; |
| 1110 | 1110 | if(def->data[0]) |
| 1111 | | − def->data[0] = NULL; |
| 1112 | | − } |
| 1111 | + def->data[0] = NULL; |
| 1112 | + } |
| 1113 | 1113 | sym_free(top); |
| 1114 | 1114 | top = tmp; |
| 1115 | 1115 | } |
| @@ -1398,8 +1398,8 @@ read_name: · 282 unmodified lines |
| 1398 | 1398 | } else |
| 1399 | 1399 | inp(); |
| 1400 | 1400 | } |
| 1401 | | − if (ch != c) |
| 1402 | | − goto include_syntax; |
| 1401 | + if (ch != c) |
| 1402 | + goto include_syntax; |
| 1403 | 1403 | *p = '\0'; |
| 1404 | 1404 | minp(); |
| 1405 | 1405 | #if 0 |
| @@ -1438,8 +1438,8 @@ read_name: · 32 unmodified lines |
| 1438 | 1438 | c = '>'; |
| 1439 | 1439 | } |
| 1440 | 1440 | } |
| 1441 | | − if(!buf[0]) |
| 1442 | | − tcc_error(" empty filename in #include"); |
| 1441 | + if(!buf[0]) |
| 1442 | + tcc_error(" empty filename in #include"); |
| 1443 | 1443 | |
| 1444 | 1444 | if (s1->include_stack_ptr >= s1->include_stack + INCLUDE_STACK_SIZE) |
| 1445 | 1445 | tcc_error("#include recursion too deep"); |
| @@ -1588,9 +1588,9 @@ skip: · 142 unmodified lines |
| 1588 | 1588 | file->ifndef_macro = 0; |
| 1589 | 1589 | tok_flags |= TOK_FLAG_ENDIF; |
| 1590 | 1590 | } |
| 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)); |
| 1594 | 1594 | break; |
| 1595 | 1595 | case TOK_LINE: |
| 1596 | 1596 | next(); |
| @@ -1626,144 +1626,144 @@ skip: · 29 unmodified lines |
| 1626 | 1626 | tcc_warning("#warning %s", buf); |
| 1627 | 1627 | break; |
| 1628 | 1628 | 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) { |
| 1643 | 1643 | 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) { |
| 1658 | 1658 | 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(;;){ |
| 1725 | 1725 | if (!isidnum_table[p[0] - CH_EOF]) |
| 1726 | 1726 | 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 | + } |
| 1767 | 1767 | break; |
| 1768 | 1768 | default: |
| 1769 | 1769 | if (tok == TOK_LINEFEED || tok == '!' || tok == TOK_PPNUM) { |
| @@ -3245,8 +3245,8 @@ ST_FUNC int tcc_preprocess(TCCState *s1) · 1475 unmodified lines |
| 3245 | 3245 | line_ref = 0; |
| 3246 | 3246 | file_ref = NULL; |
| 3247 | 3247 | 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; |
| 3250 | 3250 | for (;;) { |
| 3251 | 3251 | next(); |
| 3252 | 3252 | if (tok == TOK_EOF) { |