aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-02-08 11:48:37 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-02-08 11:48:37 +0200
commitedb7ba7437aa577d65da942aaf778c16c9a501ed (patch)
tree8002ee45759c89c77f01e7748f917a64b4705989
parent039beb368bf43572b0400521a7859dd635a8f22f (diff)
Recode strncpy as memcpy
VC12 deprecated those hard, as in, it is now an error.
-rw-r--r--common/query/array/test.hxx9
-rw-r--r--mssql/types/test.hxx12
-rw-r--r--mysql/types/test.hxx6
-rw-r--r--oracle/types/test.hxx6
-rw-r--r--pgsql/types/test.hxx6
-rw-r--r--sqlite/types/test.hxx8
6 files changed, 24 insertions, 23 deletions
diff --git a/common/query/array/test.hxx b/common/query/array/test.hxx
index 1bebf19..a881e8c 100644
--- a/common/query/array/test.hxx
+++ b/common/query/array/test.hxx
@@ -7,7 +7,7 @@
#include <common/config.hxx> // HAVE_CXX11
-#include <cstring> // std::strncpy
+#include <cstring> // std::memcpy, std::strlen
#ifdef HAVE_CXX11
# include <array>
@@ -22,10 +22,11 @@ struct object
object (unsigned long id, const char* s, const char* b)
: id_ (id)
{
- std::strncpy (s_, s, sizeof (s_));
- std::strncpy (s1_, s, sizeof (s1_));
+ std::memcpy (s_, s, std::strlen (s) + 1); // VC++ strncpy deprecation.
+ std::memcpy (s1_, s, std::strlen (s) + 1);
+
#ifdef HAVE_CXX11
- std::strncpy (a_.data (), s, a_.size ());
+ std::memcpy (a_.data (), s, std::strlen (s) + 1);
#endif
c_ = c1_ = *s;
std::memcpy (b_, b, sizeof (b_));
diff --git a/mssql/types/test.hxx b/mssql/types/test.hxx
index 0b4653e..15070e3 100644
--- a/mssql/types/test.hxx
+++ b/mssql/types/test.hxx
@@ -23,8 +23,8 @@ typedef struct _GUID
#include <string>
#include <vector>
#include <memory> // std::auto_ptr
-#include <cstring> // std::memcmp, std::strncpy, std::str[n]cmp
-#include <cwchar> // std::wcsncpy, std::wcs[n]cmp
+#include <cstring> // std::memcmp, std::memcpy, std::str[n]cmp, std::strlen
+#include <cwchar> // std::wcslen, std::wcs[n]cmp
#include <odb/core.hxx>
@@ -379,12 +379,12 @@ struct char_array
char_array (unsigned long id, const char* s, const wchar_t* ws)
: id_ (id)
{
- std::strncpy (s1, s, sizeof (s1));
- std::strncpy (s2, s, sizeof (s2));
+ std::memcpy (s1, s, std::strlen (s) + 1); // VC++ strncpy deprecation.
+ std::memcpy (s2, s, std::strlen (s) + 1);
s3[0] = c1 = *s;
- std::wcsncpy (ws1, ws, sizeof (ws1) / sizeof(wchar_t));
- std::wcsncpy (ws2, ws, sizeof (ws2) / sizeof(wchar_t));
+ std::memcpy (ws1, ws, (std::wcslen (ws) + 1) * sizeof (wchar_t));
+ std::memcpy (ws2, ws, (std::wcslen (ws) + 1) * sizeof (wchar_t));
ws3[0] = wc1 = *ws;
if (std::strlen (s) == sizeof (s2))
diff --git a/mysql/types/test.hxx b/mysql/types/test.hxx
index 5e6c7b4..aaf6df7 100644
--- a/mysql/types/test.hxx
+++ b/mysql/types/test.hxx
@@ -9,7 +9,7 @@
#include <string>
#include <vector>
#include <memory> // std::auto_ptr
-#include <cstring> // std::strncpy, std::str[n]cmp
+#include <cstring> // std::memcpy, std::str[n]cmp, std::strlen
#include <odb/core.hxx>
@@ -282,8 +282,8 @@ struct char_array
char_array (unsigned long id, const char* s)
: id_ (id)
{
- std::strncpy (s1, s, sizeof (s1));
- std::strncpy (s2, s, sizeof (s2));
+ std::memcpy (s1, s, std::strlen (s) + 1); // VC++ strncpy deprecation.
+ std::memcpy (s2, s, std::strlen (s) + 1);
s3[0] = c1 = *s;
}
diff --git a/oracle/types/test.hxx b/oracle/types/test.hxx
index 804f0aa..687f05e 100644
--- a/oracle/types/test.hxx
+++ b/oracle/types/test.hxx
@@ -8,7 +8,7 @@
#include <string>
#include <vector>
#include <memory> // std::auto_ptr
-#include <cstring> // std::strncpy, std::str[n]cmp
+#include <cstring> // std::memcpy, std::str[n]cmp, std::strlen
#include <odb/core.hxx>
@@ -314,8 +314,8 @@ struct char_array
char_array (unsigned long id, const char* s)
: id_ (id)
{
- std::strncpy (s1, s, sizeof (s1));
- std::strncpy (s2, s, sizeof (s2));
+ std::memcpy (s1, s, std::strlen (s) + 1); // VC++ strncpy deprecation.
+ std::memcpy (s2, s, std::strlen (s) + 1);
s3[0] = c1 = *s;
}
diff --git a/pgsql/types/test.hxx b/pgsql/types/test.hxx
index f3a7d26..773742e 100644
--- a/pgsql/types/test.hxx
+++ b/pgsql/types/test.hxx
@@ -9,7 +9,7 @@
#include <string>
#include <vector>
#include <memory> // std::auto_ptr
-#include <cstring> // std::memcmp, std::strncpy, std::str[n]cmp
+#include <cstring> // std::memcmp, std::memcpy, std::str[n]cmp, std::strlen
#include <cstddef> // std::size_t
#include <odb/core.hxx>
@@ -191,8 +191,8 @@ struct char_array
char_array (unsigned long id, const char* s)
: id_ (id)
{
- std::strncpy (s1, s, sizeof (s1));
- std::strncpy (s2, s, sizeof (s2));
+ std::memcpy (s1, s, std::strlen (s) + 1); // VC++ strncpy deprecation.
+ std::memcpy (s2, s, std::strlen (s) + 1);
s3[0] = c1 = *s;
}
diff --git a/sqlite/types/test.hxx b/sqlite/types/test.hxx
index 5797089..5a0bb41 100644
--- a/sqlite/types/test.hxx
+++ b/sqlite/types/test.hxx
@@ -9,10 +9,10 @@
#include <string>
#include <vector>
#include <memory> // std::auto_ptr
-#include <cstring> // std::strncpy, std::str[n]cmp
+#include <cstring> // std::memcpy, std::str[n]cmp, std::strlen
#ifdef _WIN32
-# include <cwchar> // std::wcsncpy, std::wcs[n]cmp
+# include <cwchar> // std::wcslen, std::wcs[n]cmp
#endif
#include <odb/core.hxx>
@@ -85,11 +85,11 @@ struct char_array
)
: id_ (id)
{
- std::strncpy (s1, s, sizeof (s1));
+ std::memcpy (s1, s, std::strlen (s) + 1); // VC++ strncpy deprecation.
s2[0] = c1 = *s;
#ifdef _WIN32
- std::wcsncpy (ws1, ws, sizeof (ws1) / 2);
+ std::memcpy (ws1, ws, (std::wcslen (ws) + 1) * sizeof (wchar_t));
ws2[0] = wc1 = *ws;
#endif
}