Unified · Split
| @@ -316,6 +316,10 @@ enum { · 315 unmodified lines | |||
| 316 | TOK_MAIN, | 316 | TOK_MAIN, |
| 317 | }; | 317 | }; |
| 318 | 318 | ||
| 319 | /* XXX: need to define this to use them in non ISOC99 context */ | ||
| 320 | extern float strtof (const char *__nptr, char **__endptr); | ||
| 321 | extern long double strtold (const char *__nptr, char **__endptr); | ||
| 322 | |||
| 319 | void sum(int l); | 323 | void sum(int l); |
| 320 | void next(void); | 324 | void next(void); |
| 321 | void next_nomacro(void); | 325 | void next_nomacro(void); |
| @@ -894,7 +898,7 @@ int expr_preprocess(void) · 572 unmodified lines | |||
| 894 | return c != 0; | 898 | return c != 0; |
| 895 | } | 899 | } |
| 896 | 900 | ||
| 897 | #ifdef DEBUG | 901 | #if defined(DEBUG) |
| 898 | void tok_print(int *str) | 902 | void tok_print(int *str) |
| 899 | { | 903 | { |
| 900 | int t; | 904 | int t; |
| @@ -1007,6 +1011,11 @@ void preprocess() · 106 unmodified lines | |||
| 1007 | strcpy(buf, get_tok_str(tok, &tokc)); | 1011 | strcpy(buf, get_tok_str(tok, &tokc)); |
| 1008 | c = '\"'; | 1012 | c = '\"'; |
| 1009 | } | 1013 | } |
| 1014 | /* eat all spaces and comments after include */ | ||
| 1015 | /* XXX: slightly incorrect */ | ||
| 1016 | while (ch1 != '\n' && ch1 != -1) | ||
| 1017 | inp(); | ||
| 1018 | |||
| 1010 | if (include_stack_ptr >= include_stack + INCLUDE_STACK_SIZE) | 1019 | if (include_stack_ptr >= include_stack + INCLUDE_STACK_SIZE) |
| 1011 | error("memory full"); | 1020 | error("memory full"); |
| 1012 | if (c == '\"') { | 1021 | if (c == '\"') { |
| @@ -1389,12 +1398,10 @@ void parse_number(void) · 376 unmodified lines | |||
| 1389 | if (t == 'F') { | 1398 | if (t == 'F') { |
| 1390 | cinp(); | 1399 | cinp(); |
| 1391 | tok = TOK_CFLOAT; | 1400 | tok = TOK_CFLOAT; |
| 1392 | /* XXX: this is an ISOC99 function */ | ||
| 1393 | cval.f = strtof(token_buf, NULL); | 1401 | cval.f = strtof(token_buf, NULL); |
| 1394 | } else if (t == 'L') { | 1402 | } else if (t == 'L') { |
| 1395 | cinp(); | 1403 | cinp(); |
| 1396 | tok = TOK_CLDOUBLE; | 1404 | tok = TOK_CLDOUBLE; |
| 1397 | /* XXX: this is an ISOC99 function */ | ||
| 1398 | cval.ld = strtold(token_buf, NULL); | 1405 | cval.ld = strtold(token_buf, NULL); |
| 1399 | } else { | 1406 | } else { |
| 1400 | tok = TOK_CDOUBLE; | 1407 | tok = TOK_CDOUBLE; |
| @@ -1638,7 +1645,7 @@ int *macro_twosharps(int *macro_str) · 237 unmodified lines | |||
| 1638 | next_nomacro(); | 1645 | next_nomacro(); |
| 1639 | if (tok == 0) | 1646 | if (tok == 0) |
| 1640 | break; | 1647 | break; |
| 1641 | if (*macro_ptr == TOK_TWOSHARPS) { | 1648 | while (*macro_ptr == TOK_TWOSHARPS) { |
| 1642 | macro_ptr++; | 1649 | macro_ptr++; |
| 1643 | macro_ptr1 = macro_ptr; | 1650 | macro_ptr1 = macro_ptr; |
| 1644 | t = *macro_ptr; | 1651 | t = *macro_ptr; |
| @@ -1654,15 +1661,15 @@ int *macro_twosharps(int *macro_str) · 9 unmodified lines | |||
| 1654 | p = get_tok_str(t, &cval); | 1661 | p = get_tok_str(t, &cval); |
| 1655 | strcat(token_buf, p); | 1662 | strcat(token_buf, p); |
| 1656 | ts = tok_alloc(token_buf, 0); | 1663 | ts = tok_alloc(token_buf, 0); |
| 1657 | tok_add(¯o_str1, ¯o_str1_len, ts->tok); | 1664 | tok = ts->tok; /* modify current token */ |
| 1658 | } else { | 1665 | } else { |
| 1659 | /* cannot merge tokens: skip '##' */ | 1666 | /* cannot merge tokens: skip '##' */ |
| 1660 | macro_ptr = macro_ptr1; | 1667 | macro_ptr = macro_ptr1; |
| 1668 | break; | ||
| 1661 | } | 1669 | } |
| 1662 | } | 1670 | } |
| 1663 | } else { | ||
| 1664 | tok_add2(¯o_str1, ¯o_str1_len, tok, &tokc); | ||
| 1665 | } | 1671 | } |
| 1672 | tok_add2(¯o_str1, ¯o_str1_len, tok, &tokc); | ||
| 1666 | } | 1673 | } |
| 1667 | tok_add(¯o_str1, ¯o_str1_len, 0); | 1674 | tok_add(¯o_str1, ¯o_str1_len, 0); |
| 1668 | return macro_str1; | 1675 | return macro_str1; |
| @@ -2842,7 +2849,19 @@ void unary(void) · 1173 unmodified lines | |||
| 2842 | GFuncContext gf; | 2849 | GFuncContext gf; |
| 2843 | 2850 | ||
| 2844 | if (tok == TOK_NUM || tok == TOK_CCHAR || tok == TOK_LCHAR) { | 2851 | if (tok == TOK_NUM || tok == TOK_CCHAR || tok == TOK_LCHAR) { |
| 2845 | vset(VT_CONST, tokc.i); | 2852 | vset(VT_CONST | VT_INT, tokc.i); |
| 2853 | next(); | ||
| 2854 | } else if (tok == TOK_CFLOAT) { | ||
| 2855 | /* currently, cannot do more */ | ||
| 2856 | vset(VT_CONST | VT_FLOAT, 0); | ||
| 2857 | next(); | ||
| 2858 | } else if (tok == TOK_CDOUBLE) { | ||
| 2859 | /* currently, cannot do more */ | ||
| 2860 | vset(VT_CONST | VT_DOUBLE, 0); | ||
| 2861 | next(); | ||
| 2862 | } else if (tok == TOK_CLDOUBLE) { | ||
| 2863 | /* currently, cannot do more */ | ||
| 2864 | vset(VT_CONST | VT_LDOUBLE, 0); | ||
| 2846 | next(); | 2865 | next(); |
| 2847 | } else if (tok == TOK___FUNC__) { | 2866 | } else if (tok == TOK___FUNC__) { |
| 2848 | /* special function name identifier */ | 2867 | /* special function name identifier */ |