diff options
author | Theodore Papadopoulo <Theodore.Papadopoulo@sophia.inria.fr> | 1998-10-04 23:12:11 +0200 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 1998-10-04 17:12:11 -0400 |
commit | 12a27dfc4e83a8e450b98063efc0b38207050000 (patch) | |
tree | 070461b4877d38e24b59eca0483262dac74a5609 /gcc | |
parent | 5f2c99c43b76e7d4bc46e445eaa04201c827ffe2 (diff) | |
download | gcc-12a27dfc4e83a8e450b98063efc0b38207050000.zip gcc-12a27dfc4e83a8e450b98063efc0b38207050000.tar.gz gcc-12a27dfc4e83a8e450b98063efc0b38207050000.tar.bz2 |
errfn.c (cp_thing): Print buf as a string not as a printf format to avoid problems with the operator%.
* errfn.c (cp_thing): Print buf as a string not as a printf format
to avoid problems with the operator%. Consequently, `%%' sequences
in format are copied as `%' in buf.
From-SVN: r22825
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/errfn.c | 15 |
2 files changed, 12 insertions, 9 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d803d39..86bd8c9 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +1998-10-04 Theodore Papadopoulo <Theodore.Papadopoulo@sophia.inria.fr> + + * errfn.c (cp_thing): Print buf as a string not as a printf format + to avoid problems with the operator%. Consequently, `%%' sequences + in format are copied as `%' in buf. + 1998-10-04 Jason Merrill <jason@yorick.cygnus.com> * pt.c (pop_tinst_level): Call extract_interface_info. diff --git a/gcc/cp/errfn.c b/gcc/cp/errfn.c index 10de8a9..a43bcf3 100644 --- a/gcc/cp/errfn.c +++ b/gcc/cp/errfn.c @@ -149,18 +149,15 @@ cp_thing (errfn, atarg1, format, ap) } else if (*f == '%') { - /* A `%%' has occurred in the input string. Since the - string we produce here will be passed to vprintf we must - preserve both `%' characters. */ + /* A `%%' has occurred in the input string. Replace it with + a `%' in the formatted message buf. */ - len += 2; - if (len > buflen) + if (++len > buflen) { buflen = len; buf = xrealloc (buf, len); } - strcpy (buf + offset, "%%"); - offset += 2; + buf[offset++] = '%'; } else { @@ -190,10 +187,10 @@ cp_thing (errfn, atarg1, format, ap) { char *file = cp_file_of (atarg); int line = cp_line_of (atarg); - (*errfn) (file, line, buf); + (*errfn) (file, line, "%s", buf); } else - (*errfn) (buf); + (*errfn) ("%s", buf); } |