<div class="__aliyun_email_body_block"><div  style="font-family: Tahoma, Arial, STHeitiSC-Light, SimSun"><div  style="clear: both; font-family: Tahoma, Arial, STHeitiSC-Light, SimSun;"><span  style="font-family: Tahoma, Arial, STHeitiSC-Light, SimSun;"><br ></span></div><div  style="clear: both; font-family: Tahoma, Arial, STHeitiSC-Light, SimSun;"><span  style="font-family: Tahoma, Arial, STHeitiSC-Light, SimSun;"><br ></span></div><div  class="alimail-quote"><div  style="clear: both;">------------------------------------------------------------------</div><div  style="clear: both;">From:jinser &lt;aimer@purejs.icu&gt;</div><div  style="clear: both;">Send Time:2025 Sep. 17 (Wed.) 16:34</div><div  style="clear: both;">To:"沈达"&lt;da@liii.pro&gt;</div><div  style="clear: both;">Subject:Fwd: [PATCH] Fix R7RS newline escaping in string serialization</div><div  style="clear: both;"><br ></div><div ></div><br ><div  class="gmail_quote gmail_quote_container"><div  class="gmail_attr">---------- Forwarded message ---------<br >发件人: <strong  class="gmail_sendername">Jinser Kafka</strong> <span >&lt;aimer@purejs.icu&gt;</span><br >Date: 2025年9月17日周三 14:42<br >Subject: [PATCH] Fix R7RS newline escaping in string serialization<br >To:  &lt;<a  href="mailto:997460364@qq.com" target="_blank">997460364@qq.com</a>&gt;<br ></div><br ><br >In R7RS mode, newlines in strings should be escaped as \n to ensure<br >
proper serialization and readback compatibility. This change:<br ><br >
- Makes slashify_table escape newlines when WITH_R7RS is defined<br >
- Adds newline case to slashify_string_to_port for proper \n output<br ><br >
This fixes issues where strings containing newlines would not serialize<br >
correctly in R7RS mode, breaking the round-trip property of write/read.<br >
---<br >
&nbsp;s7.c | 6 ++++++<br >
&nbsp;1 file changed, 6 insertions(+)<br ><br >
diff --git a/s7.c b/s7.c<br >
index 273f6d1..4534a01 100644<br >
--- a/s7.c<br >
+++ b/s7.c<br >
@@ -15584,7 +15584,12 @@ static void init_ctables(void)<br >
&nbsp; &nbsp;/* for (int32_t i = 127; i &lt; 160; i++) slashify_table[i] = true; */ /* 6-Apr-24 for utf-8, but this has no effect on s7test?? */<br >
&nbsp; &nbsp;slashify_table[(uint8_t)'\\'] = true;<br >
&nbsp; &nbsp;slashify_table[(uint8_t)'"'] = true;<br >
+#if WITH_R7RS<br >
+&nbsp; /* In R7RS mode, newlines should be escaped to ensure proper serialization */<br >
+&nbsp; slashify_table[(uint8_t)'\n'] = true;<br >
+#else<br >
&nbsp; &nbsp;slashify_table[(uint8_t)'\n'] = false;<br >
+#endif<br ><br >
&nbsp; &nbsp;for (int32_t i = 0; i &lt; CTABLE_SIZE; i++)<br >
&nbsp; &nbsp; &nbsp;symbol_slashify_table[i] = ((slashify_table[i]) || (!char_ok_in_a_name[i])); /* force use of (symbol ...) for cases like '(ab) as symbol */<br >
@@ -33935,6 +33940,7 @@ static void slashify_string_to_port(s7_scheme *sc, s7_pointer port, const char *<br >
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case '\'':&nbsp; port_write_character(port)(sc, '\'', port);&nbsp; break;<br >
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case '\t':&nbsp; port_write_character(port)(sc, 't', port);&nbsp; &nbsp;break;<br >
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case '\r':&nbsp; port_write_character(port)(sc, 'r', port);&nbsp; &nbsp;break;<br >
+&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;case '\n':&nbsp; port_write_character(port)(sc, 'n', port);&nbsp; &nbsp;break;<br >
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case '\b':&nbsp; port_write_character(port)(sc, 'b', port);&nbsp; &nbsp;break;<br >
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case '\f':&nbsp; port_write_character(port)(sc, 'f', port);&nbsp; &nbsp;break;<br >
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case '\?':&nbsp; port_write_character(port)(sc, '?', port);&nbsp; &nbsp;break;<br >
-- <br >
2.51.0<br ><br ></div></div><div  style="line-height: 20px; clear: both;"><br ></div></div></div>