build: Fix build when std::to_string is not available
This commit also adds a missing header include
Change-Id: I60857a488031f447c63308600052b1d2e9e3958b
Refs: #4393
diff --git a/src/net/ethernet.cpp b/src/net/ethernet.cpp
index 0efdd58..4cda2cc 100644
--- a/src/net/ethernet.cpp
+++ b/src/net/ethernet.cpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2014-2017 Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
@@ -30,6 +30,7 @@
#include <boost/functional/hash.hpp>
#include <stdio.h>
+#include <cstdio>
#include <ostream>
namespace ndn {
@@ -103,18 +104,17 @@
if (ret < 11 || static_cast<size_t>(n) != str.length())
return Address();
- for (size_t i = 0; i < a.size(); ++i)
- {
- // check that all separators are actually the same char (: or -)
- if (i < 5 && sep[i][0] != sep[0][0])
- return Address();
+ for (size_t i = 0; i < a.size(); ++i) {
+ // check that all separators are actually the same char (: or -)
+ if (i < 5 && sep[i][0] != sep[0][0])
+ return Address();
- // check that each value fits into a uint8_t
- if (temp[i] > 0xFF)
- return Address();
+ // check that each value fits into a uint8_t
+ if (temp[i] > 0xFF)
+ return Address();
- a[i] = static_cast<uint8_t>(temp[i]);
- }
+ a[i] = static_cast<uint8_t>(temp[i]);
+ }
return a;
}
diff --git a/src/security/transform/transform-base.cpp b/src/security/transform/transform-base.cpp
index b04c3f5..2a65281 100644
--- a/src/security/transform/transform-base.cpp
+++ b/src/security/transform/transform-base.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2016 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -26,7 +26,7 @@
namespace transform {
Error::Error(size_t index, const std::string& what)
- : std::runtime_error("Error in module " + std::to_string(index) + ": " + what)
+ : std::runtime_error("Error in module " + to_string(index) + ": " + what)
, m_index(index)
{
}
diff --git a/src/util/random.cpp b/src/util/random.cpp
index 41775e4..f6722b9 100644
--- a/src/util/random.cpp
+++ b/src/util/random.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2016 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -48,7 +48,7 @@
{
if (RAND_bytes(bytes, size) != 1) {
BOOST_THROW_EXCEPTION(std::runtime_error("Failed to generate random bytes (error code " +
- std::to_string(ERR_get_error()) + ")"));
+ to_string(ERR_get_error()) + ")"));
}
}