As per grischka comment, always output a space after macro concatenation instead of trying to detect if it's necessary as the current approach has a huge cost.
Unified · Split
| @@ -2910,32 +2910,8 @@ static inline int *macro_twosharps(const int *macro_str) · 2909 unmodified lines | ||
| 2910 | 2910 | } |
| 2911 | 2911 | } |
| 2912 | 2912 | if (tok != TOK_NOSUBST) { |
| 2913 | − const int *oldptr; | |
| 2914 | − CValue cval; | |
| 2915 | − | |
| 2916 | − /* Check if a space need to be added after ## concatenation in | |
| 2917 | − order to avoid misinterpreting the newly formed token | |
| 2918 | − followed by the next token as being a single token (see | |
| 2919 | − macro_concat test) */ | |
| 2920 | − cstr_new(&cstr); | |
| 2921 | − cstr_cat(&cstr, get_tok_str(tok, &tokc)); | |
| 2922 | − oldptr = ptr; | |
| 2923 | − TOK_GET(&t, &ptr, &cval); | |
| 2924 | − ptr = oldptr; | |
| 2925 | − cstr_cat(&cstr, get_tok_str(t, &cval)); | |
| 2926 | − cstr_ccat(&cstr, '\0'); | |
| 2927 | − t = tok; | |
| 2928 | − cval = tokc; | |
| 2929 | − tcc_open_bf(tcc_state, ":paste:", cstr.size); | |
| 2930 | − memcpy(file->buffer, cstr.data, cstr.size); | |
| 2931 | − next_nomacro1(); | |
| 2932 | − if (!*file->buf_ptr) { | |
| 2933 | − tok_str_add2(¯o_str1, t, &cval); | |
| 2934 | − tok = ' '; | |
| 2935 | − } | |
| 2936 | − tcc_close(); | |
| 2937 | − cstr_free(&cstr); | |
| 2938 | − | |
| 2913 | + tok_str_add2(¯o_str1, tok, &tokc); | |
| 2914 | + tok = ' '; | |
| 2939 | 2915 | start_of_nosubsts = -1; |
| 2940 | 2916 | } |
| 2941 | 2917 | tok_str_add2(¯o_str1, tok, &tokc); |