diff --git a/ChangeLog b/ChangeLog index 73b9697a49..e3d13e736a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2000-10-18 Angus Leeming + * src/support/lstrings.C (lowercase, uppercase): + use explicit casts to remove compiler warnings. + + * src/support/LRegex.C (Impl): + * src/support/StrPool.C (add): + * src/support/filetools.C (MakeAbsPath, NormalizePath, MakeRelPath) + (AddPath, MakeDisplayPath): + * src/support/lstrings.C (prefixIs, subst): + use correct type to remove compiler warnings. + + * src/support/lstrings.[Ch] (countChar): returns string::size_type. + + * src/support/lyxlib.h: + * src/support/mkdir.C (mkdir): change parameter to mode_t for + portability and to remove compiler warning with DEC cxx. + + * src/support/FileInfo.[Ch] (flagRWX): ditto. + 2000-10-18 Jean-Marc Lasgouttes * src/minibuffer.C (peek_event): retun 1 when there has been a diff --git a/NEWS b/NEWS index 5c13c7a068..630f979fa8 100644 --- a/NEWS +++ b/NEWS @@ -20,8 +20,8 @@ from the older development version: - LyX now has a Preference popup where you can change most of your lyxrc settings [Allan, details?] -- the menus can now be defined from a text file (like the toolbar) and - shows the keyboard bindings associated to commands. +- The menus can now be defined in a text file, and they automatically + display the keyboard bindings associated with commands. - it is now possible to provide your own icons for the toolbar. diff --git a/src/support/FileInfo.C b/src/support/FileInfo.C index 3bc18c1231..944652b9e1 100644 --- a/src/support/FileInfo.C +++ b/src/support/FileInfo.C @@ -237,7 +237,7 @@ char FileInfo::typeLetter() const // should not be in FileInfo -void FileInfo::flagRWX(unsigned short i, char * szString) const +void FileInfo::flagRWX(mode_t i, char * szString) const { szString[0] = (i & S_IRUSR) ? 'r' : '-'; szString[1] = (i & S_IWUSR) ? 'w' : '-'; diff --git a/src/support/FileInfo.h b/src/support/FileInfo.h index b2f8caad18..93bbadc8fb 100644 --- a/src/support/FileInfo.h +++ b/src/support/FileInfo.h @@ -60,7 +60,7 @@ public: char typeLetter() const; /// builds 'rwx' string describing file access rights - void flagRWX(unsigned short i, char * szString) const; + void flagRWX(mode_t i, char * szString) const; /// updates mode string to match suid/sgid/sticky bits void setSticky(char * szString) const; diff --git a/src/support/LRegex.C b/src/support/LRegex.C index c6c1e938ce..1b6064abd7 100644 --- a/src/support/LRegex.C +++ b/src/support/LRegex.C @@ -59,10 +59,10 @@ struct LRegex::Impl { { regmatch_t tmp; regexec(preg, str.c_str(), 1, &tmp, 0); - unsigned int const first = tmp.rm_so != -1 ? - static_cast(tmp.rm_so) : string::npos; - unsigned int const second = tmp.rm_eo != -1 ? - static_cast(tmp.rm_eo) : string::npos; + string::size_type const first = tmp.rm_so != -1 ? + tmp.rm_so : string::npos; + string::size_type const second = tmp.rm_eo != -1 ? + tmp.rm_eo : string::npos; return make_pair(first, second - first); } @@ -91,18 +91,16 @@ struct LRegex::Impl { size_t const subs = (preg->re_nsub != 0 ? (preg->re_nsub + 1) : 1); regmatch_t * mat = new regmatch_t[subs]; - unsigned int first = 0; - unsigned int second = 0; + string::size_type first = 0; + string::size_type second = 0; matches.erase(matches.begin(), matches.end()); if (!regexec(preg, str.c_str(), subs, mat, 0)) { // some match matches.reserve(subs); for (size_t i = 0; i < subs; ++i) { first = mat[i].rm_so != -1 ? - static_cast - (mat[i].rm_so) : string::npos; + mat[i].rm_so : string::npos; second = mat[i].rm_eo != -1 ? - static_cast - (mat[i].rm_eo) : string::npos; + mat[i].rm_eo : string::npos; matches.push_back(make_pair(first, second - first)); } diff --git a/src/support/StrPool.C b/src/support/StrPool.C index 0fc53402cc..7dd6168f17 100644 --- a/src/support/StrPool.C +++ b/src/support/StrPool.C @@ -31,7 +31,7 @@ StrPool::~StrPool() */ char const * StrPool::add(string const & str) { - int s = str.length(); + string::size_type s = str.length(); char * buf = new char [s + 1]; str.copy(buf, s); buf[s] = '\0'; diff --git a/src/support/filetools.C b/src/support/filetools.C index 8f19df47a5..fdd8bef9e8 100644 --- a/src/support/filetools.C +++ b/src/support/filetools.C @@ -579,7 +579,7 @@ string const MakeAbsPath(string const & RelPath, string const & BasePath) if (Temp == ".") continue; if (Temp == "..") { // Remove one level of TempBase - int i = TempBase.length() - 2; + string::difference_type i = TempBase.length() - 2; #ifndef __EMX__ if (i < 0) i = 0; while (i > 0 && TempBase[i] != '/') --i; @@ -701,7 +701,7 @@ string const NormalizePath(string const & path) TempBase = "./"; } else if (Temp == "..") { // Remove one level of TempBase - int i = TempBase.length() - 2; + string::difference_type i = TempBase.length() - 2; while (i > 0 && TempBase[i] != '/') --i; if (i >= 0 && TempBase[i] == '/') @@ -853,8 +853,8 @@ string const MakeRelPath(string const & abspath0, string const & basepath0) if (abspath.empty()) return ""; - int const abslen = abspath.length(); - int const baselen = basepath.length(); + string::size_type const abslen = abspath.length(); + string::size_type const baselen = basepath.length(); // Find first different character int i = 0; @@ -913,9 +913,9 @@ string const AddPath(string const & path, string const & path_2) } if (!path2.empty()){ - int p2start = path2.find_first_not_of('/'); + string::size_type p2start = path2.find_first_not_of('/'); - int p2end = path2.find_last_not_of('/'); + string::size_type p2end = path2.find_last_not_of('/'); string tmp = path2.substr(p2start, p2end - p2start + 1); buf += tmp + '/'; @@ -966,13 +966,13 @@ string const GetExtension(string const & name) string const MakeDisplayPath (string const & path, unsigned int threshold) { - int const l1 = path.length(); + string::size_type const l1 = path.length(); // First, we try a relative path compared to home string const home(GetEnvPath("HOME")); string relhome = MakeRelPath(path, home); - unsigned int l2 = relhome.length(); + string::size_type l2 = relhome.length(); string prefix; diff --git a/src/support/lstrings.C b/src/support/lstrings.C index 689a54be76..270af081b9 100644 --- a/src/support/lstrings.C +++ b/src/support/lstrings.C @@ -155,13 +155,13 @@ double strToDbl(string const & str) char lowercase(char c) { - return tolower(c); + return char( tolower(c) ); } char uppercase(char c) { - return toupper(c); + return char( toupper(c) ); } @@ -205,7 +205,7 @@ bool prefixIs(string const & a, char const * pre) { Assert(pre); - unsigned int const l = strlen(pre); + size_t const l = strlen(pre); string::size_type const alen = a.length(); if (l > alen || a.empty()) @@ -253,7 +253,7 @@ bool suffixIs(string const & a, char const * suf) { Assert(suf); - unsigned int const suflen = strlen(suf); + size_t const suflen = strlen(suf); if (suflen > a.length()) return false; else { @@ -353,7 +353,7 @@ bool containsOnly(char const * s, string const & cset) } -unsigned int countChar(string const & a, char c) +string::size_type countChar(string const & a, char c) { #ifdef HAVE_STD_COUNT return count(a.begin(), a.end(), c); @@ -441,7 +441,7 @@ string const subst(string const & a, string lstr(a); string::size_type i = 0; - int olen = strlen(oldstr); + string::size_type olen = strlen(oldstr); while((i = lstr.find(oldstr, i)) != string::npos) { lstr.replace(i, olen, newstr); i += newstr.length(); // We need to be sure that we dont diff --git a/src/support/lstrings.h b/src/support/lstrings.h index d718b57243..cc3e88acda 100644 --- a/src/support/lstrings.h +++ b/src/support/lstrings.h @@ -127,7 +127,7 @@ bool containsOnly(char const *, char const *); bool containsOnly(char const *, string const &); /// Counts how many of character c there is in a -unsigned int countChar(string const & a, char c); +string::size_type countChar(string const & a, char c); /** Extracts a token from this string at the nth delim. Doesn't modify the original string. Similar to strtok. diff --git a/src/support/lyxlib.h b/src/support/lyxlib.h index acaa2b0e4e..a159ee30d0 100644 --- a/src/support/lyxlib.h +++ b/src/support/lyxlib.h @@ -47,7 +47,7 @@ namespace lyx { /// void abort(); /// - int mkdir(string const & pathname, unsigned long int mode); + int mkdir(string const & pathname, mode_t mode); /// int putenv(char const * str); /// diff --git a/src/support/mkdir.C b/src/support/mkdir.C index e3a5102ecb..66f148821e 100644 --- a/src/support/mkdir.C +++ b/src/support/mkdir.C @@ -9,7 +9,7 @@ #include "lyxlib.h" -int lyx::mkdir(string const & pathname, unsigned long int mode) +int lyx::mkdir(string const & pathname, mode_t mode) { return ::mkdir(pathname.c_str(), mode); }