Index: m4/gnulib-comp.m4 =================================================================== --- m4/gnulib-comp.m4.orig +++ m4/gnulib-comp.m4 @@ -102,7 +102,6 @@ AC_DEFUN([gl_INIT], gl_FUNC_TZSET_CLOBBER gl_UNISTD_SAFER gl_FUNC_GLIBC_UNLOCKED_IO - gl_FUNC_VASNPRINTF gl_FUNC_VASPRINTF gl_XALLOC gl_XGETCWD Index: src/error.c =================================================================== --- src/error.c.orig +++ src/error.c @@ -111,28 +111,17 @@ error (int status, int errnum, const cha int save_errno = errno; /* Various buffers we attempt to use to generate the error message. */ - char statbuf[256]; char *buf; size_t length; - char statbuf2[384]; char *buf2; - char statcmdbuf[32]; - char *cmdbuf; - char *emptybuf = ""; - static const char *last_message = NULL; static int last_status; static int last_errnum; - - /* Initialize these to avoid a lot of special case error handling. */ - buf = statbuf; - buf2 = statbuf2; - cmdbuf = emptybuf; + char *cmdbuf = 0; /* Expand the message the user passed us. */ - length = sizeof (statbuf); va_start (args, message); - buf = vasnprintf (statbuf, &length, message, args); + length = vasprintf (&buf, message, args); va_end (args); if (!buf) goto memerror; @@ -145,21 +134,19 @@ error (int status, int errnum, const cha */ if (cvs_cmd_name) { - length = sizeof (statcmdbuf); - cmdbuf = asnprintf (statcmdbuf, &length, " %s%s%s", - status ? "[" : "", - cvs_cmd_name, - status ? " aborted]" : ""); + length = asprintf (&cmdbuf, " %s%s%s", + status ? "[" : "", + cvs_cmd_name, + status ? " aborted]" : ""); /* Else cmdbuf still = emptybuf. */ if (!cmdbuf) goto memerror; } /* Else cmdbuf still = emptybuf. */ /* Now put it all together. */ - length = sizeof (statbuf2); - buf2 = asnprintf (statbuf2, &length, "%s%s: %s%s%s\n", - program_name, cmdbuf, buf, - errnum ? ": " : "", errnum ? strerror (errnum) : ""); + length = asprintf (&buf2, "%s%s: %s%s%s\n", + program_name, cmdbuf ? cmdbuf : "", buf, + errnum ? ": " : "", errnum ? strerror (errnum) : ""); if (!buf2) goto memerror; /* Send the final message to the client or log it. @@ -183,9 +170,9 @@ error (int status, int errnum, const cha exit (EXIT_FAILURE); /* Free anything we may have allocated. */ - if (buf != statbuf) free (buf); - if (buf2 != statbuf2) free (buf2); - if (cmdbuf != statcmdbuf && cmdbuf != emptybuf) free (cmdbuf); + free (buf); + free (buf2); + free (cmdbuf); /* Restore errno per our charter. */ errno = save_errno; Index: src/subr.c =================================================================== --- src/subr.c.orig +++ src/subr.c @@ -1819,8 +1819,8 @@ Xasnprintf (char *resultbuf, size_t *len char *result; va_start (args, format); - result = vasnprintf (resultbuf, lengthp, format, args); - if (result == NULL) + *lengthp = vasprintf (&result, format, args); + if (*lengthp < 0) error (1, errno, "Failed to write to string."); va_end (args);