Re: Announcing bglibs version 1.020

Bruce Guenter <[email protected]>
Newsgroups gmane.comp.sysutils.bgware
Message-ID <[email protected]>
On Fri, Jun 03, 2005 at 04:39:05PM +0000, Gerrit Pape wrote:
> On Fri, May 27, 2005 at 10:31:45PM -0600, Bruce Guenter wrote:
> > Version 1.020 of bglibs is now available at:
> > 	http://untroubled.org/bglibs/
> 
> Hi, the selftests show some errors when building bglibs on Debian ppc,
> s390, ia64, and alpha.  Thanks for the selftests by the way, I wish more
> projects would include such kind of test suite.
> 
> On ppc and s390 str_catf() and str_copyf() fail, see

Oy, that's a pretty obvious typo.  Thanks for catching that.

> and below for a suggested patch.

I've applied something a little longer, but it fixes the same problem.
See below.

> On ia64 and alpha it's fmt_multi().

If you also change the type of "value" to "long long" (that is, drop the
unsigned there too) does it still work?
-- 
Bruce Guenter <[email protected]> http://em.ca/~bruceg/ http://untroubled.org/
OpenPGP key: 699980E8 / D0B7 C8DD 365D A395 29DA  2E2A E96F B2DC 6999 80E8

--- dev/bglibs/iobuf/obuf_putf.c	(revision 562)
+++ dev/bglibs/iobuf/obuf_putf.c	(working copy)
@@ -8,16 +8,15 @@
   unsigned length;
   int i;
   va_list ap2;
-  va_copy(ap2, ap);
 
-  length = fmt_multiv(0, format, ap);
-  {
-    char buf[length];
-    fmt_multiv(buf, format, ap2);
-    i = obuf_write(out, buf, length);
-  }
+  va_copy(ap2, ap);
+  length = fmt_multiv(0, format, ap2);
   va_end(ap2);
 
+  char buf[length];
+  fmt_multiv(buf, format, ap);
+  i = obuf_write(out, buf, length);
+
   return i;
 }
 
--- dev/bglibs/str/catf.c	(revision 562)
+++ dev/bglibs/str/catf.c	(working copy)
@@ -23,14 +23,14 @@
 {
   unsigned length;
   va_list ap2;
+
   va_copy(ap2, ap);
-
   length = fmt_multiv(0, format, ap);
+  va_end(ap2);
   if (!str_realloc(s, s->len + length))
     return 0;
 
   fmt_multiv(s->s + s->len, format, ap);
-  va_end(ap2);
 
   s->s[s->len += length] = 0;
   return 1;
--- dev/bglibs/str/copyf.c	(revision 562)
+++ dev/bglibs/str/copyf.c	(working copy)
@@ -23,14 +23,14 @@
 {
   unsigned length;
   va_list ap2;
+
   va_copy(ap2, ap);
-
-  length = fmt_multiv(0, format, ap);
+  length = fmt_multiv(0, format, ap2);
+  va_end(ap2);
   if (!str_ready(s, length))
     return 0;
 
   fmt_multiv(s->s, format, ap);
-  va_end(ap2);
 
   s->s[s->len = length] = 0;
   return 1;
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFCpJXa6W+y3GmZgOgRAprOAJ0eVr+97mplZMeEUT2/94mxADHUsQCglkRM
Qc4/t1mMeIzZlhAyYVc8vRc=
=i/wW
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.