]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Add 'autosprintf::operator='.
authorMiguel Angel Arruga Vivas <rosen644835@gmail.com>
Tue, 5 Mar 2013 21:48:55 +0000 (06:48 +0900)
committerDaiki Ueno <ueno@gnu.org>
Tue, 5 Mar 2013 21:48:55 +0000 (06:48 +0900)
gettext-runtime/libasprintf/ChangeLog
gettext-runtime/libasprintf/autosprintf.cc
gettext-runtime/libasprintf/autosprintf.in.h

index 9b97cc6cad946e0fd5fc8d79a3f9c36febcee940..14ae717985c87a84ba98fd3f568dfbf6980e2ee0 100644 (file)
@@ -1,3 +1,13 @@
+2013-03-04  Miguel Angel Arruga Vivas  <rosen644835@gmail.com>  (tiny change)
+
+       Add 'autosprintf::operator='. Needed because destructor
+       is not trivial.
+       Reported at <https://savannah.gnu.org/bugs/?33102>
+       * autosprintf.in.h (autosprintf::operator=): New function.
+       Thanks to Daiki Ueno for pointing a better copy-and-swap
+       idiom use.
+       * autosprintf.cc (autosprintf::operator=): Likewise.
+
 2013-01-17  Daiki Ueno  <ueno@gnu.org>
 
        Fix link errors related to C99-style extern inline.
index d3639f565d0f614fda1aa958deeae9efd64b065c..1d3a8f275548eda88d8155a318052cb9554e9eae 100644 (file)
@@ -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 <bruno@clisp.org>, 2002.
 
    This program is free software: you can redistribute it and/or modify
 #include <string.h>
 #include "lib-asprintf.h"
 
+/* std::swap() is in <utility> since C++11.  */
+#if __cplusplus >= 201103L
+# include <utility>
+#else
+# include <algorithm>
+#fi
+
 namespace gnu
 {
 
@@ -49,6 +56,13 @@ namespace gnu
     str = (src.str != NULL ? strdup (src.str) : NULL);
   }
 
+  /* Copy constructor.  Necessary because the destructor is nontrivial.  */
+  autosprintf& autosprintf::operator = (autosprintf copy)
+  {
+    std::swap (tmp.str, this->str);
+    return *this;
+  }
+
   /* Destructor: frees the temporarily allocated string.  */
   autosprintf::~autosprintf ()
   {
index 74f946c68da33499ca01da95a0638c1bec0d5764..1efd15a3d781cade66ebe98527506712c5d0d63e 100644 (file)
@@ -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 = (autosprintf copy);
     /* Destructor: frees the temporarily allocated string.  */
     ~autosprintf ();
     /* Conversion to string.  */