justinethier / cyclone

:cyclone: A brand-new compiler that allows practical application development using R7RS Scheme. We provide modern features and a stable system capable of generating fast native binaries.
http://justinethier.github.io/cyclone/
MIT License
824 stars 44 forks source link

Escape trigraphs in compiled strings #465

Closed justinethier closed 3 years ago

justinethier commented 3 years ago

Consider the following example:

justin@justin-OptiPlex-790 ~ $ cat test3.scm
(import (except (scheme base) quote) (scheme write))

(write "??>")

justin@justin-OptiPlex-790 ~ $ cyclone  test3.scm
test3.c: In function ‘c_entry_pt_first_lambda’:
test3.c:374:36: warning: trigraph ??> ignored, use -trigraphs to enable [-Wtrigraphs]
 make_utf8_string_with_len(c_7316, "??>", 3, 3);

From https://en.wikipedia.org/wiki/Digraphs_and_trigraphs#C

To safely place two consecutive question marks within a string literal, the programmer can use string concatenation "...?""?..." or an escape sequence "...?\?..."