@@ -1171,7 +1171,13 @@ add_bwt_compressor(BFILE *file)
11711171
11721172/***************** BFILE with UTF8 encode/decode *******************/
11731173
1174- #if WANT_UTF8
1174+ /*
1175+ * This transducer is always compiled in: mk_std() and mkStringU() in eval.c
1176+ * use it unconditionally for stdio and ByteString-to-String decoding, so it
1177+ * must exist regardless of WANT_UTF8. The flag instead selects the decode
1178+ * policy below: real UTF-8 when set, one Char per raw byte when not, so
1179+ * every byte<->Char boundary in the runtime agrees on what "no UTF-8" means.
1180+ */
11751181struct BFILE_utf8 {
11761182 BFILE mets ;
11771183 BFILE * bfile ;
@@ -1184,7 +1190,7 @@ getb_utf8(BFILE *bp)
11841190{
11851191 struct BFILE_utf8 * p = (struct BFILE_utf8 * )bp ;
11861192 CHECKBFILE (bp , getb_utf8 );
1187- int c1 , c2 , c3 , c4 ;
1193+ int c1 ;
11881194
11891195 /* Do we have an ungetb character? */
11901196 if (p -> unget >= 0 ) {
@@ -1193,6 +1199,10 @@ getb_utf8(BFILE *bp)
11931199 return c1 ;
11941200 }
11951201 c1 = getb (p -> bfile );
1202+ #if !WANT_UTF8
1203+ return c1 ; /* one Char per raw byte, no decoding */
1204+ #else
1205+ int c2 , c3 , c4 ;
11961206 if (c1 < 0 )
11971207 return -1 ;
11981208 if ((c1 & 0x80 ) == 0 )
@@ -1224,6 +1234,7 @@ getb_utf8(BFILE *bp)
12241234 }
12251235 ERR ("getb_utf8" );
12261236 NOTREACHED ;
1237+ #endif /* WANT_UTF8 */
12271238}
12281239
12291240void
@@ -1243,6 +1254,10 @@ putb_utf8(int c, BFILE *bp)
12431254 CHECKBFILE (bp , getb_utf8 );
12441255 if (c < 0 )
12451256 ERR ("putb_utf8: < 0" );
1257+ #if !WANT_UTF8
1258+ putb (c , p -> bfile ); /* one raw byte per Char, no encoding */
1259+ return ;
1260+ #else
12461261 if (0 < c && c < 0x80 ) { /* modified UTF-8 avoids 0 */
12471262 putb (c , p -> bfile );
12481263 return ;
@@ -1266,6 +1281,7 @@ putb_utf8(int c, BFILE *bp)
12661281 return ;
12671282 }
12681283 ERR ("putb_utf8" );
1284+ #endif /* WANT_UTF8 */
12691285}
12701286
12711287void
@@ -1306,7 +1322,6 @@ add_utf8(BFILE *file)
13061322
13071323 return (BFILE * )p ;
13081324}
1309- #endif /* WANT_UTF8 */
13101325
13111326/***************** BFILE that just buffers *******************/
13121327
0 commit comments