Skip to content

Commit 052089b

Browse files
authored
Merge pull request #674 from coatless/feature/refresh-tinyformat
Refresh tinyformat with May 2016 header, retain local modifications (close #673)
2 parents 2f9e391 + 0c23876 commit 052089b

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2017-04-14 James J Balamuta <[email protected]>
2+
3+
* inst/include/Rcpp/utils/tinyformat.h: Refreshed tinyformat.h against
4+
May 13, 2016 upstream, retained local mods.
5+
16
2017-04-14 Kirill Müller <[email protected]>
27

38
* inst/include/Rcpp/macros/macros.h: Remove unused variable warning in

inst/NEWS.Rd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
Hester in \ghpr{663} addressing \ghit{664}).
1212
\item Somewhat spurious compiler messages under very verbose settings are
1313
now suppressed (Kirill Mueller in \ghpr{670}, \ghpr{671} and \ghpr{672}).
14+
\item Refreshed the included \code{tinyformat} template library
15+
(James Balamuta in \ghpr{674} addressing \ghit{673}).
1416
}
1517
\item Changes in Rcpp Documentation:
1618
\itemize{

inst/include/Rcpp/utils/tinyformat.h

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -152,15 +152,6 @@ namespace Rcpp {
152152
# endif
153153
#endif
154154

155-
#ifdef TINYFORMAT_USE_VARIADIC_TEMPLATES
156-
# include <array>
157-
# if defined(_MSC_VER) && _MSC_VER <= 1800 // VS2013
158-
# define TINYFORMAT_BRACED_INIT_WORKAROUND(x) (x)
159-
# else
160-
# define TINYFORMAT_BRACED_INIT_WORKAROUND(x) {x}
161-
# endif
162-
#endif
163-
164155
#if defined(__GLIBCXX__) && __GLIBCXX__ < 20080201
165156
// std::showpos is broken on old libstdc++ as provided with OSX. See
166157
// http://gcc.gnu.org/ml/libstdc++/2007-11/msg00075.html
@@ -282,7 +273,7 @@ inline void formatTruncated(std::ostream& out, const T& value, int ntrunc)
282273
std::ostringstream tmp;
283274
tmp << value;
284275
std::string result = tmp.str();
285-
out.write(result.c_str(), std::min(ntrunc, static_cast<int>(result.size())));
276+
out.write(result.c_str(), (std::min)(ntrunc, static_cast<int>(result.size())));
286277
}
287278
#define TINYFORMAT_DEFINE_FORMAT_TRUNCATED_CSTR(type) \
288279
inline void formatTruncated(std::ostream& out, type* value, int ntrunc) \
@@ -332,8 +323,8 @@ inline void formatValue(std::ostream& out, const char* /*fmtBegin*/,
332323
// void* respectively and format that instead of the value itself. For the
333324
// %p conversion it's important to avoid dereferencing the pointer, which
334325
// could otherwise lead to a crash when printing a dangling (const char*).
335-
bool canConvertToChar = detail::is_convertible<T,char>::value;
336-
bool canConvertToVoidPtr = detail::is_convertible<T, const void*>::value;
326+
const bool canConvertToChar = detail::is_convertible<T,char>::value;
327+
const bool canConvertToVoidPtr = detail::is_convertible<T, const void*>::value;
337328
if(canConvertToChar && *(fmtEnd-1) == 'c')
338329
detail::formatValueAsType<T, char>::invoke(out, value);
339330
else if(canConvertToVoidPtr && *(fmtEnd-1) == 'p')
@@ -566,15 +557,17 @@ inline const char* printFormatStringLiteral(std::ostream& out, const char* fmt)
566557
switch(*c)
567558
{
568559
case '\0':
569-
out.write(fmt, static_cast<std::streamsize>(c - fmt));
560+
out.write(fmt, c - fmt);
570561
return c;
571562
case '%':
572-
out.write(fmt, static_cast<std::streamsize>(c - fmt));
563+
out.write(fmt, c - fmt);
573564
if(*(c+1) != '%')
574565
return c;
575566
// for "%%", tack trailing % onto next literal section.
576567
fmt = ++c;
577568
break;
569+
default:
570+
break;
578571
}
579572
}
580573
}
@@ -644,6 +637,8 @@ inline const char* streamStateFromFormat(std::ostream& out, bool& spacePadPositi
644637
spacePadPositive = false;
645638
widthExtra = 1;
646639
continue;
640+
default:
641+
break;
647642
}
648643
break;
649644
}
@@ -757,6 +752,8 @@ inline const char* streamStateFromFormat(std::ostream& out, bool& spacePadPositi
757752
TINYFORMAT_ERROR("tinyformat: Conversion spec incorrectly "
758753
"terminated by end of string");
759754
return c;
755+
default:
756+
break;
760757
}
761758
if(intConversion && precisionSet && !widthSet)
762759
{
@@ -869,7 +866,7 @@ class FormatListN : public FormatList
869866
template<typename... Args>
870867
FormatListN(const Args&... args)
871868
: FormatList(&m_formatterStore[0], N),
872-
m_formatterStore TINYFORMAT_BRACED_INIT_WORKAROUND({ FormatArg(args)... })
869+
m_formatterStore { FormatArg(args)... }
873870
{ static_assert(sizeof...(args) == N, "Number of args must be N"); }
874871
#else // C++98 version
875872
void init(int) {}
@@ -878,7 +875,7 @@ class FormatListN : public FormatList
878875
template<TINYFORMAT_ARGTYPES(n)> \
879876
FormatListN(TINYFORMAT_VARARGS(n)) \
880877
: FormatList(&m_formatterStore[0], n) \
881-
{/*assert*n == N);*/init(0, TINYFORMAT_PASSARGS(n)); } \
878+
{/*assert(n == N);*/init(0, TINYFORMAT_PASSARGS(n)); } \
882879
\
883880
template<TINYFORMAT_ARGTYPES(n)> \
884881
void init(int i, TINYFORMAT_VARARGS(n)) \
@@ -892,11 +889,7 @@ class FormatListN : public FormatList
892889
#endif
893890

894891
private:
895-
#ifdef TINYFORMAT_USE_VARIADIC_TEMPLATES
896-
std::array<FormatArg, N> m_formatterStore;
897-
#else // C++98 version
898892
FormatArg m_formatterStore[N];
899-
#endif
900893
};
901894

902895
// Special 0-arg version - MSVC says zero-sized C array in struct is nonstandard
@@ -1048,4 +1041,4 @@ TINYFORMAT_FOREACH_ARGNUM(TINYFORMAT_MAKE_FORMAT_FUNCS)
10481041

10491042
} // namespace tinyformat
10501043

1051-
#endif // TINYFORMAT_H_INCLUDED
1044+
#endif // TINYFORMAT_H_INCLUDED

0 commit comments

Comments
 (0)