From 5feec11d51e96ec06ee2654c84dbf836e742da73 Mon Sep 17 00:00:00 2001 From: "Jose E. Marchesi" Date: Sat, 21 Feb 2026 21:36:19 +0100 Subject: [PATCH] a68: fix %%< and %%> marks in snprintf calls The function a68_mode_error_text computes a string that is then passed to a68_error or a68_warning. The later functions feed the resulting string to the diagnostics machinery, which knows how to handle %< and %>, but the *printf calls don't. Therefore the %s have to be escaped for %< and %> to be interpreted literally. Signed-off-by: Jose E. Marchesi * a68-moids-diagnostics.cc (a68_mode_error_text): Properly escape %< and %> in snprintf calls. --- gcc/algol68/a68-moids-diagnostics.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gcc/algol68/a68-moids-diagnostics.cc b/gcc/algol68/a68-moids-diagnostics.cc index 180d7fb89a75..10ee4a774159 100644 --- a/gcc/algol68/a68-moids-diagnostics.cc +++ b/gcc/algol68/a68-moids-diagnostics.cc @@ -78,7 +78,7 @@ a68_mode_error_text (NODE_T *n, MOID_T *p, MOID_T *q, int context, int deflex, i N++; len = strlen (txt); } - if (snprintf (TAIL (txt), ACTUAL_SNPRINTF_SIZE, "%<%s%>", + if (snprintf (TAIL (txt), ACTUAL_SNPRINTF_SIZE, "%%<%s%%>", a68_moid_to_string (MOID (u), MOID_ERROR_WIDTH, n)) < 0) gcc_unreachable (); N++; @@ -96,7 +96,7 @@ a68_mode_error_text (NODE_T *n, MOID_T *p, MOID_T *q, int context, int deflex, i gcc_unreachable (); len = strlen (txt); } - if (snprintf (TAIL (txt), ACTUAL_SNPRINTF_SIZE, " cannot be coerced to %<%s%>", + if (snprintf (TAIL (txt), ACTUAL_SNPRINTF_SIZE, " cannot be coerced to %%<%s%%>", a68_moid_to_string (q, MOID_ERROR_WIDTH, n)) < 0) gcc_unreachable (); } @@ -137,7 +137,7 @@ a68_mode_error_text (NODE_T *n, MOID_T *p, MOID_T *q, int context, int deflex, i } } len = strlen (txt); - if (snprintf (TAIL (txt), ACTUAL_SNPRINTF_SIZE, " cannot be coerced to %<%s%>", + if (snprintf (TAIL (txt), ACTUAL_SNPRINTF_SIZE, " cannot be coerced to %%<%s%%>", a68_moid_to_string (SLICE (SUB (q)), MOID_ERROR_WIDTH, n)) < 0) gcc_unreachable (); } @@ -171,7 +171,7 @@ a68_mode_error_text (NODE_T *n, MOID_T *p, MOID_T *q, int context, int deflex, i gcc_unreachable (); len = strlen (txt); } - if (snprintf (TAIL (txt), ACTUAL_SNPRINTF_SIZE, "%<%s%>", + if (snprintf (TAIL (txt), ACTUAL_SNPRINTF_SIZE, "%%<%s%%>", a68_moid_to_string (MOID (u), MOID_ERROR_WIDTH, n)) < 0) gcc_unreachable (); } @@ -212,7 +212,7 @@ a68_mode_error_text (NODE_T *n, MOID_T *p, MOID_T *q, int context, int deflex, i gcc_unreachable (); len = strlen (txt); } - if (snprintf (TAIL (txt), ACTUAL_SNPRINTF_SIZE, "%<%s%> cannot be coerced to %<%s%>", + if (snprintf (TAIL (txt), ACTUAL_SNPRINTF_SIZE, "%%<%s%%> cannot be coerced to %%<%s%%>", a68_moid_to_string (MOID (u), MOID_ERROR_WIDTH, n), a68_moid_to_string (MOID (v), MOID_ERROR_WIDTH, n)) < 0) gcc_unreachable ();