From f9ad74367ccb11e91fbda2bb7702039bcde360ce Mon Sep 17 00:00:00 2001 From: Andrew Burt Date: Mon, 25 Jan 1988 23:31:23 +0000 Subject: perl 1.0 patch 6: printf doesn't finish processing format string when out of args. printf "%% %d %%", 1; produces "% 1 %%", which is counterintuitive. --- arg.c | 12 ++++++++++-- patchlevel.h | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/arg.c b/arg.c index 1423d91a42..728f44d819 100644 --- a/arg.c +++ b/arg.c @@ -1,6 +1,9 @@ -/* $Header: arg.c,v 1.0.1.2 88/01/24 03:52:34 root Exp $ +/* $Header: arg.c,v 1.0.1.3 88/01/26 12:30:33 root Exp $ * * $Log: arg.c,v $ + * Revision 1.0.1.3 88/01/26 12:30:33 root + * patch 6: sprintf didn't finish processing format string when out of args. + * * Revision 1.0.1.2 88/01/24 03:52:34 root * patch 2: added STATBLKS dependencies. * @@ -646,11 +649,16 @@ register STR **sarg; register char *t; bool dolong; char ch; + static STR *sargnull = &str_no; str_set(str,""); len--; /* don't count pattern string */ sarg++; - for (s = str_get(*(sarg++)); *sarg && *s && len; len--) { + for (s = str_get(*(sarg++)); *s; len--) { + if (len <= 0 || !*sarg) { + sarg = &sargnull; + len = 0; + } dolong = FALSE; for (t = s; *t && *t != '%'; t++) ; if (!*t) diff --git a/patchlevel.h b/patchlevel.h index 51d80f3b8e..fb8ed65ede 100644 --- a/patchlevel.h +++ b/patchlevel.h @@ -1 +1 @@ -#define PATCHLEVEL 5 +#define PATCHLEVEL 6 -- cgit v1.2.1