escape a ? that follows a ? in string literals

Under -std=c11 C reads trigraphs, which Sex has none of: "??=" came out
"#", and "??/" before the closing quote left the string open.
This commit is contained in:
2026-10-16 14:19:51 +03:00
parent e029a234b7
commit 5df6adc4ff
2 changed files with 22 additions and 6 deletions

View File

@@ -1,6 +1,7 @@
(compilation "-- -std=c11 -pedantic-errors")
(input)
(output "c11: 42 43 6 4 6 12")
(output "c11: 42 43 6 4 6 12"
"trigraphs: what??! ??= ???( ??/")
(return 0)
;;; C11 is the floor, and this is the program that holds it there: the
@@ -12,6 +13,10 @@
;;; max_align_t in the environment and `_Static_assert' on its size;
;;; the record, the method and the match are here for what they emit,
;;; and the globals for initializers that have to be constants.
;;;
;;; It is also the one mode where C still reads trigraphs, which Sex has
;;; none of: a string says what was written, `??/' before its closing
;;; quote included.
(include stdio.h)
@@ -42,4 +47,5 @@
(printf "c11: %d %d %d %d %d %d\n"
(.area p) (add-k (.area p)) (+ (sides (shape/square 1)) (sides (shape/dot)) 2)
(sides unit) (.area corner) (.area [pair 1]))
(printf "trigraphs: %s\n" "what??! ??= ???( ??/")
(return 0))