From faad5ad59005d16080aa79b593fede25c6a7457c Mon Sep 17 00:00:00 2001 From: Tim Peters Date: Mon, 3 Dec 2001 00:43:33 +0000 Subject: mysnprintf.c: Massive rewrite of PyOS_snprintf and PyOS_vsnprintf, to use wrappers on all platforms, to make this as consistent as possible x- platform (in particular, make sure there's at least one \0 byte in the output buffer). Also document more of the truth about what these do. getargs.c, seterror(): Three computations of remaining buffer size were backwards, thus telling PyOS_snprintf the buffer is larger than it actually is. This matters a lot now that PyOS_snprintf ensures there's a trailing \0 byte (because it didn't get the truth about the buffer size, it was storing \0 beyond the true end of the buffer). sysmodule.c, mywrite(): Simplify, now that PyOS_vsnprintf guarantees to produce a \0 byte. --- Python/getargs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Python/getargs.c') diff --git a/Python/getargs.c b/Python/getargs.c index a58816fa86..9df2a2e566 100644 --- a/Python/getargs.c +++ b/Python/getargs.c @@ -231,7 +231,7 @@ seterror(int iarg, char *msg, int *levels, char *fname, char *message) p += strlen(p); } if (iarg != 0) { - PyOS_snprintf(p, sizeof(buf) - (buf - p), + PyOS_snprintf(p, sizeof(buf) - (p - buf), "argument %d", iarg); i = 0; p += strlen(p); @@ -243,10 +243,10 @@ seterror(int iarg, char *msg, int *levels, char *fname, char *message) } } else { - PyOS_snprintf(p, sizeof(buf) - (buf - p), "argument"); + PyOS_snprintf(p, sizeof(buf) - (p - buf), "argument"); p += strlen(p); } - PyOS_snprintf(p, sizeof(buf) - (buf - p), " %.256s", msg); + PyOS_snprintf(p, sizeof(buf) - (p - buf), " %.256s", msg); message = buf; } PyErr_SetString(PyExc_TypeError, message); -- cgit v1.2.1