diff options
author | Jim Meyering <meyering@redhat.com> | 2012-09-10 12:18:59 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2012-09-10 14:31:35 +0200 |
commit | 221383bcb1f9de839727b6ffd1b5a2b725314779 (patch) | |
tree | ab454e73db177448577a9db9300576f2affd50e2 | |
parent | e17295dc5529b252c269f12e081184bbde42d575 (diff) | |
download | diffutils-221383bcb1f9de839727b6ffd1b5a2b725314779.tar.gz |
maint: use xasprintf in place of xmalloc+sprintf
* bootstrap.conf (gnulib_modules): Add gnulib's xvasprintf module.
* src/util.c: Include "xvasprintf.h".
(begin_output): Use xasprintf in place of xmalloc+sprintf.
-rw-r--r-- | bootstrap.conf | 1 | ||||
-rw-r--r-- | src/util.c | 5 |
2 files changed, 3 insertions, 3 deletions
diff --git a/bootstrap.conf b/bootstrap.conf index 3954c4d..81b318e 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -81,6 +81,7 @@ xalloc xfreopen xreadlink xstrtoumax +xvasprintf ' # Additional xgettext options to use. Use "\\\newline" to break lines. @@ -23,6 +23,7 @@ #include <error.h> #include <system-quote.h> #include <xalloc.h> +#include "xvasprintf.h" char const pr_program[] = PR_PROGRAM; @@ -262,14 +263,12 @@ begin_output (void) names[1] = c_escape (current_name1); /* Construct the header of this piece of diff. */ - name = xmalloc (strlen (names[0]) + strlen (names[1]) + strlen (switch_string) + 7); - /* POSIX 1003.1-2001 specifies this format. But there are some bugs in the standard: it says that we must print only the last component of the pathnames, and it requires two spaces after "diff" if there are no options. These requirements are silly and do not match historical practice. */ - sprintf (name, "diff%s %s %s", switch_string, names[0], names[1]); + name = xasprintf ("diff%s %s %s", switch_string, names[0], names[1]); if (paginate) { |