#endif
string qname = name;
while (qname.find("'") != string::npos)
- LSubstring(qname,"'") = "\\'";
+ LSubstring(qname, "'") = "\\'";
return '\'' + qname + '\'';
}
// a short string...
string ret;
FileInfo fnfo;
- for (int a= 'a'; a<= 'z'; ++a)
- for (int b= 'a'; b<= 'z'; ++b)
- for (int c= 'a'; c<= 'z'; ++c) {
+ for (int a = 'a'; a <= 'z'; ++a)
+ for (int b = 'a'; b <= 'z'; ++b)
+ for (int c = 'a'; c <= 'z'; ++c) {
// if this is not enough I have no idea what
// to do.
ret = tmpfl + char(a) + char(b) + char(c);
}
}
}
- if (remove (tmpfl.c_str())) {
+ if (remove(tmpfl.c_str())) {
WriteFSAlert(_("LyX Internal Error!"),
_("Created test file but cannot remove it?"));
return -1;
// 2) build_lyxdir (if not empty)
// 3) system_lyxdir
string LibFileSearch(string const & dir, string const & name,
- string const & ext)
+ string const & ext)
{
- string fullname = FileSearch(AddPath(user_lyxdir, dir), name,
- ext);
+ string fullname = FileSearch(AddPath(user_lyxdir, dir),
+ name, ext);
if (!fullname.empty())
return fullname;
string i18nLibFileSearch(string const & dir, string const & name,
- string const & ext)
+ string const & ext)
{
string lang = token(string(GetEnv("LANG")), '_', 0);
#warning Look at and fix this.
#endif
// f.ex. what about error checking?
- int retval = 0;
#if HAVE_PUTENV
// this leaks, but what can we do about it?
// Is doing a getenv() and a free() of the older value
// a good idea? (JMarc)
- retval = putenv((new string(envstr))->c_str());
+ int retval = putenv((new string(envstr))->c_str());
#else
#ifdef HAVE_SETENV
string varname;
string str = envstr.split(varname,'=');
- retval = setenv(varname.c_str(), str.c_str(), true);
+ int retval = setenv(varname.c_str(), str.c_str(), true);
#endif
#endif
return retval == 0;
static
int DeleteAllFilesInDir (string const & path)
{
- struct dirent * de;
DIR * dir = opendir(path.c_str());
if (!dir) {
WriteFSAlert (_("Error! Cannot open directory:"), path);
return -1;
}
+ struct dirent * de;
while ((de = readdir(dir))) {
string temp = de->d_name;
if (temp == "." || temp == "..")
lyxerr.debug() << "Deleting file: " << unlinkpath << endl;
- if (remove (unlinkpath.c_str()))
+ if (remove(unlinkpath.c_str()))
WriteFSAlert (_("Error! Could not remove file:"),
unlinkpath);
}
- closedir (dir);
+ closedir(dir);
return 0;
}
string CreateBufferTmpDir (string const & pathfor)
{
- return CreateTmpDir (pathfor, "lyx_bufrtmp");
+ return CreateTmpDir(pathfor, "lyx_bufrtmp");
}
int DestroyBufferTmpDir (string const & tmpdir)
{
- return DestroyTmpDir (tmpdir, true);
+ return DestroyTmpDir(tmpdir, true);
}
string CreateLyXTmpDir (string const & deflt)
{
- string t;
-
if ((!deflt.empty()) && (deflt != "/tmp")) {
- if (mkdir (deflt.c_str(), 0777)) {
+ if (mkdir(deflt.c_str(), 0777)) {
#ifdef __EMX__
Path p(user_lyxdir);
#endif
- t = CreateTmpDir (deflt.c_str(), "lyx_tmp");
+ string t = CreateTmpDir (deflt.c_str(), "lyx_tmp");
return t;
} else
return deflt;
#ifdef __EMX__
Path p(user_lyxdir);
#endif
- t = CreateTmpDir ("/tmp", "lyx_tmp");
+ string t = CreateTmpDir ("/tmp", "lyx_tmp");
return t;
}
}
int n = 256; // Assume path is less than 256 chars
char * err;
char * tbuf = new char[n];
- string result;
// Safe. Hopefully all getcwds behave this way!
while (((err = lyx::getcwd (tbuf, n)) == 0) && (errno == ERANGE)) {
tbuf = new char[n];
}
+ string result;
if (err) result = tbuf;
delete[] tbuf;
return result;
if (Temp == ".") continue;
if (Temp == "..") {
// Remove one level of TempBase
- int i = TempBase.length()-2;
+ int i = TempBase.length() - 2;
#ifndef __EMX__
if (i < 0) i = 0;
while (i > 0 && TempBase[i] != '/') --i;
}
// returns absolute path
- return TempBase;
+ return TempBase;
}
TempBase = "./";
} else if (Temp == "..") {
// Remove one level of TempBase
- int i = TempBase.length()-2;
- while (i>0 && TempBase[i] != '/')
+ int i = TempBase.length() - 2;
+ while (i > 0 && TempBase[i] != '/')
--i;
- if (i>= 0 && TempBase[i] == '/')
- TempBase.erase(i+1, string::npos);
+ if (i >= 0 && TempBase[i] == '/')
+ TempBase.erase(i + 1, string::npos);
else
TempBase = "../";
} else {
if (*res1_contents != FirstChar) {
// Again No Environmentvariable
result1 += CompareString;
- result0 = res0;
+ result0 = res0;
}
// Check for variable names
// Situation ${} is detected as "No Environmentvariable"
- char const * cp1 = res1_contents+1;
+ char const * cp1 = res1_contents + 1;
bool result = isalpha(*cp1) || (*cp1 == UnderscoreChar);
++cp1;
while (*cp1 && result) {
// Append relative stuff from common directory to abspath
if (abspath[i] == '/') ++i;
- for (; i<abslen; ++i)
+ for (; i < abslen; ++i)
buf += abspath[i];
// Remove trailing /
if (suffixIs(buf, '/'))
if (!path.empty() && path != "." && path != "./") {
buf = CleanupPath(path);
if (path[path.length() - 1] != '/')
-
buf += '/';
}
}
-
// Creates a nice compact path for displaying
string MakeDisplayPath (string const & path, unsigned int threshold)
{
bool LyXReadLink(string const & File, string & Link)
{
char LinkBuffer[512];
- // Should be PATH_MAX but that needs autconf support
- int nRead;
- nRead = readlink(File.c_str(), LinkBuffer, sizeof(LinkBuffer)-1);
+ // Should be PATH_MAX but that needs autconf support
+ int nRead = readlink(File.c_str(), LinkBuffer, sizeof(LinkBuffer)-1);
if (nRead <= 0)
return false;
LinkBuffer[nRead] = 0;