diff --git a/gettext-runtime/libasprintf/ChangeLog b/gettext-runtime/libasprintf/ChangeLog
index 9b97cc6..c67101f 100644
--- a/gettext-runtime/libasprintf/ChangeLog
+++ b/gettext-runtime/libasprintf/ChangeLog
@@ -1,3 +1,10 @@
+2013-02-06 Miguel Angel Arruga Vivas
+
+ Add 'autosprintf::operator='. Needed because destructor
+ is not trivial.
+ Reported at https://savannah.gnu.org/bugs/?33102
+ * autosprintf.cc (autosprintf::operator=): New function.
+
2013-01-17 Daiki Ueno
Fix link errors related to C99-style extern inline.
diff --git a/gettext-runtime/libasprintf/autosprintf.cc b/gettext-runtime/libasprintf/autosprintf.cc
index d3639f5..5b869f8 100644
--- a/gettext-runtime/libasprintf/autosprintf.cc
+++ b/gettext-runtime/libasprintf/autosprintf.cc
@@ -1,5 +1,5 @@
/* Class autosprintf - formatted output to an ostream.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2013 Free Software Foundation, Inc.
Written by Bruno Haible , 2002.
This program is free software: you can redistribute it and/or modify
@@ -30,6 +30,13 @@
#include
#include "lib-asprintf.h"
+/* std::swap() is in since C++11. */
+#if __cplusplus >= 201103L
+# include
+#else
+# include
+#fi
+
namespace gnu
{
@@ -49,6 +56,17 @@ namespace gnu
str = (src.str != NULL ? strdup (src.str) : NULL);
}
+ /* Copy constructor. Necessary because the destructor is nontrivial. */
+ autosprintf& autosprintf::operator = (const autosprintf& copy)
+ {
+ if (this != ©)
+ {
+ autosprintf tmp(copy);
+ std::swap (tmp.str, this->str);
+ }
+ return *this;
+ }
+
/* Destructor: frees the temporarily allocated string. */
autosprintf::~autosprintf ()
{
diff --git a/gettext-runtime/libasprintf/autosprintf.in.h b/gettext-runtime/libasprintf/autosprintf.in.h
index 74f946c..0b0b03a 100644
--- a/gettext-runtime/libasprintf/autosprintf.in.h
+++ b/gettext-runtime/libasprintf/autosprintf.in.h
@@ -1,5 +1,5 @@
/* Class autosprintf - formatted output to an ostream.
- Copyright (C) 2002, 2012 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2012, 2013 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@@ -45,6 +45,7 @@ namespace gnu
__attribute__ ((__format__ (__printf__, 2, 3)));
/* Copy constructor. */
autosprintf (const autosprintf& src);
+ autosprintf& operator = (const autosprintf& copy);
/* Destructor: frees the temporarily allocated string. */
~autosprintf ();
/* Conversion to string. */