]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
a68: fix %%< and %%> marks in snprintf calls
authorJose E. Marchesi <jemarch@gnu.org>
Sat, 21 Feb 2026 20:36:19 +0000 (21:36 +0100)
committerJose E. Marchesi <jemarch@gnu.org>
Sat, 21 Feb 2026 20:44:31 +0000 (21:44 +0100)
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 <jemarch@gnu.org>
* a68-moids-diagnostics.cc (a68_mode_error_text): Properly escape
%< and %> in snprintf calls.

gcc/algol68/a68-moids-diagnostics.cc

index 180d7fb89a752fdccdb8729a578111d123e022cc..10ee4a774159cc64c6c4aa9d2e9caa49e91c26e6 100644 (file)
@@ -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 ();