[Bug fortran/118571] UTF-8 output and the A edit descriptor
jvdelisle at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Jan 21 21:55:40 GMT 2025
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118571
--- Comment #7 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
If no width is specified w_len comes in as zero so we have to handle that case.
diff --git a/libgfortran/io/write.c b/libgfortran/io/write.c
index 54312bf67e9..15a0dd5c3e9 100644
--- a/libgfortran/io/write.c
+++ b/libgfortran/io/write.c
@@ -178,7 +178,10 @@ write_utf8_char4 (st_parameter_dt *dtp, gfc_char4_t
*source,
}
/* Now process the remaining characters, one at a time. */
- for (j = k; j < src_len; j++)
+
+ w_len = w_len == 0 ? src_len : w_len; /* No width specified. */
+
+ for (j = k; j < (w_len < src_len ? w_len : src_len); j++)
{
c = source[j];
if (c < 0x80)
There is probably a more readable way to do that logic. This patch illustrates
the point. I will clean this all up and submit for approval.
More information about the Gcc-bugs
mailing list