+2000-10-18 Angus Leeming <a.leeming@ic.ac.uk>
+ * 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 <Jean-Marc.Lasgouttes@inria.fr>
* src/minibuffer.C (peek_event): retun 1 when there has been a
- 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.
// 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' : '-';
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;
{
regmatch_t tmp;
regexec(preg, str.c_str(), 1, &tmp, 0);
- unsigned int const first = tmp.rm_so != -1 ?
- static_cast<unsigned int>(tmp.rm_so) : string::npos;
- unsigned int const second = tmp.rm_eo != -1 ?
- static_cast<unsigned int>(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);
}
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<unsigned int>
- (mat[i].rm_so) : string::npos;
+ mat[i].rm_so : string::npos;
second = mat[i].rm_eo != -1 ?
- static_cast<unsigned int>
- (mat[i].rm_eo) : string::npos;
+ mat[i].rm_eo : string::npos;
matches.push_back(make_pair(first,
second - first));
}
*/
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';
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;
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] == '/')
if (abspath.empty())
return "<unknown_path>";
- 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;
}
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 + '/';
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;
char lowercase(char c)
{
- return tolower(c);
+ return char( tolower(c) );
}
char uppercase(char c)
{
- return toupper(c);
+ return char( toupper(c) );
}
{
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())
{
Assert(suf);
- unsigned int const suflen = strlen(suf);
+ size_t const suflen = strlen(suf);
if (suflen > a.length())
return false;
else {
}
-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);
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
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.
///
void abort();
///
- int mkdir(string const & pathname, unsigned long int mode);
+ int mkdir(string const & pathname, mode_t mode);
///
int putenv(char const * str);
///
#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);
}