diff --git a/configure.ac b/configure.ac index 3f6b89c376..6de63c9fd7 100644 --- a/configure.ac +++ b/configure.ac @@ -130,6 +130,13 @@ LYX_CHECK_CALLSTACK_PRINTING # Needed for our char_type AC_CHECK_SIZEOF(wchar_t) +# Needed for Mingw-w64 +AC_TYPE_LONG_LONG_INT +if test "$ac_cv_type_long_long_int" = yes; then + AC_CHECK_SIZEOF(long) + AC_CHECK_SIZEOF(long long) +fi + ### We need iconv for unicode support (Qt4 frontend requires it too) AM_ICONV if test "$am_cv_func_iconv" = no; then @@ -324,6 +331,12 @@ char * strerror(int n); # define USE_WCHAR_T #endif +#ifdef HAVE_LONG_LONG_INT +#if SIZEOF_LONG_LONG > SIZEOF_LONG +#define LYX_USE_LONG_LONG +#endif +#endif + #endif ]) diff --git a/development/cmake/ConfigureChecks.cmake b/development/cmake/ConfigureChecks.cmake index 6dc82a7d87..825813b501 100644 --- a/development/cmake/ConfigureChecks.cmake +++ b/development/cmake/ConfigureChecks.cmake @@ -114,6 +114,13 @@ check_cxx_source_compiles( " SIZEOF_WCHAR_T_IS_4) +check_cxx_source_compiles( + " + int i[ ( sizeof(long long)>sizeof(long) ? 1 : -1 ) ]; + int main(){return 0;} + " +SIZEOF_LONG_LONG_GREATER_THAN_SIZEOF_LONG) + check_cxx_source_compiles( " #include diff --git a/development/cmake/configCompiler.h.cmake b/development/cmake/configCompiler.h.cmake index 858cfc9711..6eb627add7 100644 --- a/development/cmake/configCompiler.h.cmake +++ b/development/cmake/configCompiler.h.cmake @@ -42,6 +42,7 @@ #cmakedefine HAVE_MAGIC_H 1 #cmakedefine SIZEOF_WCHAR_T_IS_2 1 #cmakedefine SIZEOF_WCHAR_T_IS_4 1 +#cmakedefine SIZEOF_LONG_LONG_GREATER_THAN_SIZEOF_LONG 1 #ifdef SIZEOF_WCHAR_T_IS_2 # define SIZEOF_WCHAR_T 2 @@ -51,6 +52,12 @@ # endif #endif +#ifdef HAVE_LONG_LONG +#ifdef SIZEOF_LONG_LONG_GREATER_THAN_SIZEOF_LONG +#define LYX_USE_LONG_LONG +#endif +#endif + #cmakedefine GETTEXT_FOUND 1 #cmakedefine HAVE_ALLOCA 1 diff --git a/development/cmake/configCompiler.h.msvc b/development/cmake/configCompiler.h.msvc index 334015b5e9..5ff2e9dcf3 100644 --- a/development/cmake/configCompiler.h.msvc +++ b/development/cmake/configCompiler.h.msvc @@ -152,6 +152,12 @@ # define USE_WCHAR_T #endif +#ifdef HAVE_LONG_LONG +#ifdef SIZEOF_LONG_LONG_GREATER_THAN_SIZEOF_LONG +#define LYX_USE_LONG_LONG +#endif +#endif + #if defined(MAKE_INTL_LIB) && defined(_MSC_VER) #define __attribute__(x) #define inline diff --git a/src/support/convert.cpp b/src/support/convert.cpp index 6b985f50ba..58a56479a3 100644 --- a/src/support/convert.cpp +++ b/src/support/convert.cpp @@ -90,6 +90,22 @@ docstring convert(unsigned long ul) } +#ifdef LYX_USE_LONG_LONG +template<> +string convert(unsigned long long ull) +{ + return lexical_cast(ull); +} + + +template<> +docstring convert(unsigned long long ull) +{ + return from_ascii(lexical_cast(ull)); +} +#endif + + template<> string convert(long l) { @@ -104,6 +120,22 @@ docstring convert(long l) } +#ifdef LYX_USE_LONG_LONG +template<> +string convert(long long ll) +{ + return lexical_cast(ll); +} + + +template<> +docstring convert(long long ll) +{ + return from_ascii(lexical_cast(ll)); +} +#endif + + template<> string convert(float f) { diff --git a/src/support/convert.h b/src/support/convert.h index e72fe61b56..fb069c98c3 100644 --- a/src/support/convert.h +++ b/src/support/convert.h @@ -33,8 +33,16 @@ template<> std::string convert(unsigned int ui); template<> docstring convert(unsigned int ui); template<> std::string convert(unsigned long ul); template<> docstring convert(unsigned long ul); +#ifdef LYX_USE_LONG_LONG +template<> std::string convert(unsigned long long ull); +template<> docstring convert(unsigned long long ull); +#endif template<> std::string convert(long l); template<> docstring convert(long l); +#ifdef LYX_USE_LONG_LONG +template<> std::string convert(long long ll); +template<> docstring convert(long long ll); +#endif template<> std::string convert(float f); template<> std::string convert(double d); template<> int convert(std::string const & s); diff --git a/src/support/debug.cpp b/src/support/debug.cpp index 538b487760..bff9bf415a 100644 --- a/src/support/debug.cpp +++ b/src/support/debug.cpp @@ -243,6 +243,12 @@ LyXErr & operator<<(LyXErr & l, long t) { return toStream(l, t); } LyXErr & operator<<(LyXErr & l, unsigned long t) { return toStream(l, t); } +#ifdef LYX_USE_LONG_LONG +LyXErr & operator<<(LyXErr & l, long long t) +{ return toStream(l, t); } +LyXErr & operator<<(LyXErr & l, unsigned long long t) +{ return toStream(l, t); } +#endif LyXErr & operator<<(LyXErr & l, double t) { return toStream(l, t); } LyXErr & operator<<(LyXErr & l, string const & t) diff --git a/src/support/debug.h b/src/support/debug.h index 216538958d..b98dfd0eab 100644 --- a/src/support/debug.h +++ b/src/support/debug.h @@ -202,6 +202,10 @@ LyXErr & operator<<(LyXErr &, int); LyXErr & operator<<(LyXErr &, unsigned int); LyXErr & operator<<(LyXErr &, long); LyXErr & operator<<(LyXErr &, unsigned long); +#ifdef LYX_USE_LONG_LONG +LyXErr & operator<<(LyXErr &, long long); +LyXErr & operator<<(LyXErr &, unsigned long long); +#endif LyXErr & operator<<(LyXErr &, double); LyXErr & operator<<(LyXErr &, std::string const &); LyXErr & operator<<(LyXErr &, docstring const &); diff --git a/src/support/docstring.cpp b/src/support/docstring.cpp index f44259d349..95c86b3665 100644 --- a/src/support/docstring.cpp +++ b/src/support/docstring.cpp @@ -514,7 +514,7 @@ protected: return do_put_helper(oit, b, fill, v); } -#ifdef _GLIBCXX_USE_LONG_LONG +#ifdef LYX_USE_LONG_LONG iter_type do_put(iter_type oit, ios_base & b, char_type fill, long long v) const { @@ -675,7 +675,7 @@ protected: return do_get_integer(iit, eit, b, err, v); } -#ifdef _GLIBCXX_USE_LONG_LONG +#ifdef LYX_USE_LONG_LONG iter_type do_get(iter_type iit, iter_type eit, ios_base & b, ios_base::iostate & err, long long & v) const diff --git a/src/support/lstrings.cpp b/src/support/lstrings.cpp index f4aba23c0a..6d5f86672f 100644 --- a/src/support/lstrings.cpp +++ b/src/support/lstrings.cpp @@ -1437,6 +1437,17 @@ docstring bformat(docstring const & fmt, long arg1) } +#ifdef LYX_USE_LONG_LONG +template<> +docstring bformat(docstring const & fmt, long long arg1) +{ + LATTEST(contains(fmt, from_ascii("%1$d"))); + docstring const str = subst(fmt, from_ascii("%1$d"), convert(arg1)); + return subst(str, from_ascii("%%"), from_ascii("%")); +} +#endif + + template<> docstring bformat(docstring const & fmt, unsigned int arg1) { diff --git a/src/support/lstrings.h b/src/support/lstrings.h index 269b5a6564..ac310c59c4 100644 --- a/src/support/lstrings.h +++ b/src/support/lstrings.h @@ -357,6 +357,9 @@ docstring bformat(docstring const & fmt, Arg1, Arg2, Arg3, Arg4); template<> docstring bformat(docstring const & fmt, int arg1); template<> docstring bformat(docstring const & fmt, long arg1); +#ifdef LYX_USE_LONG_LONG +template<> docstring bformat(docstring const & fmt, long long arg1); +#endif template<> docstring bformat(docstring const & fmt, unsigned int arg1); template<> docstring bformat(docstring const & fmt, docstring arg1); template<> docstring bformat(docstring const & fmt, char * arg1); diff --git a/src/texstream.cpp b/src/texstream.cpp index 3268dca7b2..16f8dfbe68 100644 --- a/src/texstream.cpp +++ b/src/texstream.cpp @@ -215,6 +215,11 @@ template otexrowstream & operator<< (otexrowstream &, template otexrowstream & operator<< (otexrowstream &, unsigned long); +#ifdef LYX_USE_LONG_LONG +template otexrowstream & operator<< (otexrowstream &, + unsigned long long); +#endif + template otexstream & operator<<(otexstream & ots, Type value) @@ -230,5 +235,8 @@ template otexstream & operator<< (otexstream &, double); template otexstream & operator<< (otexstream &, int); template otexstream & operator<< (otexstream &, unsigned int); template otexstream & operator<< (otexstream &, unsigned long); +#ifdef LYX_USE_LONG_LONG +template otexstream & operator<< (otexstream &, unsigned long long); +#endif }