From c9728abdeeecab06eeedba5fc116d1f87bef60a3 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 1 Feb 2018 10:52:44 +0000 Subject: [PATCH] build CORE lib without warnings --- CGAL_Core/include/CGAL/CORE/BigFloat_impl.h | 12 ++++--- CGAL_Core/include/CGAL/CORE/CoreIO_impl.h | 39 +++++++++++---------- CGAL_Core/include/CGAL/CORE/Expr_impl.h | 4 +++ CGAL_Core/include/CGAL/CORE/Real_impl.h | 6 +++- 4 files changed, 38 insertions(+), 23 deletions(-) diff --git a/CGAL_Core/include/CGAL/CORE/BigFloat_impl.h b/CGAL_Core/include/CGAL/CORE/BigFloat_impl.h index b07c3754ab7..0554fe2a172 100644 --- a/CGAL_Core/include/CGAL/CORE/BigFloat_impl.h +++ b/CGAL_Core/include/CGAL/CORE/BigFloat_impl.h @@ -48,6 +48,8 @@ #define CGAL_INLINE_FUNCTION #endif +#include + #include #include #include @@ -942,7 +944,7 @@ BigFloatRep::toDecimal(unsigned int width, bool Scientific) const { return toDecimal(width, true); } } - decOut.noSignificant = decRep.length(); + decOut.noSignificant = static_cast(decRep.length()); if (L10 + 1 < (long)width ) { decRep.insert(L10 + 1, "."); } else { // L10 + 1 == width @@ -957,7 +959,7 @@ BigFloatRep::toDecimal(unsigned int width, bool Scientific) const { decRep = round(decRep, L10, width ); // cannot overflow since there are L10 leading zeroes. } - decOut.noSignificant = decRep.length() - (-L10); + decOut.noSignificant = static_cast(decRep.length() - (-L10)); decRep.insert(1, "."); } decOut.isScientific = false; @@ -1085,7 +1087,7 @@ std::istream& BigFloatRep :: operator >>(std::istream& i) { // Change to: // int status; do { - c = i.get(); + i.get(c); } while (isspace(c)); /* loop if met end-of-file, or char read in is white-space. */ // Chen Li, "if (c == EOF)" is unsafe since c is of char type and @@ -1135,7 +1137,7 @@ std::istream& BigFloatRep :: operator >>(std::istream& i) { // chenli: make sure that the p is still in the range if (p - str >= size) { - int len = p - str; + std::size_t len = p - str; char *t = str; str = new char[len + 1]; memcpy(str, t, len); @@ -1327,3 +1329,5 @@ BigFloat root(const BigFloat& x, unsigned long k, CORE_MEMORY_IMPL(BigFloatRep) } //namespace CORE + +#include diff --git a/CGAL_Core/include/CGAL/CORE/CoreIO_impl.h b/CGAL_Core/include/CGAL/CORE/CoreIO_impl.h index 53bb3edfd53..bbc582fa808 100644 --- a/CGAL_Core/include/CGAL/CORE/CoreIO_impl.h +++ b/CGAL_Core/include/CGAL/CORE/CoreIO_impl.h @@ -102,15 +102,15 @@ void append_char (char * &s, int & sz, int pos, char c) { // skip blanks, tabs, line breaks and comment lines CGAL_INLINE_FUNCTION int skip_comment_line (std::istream & in) { - int c; + char c; do { - c = in.get(); + in.get(c); while ( c == '#' ) { do { - c = in.get(); + in.get(c); } while ( c != '\n' ); - c = in.get(); + in.get(c); } } while (c == ' ' || c == '\t' || c == '\n'); @@ -123,14 +123,15 @@ int skip_comment_line (std::istream & in) { // skips '\\' followed by '\n' CGAL_INLINE_FUNCTION -int skip_backslash_new_line (std::istream & in) { - int c = in.get(); +char skip_backslash_new_line (std::istream & in) { + char c; + in.get(c); while (c == '\\') { - c = in.get(); + in.get(c); if (c == '\n') - c = in.get(); + in.get(c); else core_io_error_handler("CoreIO::operator>>", "\\ must be immediately followed by new line."); } @@ -140,10 +141,11 @@ int skip_backslash_new_line (std::istream & in) { CGAL_INLINE_FUNCTION void read_string(std::istream& in, char* &buffer, int sz) { - int c, pos=0; + char c; + int pos=0; skip_comment_line(in); - while ( (c = in.get()) != EOF ) { + while ( in.get(c) ) { if ( c == ' ' || c == '\t' || c == '\n' || c == '#') break; else @@ -159,20 +161,21 @@ void read_base_number(std::istream& in, BigInt& m, long length, long maxBits) { int base; bool is_negate; - int c, pos = 0; + char c; + int pos = 0; skip_comment_line(in); // read sign - c = in.get(); + in.get(c); if (c == '-') { is_negate = true; - c = in.get(); + in.get(c); } else is_negate = false; // read base and compute digits if (c == '0') { - c = in.get(); + in.get(c); if (c == 'b') { base = 2; size = (maxBits == 0 || maxBits > length) ? length : maxBits; @@ -225,7 +228,7 @@ void read_base_number(std::istream& in, BigInt& m, long length, long maxBits) { CGAL_INLINE_FUNCTION -void write_base_number(std::ostream& out, char* buffer, int length, int base, int charsPerLine) { +void write_base_number(std::ostream& out, char* buffer, std::size_t length, int base, int charsPerLine) { // write big number in a format that gmp's mpz_set_str() can // automatically recognize with argument base = 0. if (base == 2) @@ -237,7 +240,7 @@ void write_base_number(std::ostream& out, char* buffer, int length, int base, in // write big number in charsPerLine. char* start, *end, c; - for (int i=0; i= length) out << start; @@ -281,7 +284,7 @@ void writeToFile(const BigInt& z, std::ostream& out, int base, int charsPerLine) // get the absoulte value string char* buffer = new char[mpz_sizeinbase(c.get_mp(), base) + 2]; mpz_get_str(buffer, base, c.get_mp()); - int length = std::strlen(buffer); + std::size_t length = std::strlen(buffer); // write type name of big number and length //out << "# This is an experimental big number format.\n"; @@ -343,7 +346,7 @@ void writeToFile(const BigFloat& bf, std::ostream& out, int base, int charsPerLi // get the absoulte value string char* buffer = new char[mpz_sizeinbase(c.get_mp(), base) + 2]; mpz_get_str(buffer, base, c.get_mp()); - int length = std::strlen(buffer); + std::size_t length = std::strlen(buffer); // write type name, base, length diff --git a/CGAL_Core/include/CGAL/CORE/Expr_impl.h b/CGAL_Core/include/CGAL/CORE/Expr_impl.h index 3693334a4c4..7be40c324c7 100644 --- a/CGAL_Core/include/CGAL/CORE/Expr_impl.h +++ b/CGAL_Core/include/CGAL/CORE/Expr_impl.h @@ -41,6 +41,8 @@ #define CGAL_INLINE_FUNCTION #endif +#include + #include #include #include @@ -1248,3 +1250,5 @@ template class Realbase_for; template class ConstPolyRep; template class ConstPolyRep; } //namespace CORE + +#include diff --git a/CGAL_Core/include/CGAL/CORE/Real_impl.h b/CGAL_Core/include/CGAL/CORE/Real_impl.h index a01e8a5ffa4..77ad9123fe8 100644 --- a/CGAL_Core/include/CGAL/CORE/Real_impl.h +++ b/CGAL_Core/include/CGAL/CORE/Real_impl.h @@ -42,6 +42,8 @@ #define CGAL_INLINE_FUNCTION #endif +#include + #include #include #include @@ -268,7 +270,7 @@ std::istream& operator >>(std::istream& i, Real& x) { } // chenli: make sure that the p is still in the range if (p - str >= size) { - int len = p - str; + std::ptrdiff_t len = p - str; char *t = str; str = new char[len + 1]; std::memcpy(str, t, len); @@ -291,3 +293,5 @@ std::istream& operator >>(std::istream& i, Real& x) { } //namespace CORE + +#include