summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/lib
diff options
context:
space:
mode:
authorClayton Smith <argilo@gmail.com>2020-10-07 00:00:45 -0400
committermormj <34754695+mormj@users.noreply.github.com>2020-10-20 06:10:05 -0400
commitdf78c2f10d27f1300b464028bd72806735373739 (patch)
tree7933c58149c5448f82580fda0dd3d66e035ab8be /gnuradio-runtime/lib
parent92c770f19f1bc8f42c57be2483a697195cce9f22 (diff)
runtime: remove snprintf
Diffstat (limited to 'gnuradio-runtime/lib')
-rw-r--r--gnuradio-runtime/lib/pmt/pmt_unv.cc14
-rw-r--r--gnuradio-runtime/lib/pmt/qa_pmt_unv.cc5
2 files changed, 13 insertions, 6 deletions
diff --git a/gnuradio-runtime/lib/pmt/pmt_unv.cc b/gnuradio-runtime/lib/pmt/pmt_unv.cc
index 81030f8470..fd94941c9d 100644
--- a/gnuradio-runtime/lib/pmt/pmt_unv.cc
+++ b/gnuradio-runtime/lib/pmt/pmt_unv.cc
@@ -17,6 +17,7 @@
#include "pmt_int.h"
#include "pmt_unv_int.h"
#include <pmt/pmt.h>
+#include <iomanip>
#include <sstream>
#include <string>
#include <vector>
@@ -1146,9 +1147,9 @@ float* f32vector_writable_elements(pmt_t vector, size_t& len)
const std::string pmt_f32vector::string_ref(size_t k) const
{
- char buf[128];
- snprintf(buf, sizeof(buf), "%.*f", std::numeric_limits<float>::digits10, ref(k));
- return buf;
+ std::stringstream ss;
+ ss << std::fixed << std::setprecision(std::numeric_limits<float>::digits10) << ref(k);
+ return ss.str();
}
} /* namespace pmt */
@@ -1273,9 +1274,10 @@ double* f64vector_writable_elements(pmt_t vector, size_t& len)
const std::string pmt_f64vector::string_ref(size_t k) const
{
- char buf[128];
- snprintf(buf, sizeof(buf), "%.*f", std::numeric_limits<double>::digits10, ref(k));
- return buf;
+ std::stringstream ss;
+ ss << std::fixed << std::setprecision(std::numeric_limits<double>::digits10)
+ << ref(k);
+ return ss.str();
}
} /* namespace pmt */
diff --git a/gnuradio-runtime/lib/pmt/qa_pmt_unv.cc b/gnuradio-runtime/lib/pmt/qa_pmt_unv.cc
index 3f6a77afd3..76ce3933bc 100644
--- a/gnuradio-runtime/lib/pmt/qa_pmt_unv.cc
+++ b/gnuradio-runtime/lib/pmt/qa_pmt_unv.cc
@@ -324,6 +324,8 @@ BOOST_AUTO_TEST_CASE(test_f32vector)
BOOST_CHECK_EQUAL(float(0), wr[0]);
BOOST_CHECK_EQUAL(s1, wr[1]);
BOOST_CHECK_EQUAL(s2, wr[2]);
+
+ BOOST_CHECK_EQUAL(pmt::write_string(v1), "#[0.000000 20.000000 30.000000]");
}
BOOST_AUTO_TEST_CASE(test_f64vector)
{
@@ -358,6 +360,9 @@ BOOST_AUTO_TEST_CASE(test_f64vector)
BOOST_CHECK_EQUAL(double(0), wr[0]);
BOOST_CHECK_EQUAL(s1, wr[1]);
BOOST_CHECK_EQUAL(s2, wr[2]);
+
+ BOOST_CHECK_EQUAL(pmt::write_string(v1),
+ "#[0.000000000000000 20.000000000000000 30.000000000000000]");
}
BOOST_AUTO_TEST_CASE(test_c32vector)
{