| @@ -1772,22 +1772,40 @@ static void minp(void) · 1771 unmodified lines |
| 1772 | 1772 | } |
| 1773 | 1773 | |
| 1774 | 1774 | |
| 1775 | | −static void parse_line_comment(void) |
| 1775 | +/* single line C++ comments */ |
| 1776 | +static uint8_t *parse_line_comment(uint8_t *p) |
| 1776 | 1777 | { |
| 1777 | | − /* single line C++ comments */ |
| 1778 | | − /* XXX: accept '\\\n' ? */ |
| 1779 | | − inp(); |
| 1780 | | − while (ch != '\n' && ch != CH_EOF) |
| 1781 | | − inp(); |
| 1778 | + int c; |
| 1779 | + |
| 1780 | + p++; |
| 1781 | + for(;;) { |
| 1782 | + c = *p; |
| 1783 | + if (c == '\n' || c == CH_EOF) { |
| 1784 | + break; |
| 1785 | + } else if (c == '\\') { |
| 1786 | + PEEKC_EOB(c, p); |
| 1787 | + if (c == '\n') { |
| 1788 | + file->line_num++; |
| 1789 | + PEEKC_EOB(c, p); |
| 1790 | + } else if (c == '\r') { |
| 1791 | + PEEKC_EOB(c, p); |
| 1792 | + if (c == '\n') { |
| 1793 | + file->line_num++; |
| 1794 | + PEEKC_EOB(c, p); |
| 1795 | + } |
| 1796 | + } |
| 1797 | + } else { |
| 1798 | + p++; |
| 1799 | + } |
| 1800 | + } |
| 1801 | + return p; |
| 1782 | 1802 | } |
| 1783 | 1803 | |
| 1784 | | −static void parse_comment(void) |
| 1804 | +/* C comments */ |
| 1805 | +static uint8_t *parse_comment(uint8_t *p) |
| 1785 | 1806 | { |
| 1786 | | − uint8_t *p; |
| 1787 | 1807 | int c; |
| 1788 | 1808 | |
| 1789 | | − /* C comments */ |
| 1790 | | − p = file->buf_ptr; |
| 1791 | 1809 | p++; |
| 1792 | 1810 | for(;;) { |
| 1793 | 1811 | /* fast skip loop */ |
| @@ -1816,32 +1834,30 @@ static void parse_comment(void) · 22 unmodified lines |
| 1816 | 1834 | } else if (c == '\\') { |
| 1817 | 1835 | file->buf_ptr = p; |
| 1818 | 1836 | c = handle_eob(); |
| 1837 | + p = file->buf_ptr; |
| 1819 | 1838 | if (c == '\\') { |
| 1820 | | − /* skip '\\n', but if '\' followed but another |
| 1821 | | − char, behave asif a stray was parsed */ |
| 1822 | | − ch = file->buf_ptr[0]; |
| 1823 | | − while (ch == '\\') { |
| 1824 | | − inp(); |
| 1825 | | − if (ch == '\n') { |
| 1839 | + /* skip '\[\r]\n', otherwise just skip the stray */ |
| 1840 | + while (c == '\\') { |
| 1841 | + PEEKC_EOB(c, p); |
| 1842 | + if (c == '\n') { |
| 1826 | 1843 | file->line_num++; |
| 1827 | | − inp(); |
| 1828 | | − } else if (ch == '\r') { |
| 1829 | | − inp(); |
| 1830 | | − if (ch == '\n') { |
| 1844 | + PEEKC_EOB(c, p); |
| 1845 | + } else if (c == '\r') { |
| 1846 | + PEEKC_EOB(c, p); |
| 1847 | + if (c == '\n') { |
| 1831 | 1848 | file->line_num++; |
| 1832 | | − inp(); |
| 1849 | + PEEKC_EOB(c, p); |
| 1833 | 1850 | } |
| 1834 | 1851 | } else { |
| 1835 | | − p = file->buf_ptr; |
| 1836 | | − break; |
| 1852 | + goto after_star; |
| 1837 | 1853 | } |
| 1838 | 1854 | } |
| 1839 | 1855 | } |
| 1840 | | − p = file->buf_ptr; |
| 1841 | 1856 | } else { |
| 1842 | 1857 | break; |
| 1843 | 1858 | } |
| 1844 | 1859 | } |
| 1860 | + after_star: ; |
| 1845 | 1861 | } else { |
| 1846 | 1862 | /* stray, eob or eof */ |
| 1847 | 1863 | file->buf_ptr = p; |
| @@ -1856,8 +1872,7 @@ static void parse_comment(void) · 8 unmodified lines |
| 1856 | 1872 | } |
| 1857 | 1873 | end_of_comment: |
| 1858 | 1874 | p++; |
| 1859 | | − file->buf_ptr = p; |
| 1860 | | − ch = *p; |
| 1875 | + return p; |
| 1861 | 1876 | } |
| 1862 | 1877 | |
| 1863 | 1878 | #define cinp minp |
| @@ -1984,12 +1999,12 @@ void preprocess_skip(void) · 120 unmodified lines |
| 1984 | 1999 | file->buf_ptr = p; |
| 1985 | 2000 | ch = *p; |
| 1986 | 2001 | minp(); |
| 2002 | + p = file->buf_ptr; |
| 1987 | 2003 | if (ch == '*') { |
| 1988 | | − parse_comment(); |
| 2004 | + p = parse_comment(p); |
| 1989 | 2005 | } else if (ch == '/') { |
| 1990 | | − parse_line_comment(); |
| 2006 | + p = parse_line_comment(p); |
| 1991 | 2007 | } |
| 1992 | | − p = file->buf_ptr; |
| 1993 | 2008 | break; |
| 1994 | 2009 | |
| 1995 | 2010 | case '#': |
| @@ -3541,14 +3556,10 @@ static inline void next_nomacro1(void) · 1545 unmodified lines |
| 3541 | 3556 | case '/': |
| 3542 | 3557 | PEEKC(c, p); |
| 3543 | 3558 | if (c == '*') { |
| 3544 | | − file->buf_ptr = p; |
| 3545 | | − parse_comment(); |
| 3546 | | − p = file->buf_ptr; |
| 3559 | + p = parse_comment(p); |
| 3547 | 3560 | goto redo_no_start; |
| 3548 | 3561 | } else if (c == '/') { |
| 3549 | | − file->buf_ptr = p; |
| 3550 | | − parse_line_comment(); |
| 3551 | | − p = file->buf_ptr; |
| 3562 | + p = parse_line_comment(p); |
| 3552 | 3563 | goto redo_no_start; |
| 3553 | 3564 | } else if (c == '=') { |
| 3554 | 3565 | p++; |