Remove tabs

This commit is contained in:
Eelco Dolstra 2013-01-03 13:00:46 +01:00
parent def5160b61
commit 3007f57377
2 changed files with 46 additions and 46 deletions

View File

@ -99,7 +99,7 @@ Path canonPath(const Path & path, bool resolveSymlinks)
i++; i++;
/* If `..', delete the last component. */ /* If `..', delete the last component. */
else if (*i == '.' && i + 1 < end && i[1] == '.' && else if (*i == '.' && i + 1 < end && i[1] == '.' &&
(i + 2 == end || i[2] == '/')) (i + 2 == end || i[2] == '/'))
{ {
if (!s.empty()) s.erase(s.rfind('/')); if (!s.empty()) s.erase(s.rfind('/'));
@ -214,7 +214,7 @@ string readFile(int fd)
struct stat st; struct stat st;
if (fstat(fd, &st) == -1) if (fstat(fd, &st) == -1)
throw SysError("statting file"); throw SysError("statting file");
unsigned char * buf = new unsigned char[st.st_size]; unsigned char * buf = new unsigned char[st.st_size];
AutoDeleteArray<unsigned char> d(buf); AutoDeleteArray<unsigned char> d(buf);
readFull(fd, buf, st.st_size); readFull(fd, buf, st.st_size);
@ -279,9 +279,9 @@ static void _computePathSize(const Path & path,
blocks += st.st_blocks; blocks += st.st_blocks;
if (S_ISDIR(st.st_mode)) { if (S_ISDIR(st.st_mode)) {
Strings names = readDirectory(path); Strings names = readDirectory(path);
for (Strings::iterator i = names.begin(); i != names.end(); ++i) for (Strings::iterator i = names.begin(); i != names.end(); ++i)
_computePathSize(path + "/" + *i, bytes, blocks); _computePathSize(path + "/" + *i, bytes, blocks);
} }
} }
@ -308,15 +308,15 @@ static void _deletePath(const Path & path, unsigned long long & bytesFreed)
bytesFreed += st.st_blocks * 512; bytesFreed += st.st_blocks * 512;
if (S_ISDIR(st.st_mode)) { if (S_ISDIR(st.st_mode)) {
Strings names = readDirectory(path); Strings names = readDirectory(path);
/* Make the directory writable. */ /* Make the directory writable. */
if (!(st.st_mode & S_IWUSR)) { if (!(st.st_mode & S_IWUSR)) {
if (chmod(path.c_str(), st.st_mode | S_IWUSR) == -1) if (chmod(path.c_str(), st.st_mode | S_IWUSR) == -1)
throw SysError(format("making `%1%' writable") % path); throw SysError(format("making `%1%' writable") % path);
} }
for (Strings::iterator i = names.begin(); i != names.end(); ++i) for (Strings::iterator i = names.begin(); i != names.end(); ++i)
_deletePath(path + "/" + *i, bytesFreed); _deletePath(path + "/" + *i, bytesFreed);
} }
@ -348,14 +348,14 @@ void makePathReadOnly(const Path & path)
struct stat st = lstat(path); struct stat st = lstat(path);
if (!S_ISLNK(st.st_mode) && (st.st_mode & S_IWUSR)) { if (!S_ISLNK(st.st_mode) && (st.st_mode & S_IWUSR)) {
if (chmod(path.c_str(), st.st_mode & ~S_IWUSR) == -1) if (chmod(path.c_str(), st.st_mode & ~S_IWUSR) == -1)
throw SysError(format("making `%1%' read-only") % path); throw SysError(format("making `%1%' read-only") % path);
} }
if (S_ISDIR(st.st_mode)) { if (S_ISDIR(st.st_mode)) {
Strings names = readDirectory(path); Strings names = readDirectory(path);
for (Strings::iterator i = names.begin(); i != names.end(); ++i) for (Strings::iterator i = names.begin(); i != names.end(); ++i)
makePathReadOnly(path + "/" + *i); makePathReadOnly(path + "/" + *i);
} }
} }
@ -377,25 +377,25 @@ Path createTempDir(const Path & tmpRoot, const Path & prefix,
static int globalCounter = 0; static int globalCounter = 0;
int localCounter = 0; int localCounter = 0;
int & counter(useGlobalCounter ? globalCounter : localCounter); int & counter(useGlobalCounter ? globalCounter : localCounter);
while (1) { while (1) {
checkInterrupt(); checkInterrupt();
Path tmpDir = tempName(tmpRoot, prefix, includePid, counter); Path tmpDir = tempName(tmpRoot, prefix, includePid, counter);
if (mkdir(tmpDir.c_str(), mode) == 0) { if (mkdir(tmpDir.c_str(), mode) == 0) {
/* Explicitly set the group of the directory. This is to /* Explicitly set the group of the directory. This is to
work around around problems caused by BSD's group work around around problems caused by BSD's group
ownership semantics (directories inherit the group of ownership semantics (directories inherit the group of
the parent). For instance, the group of /tmp on the parent). For instance, the group of /tmp on
FreeBSD is "wheel", so all directories created in /tmp FreeBSD is "wheel", so all directories created in /tmp
will be owned by "wheel"; but if the user is not in will be owned by "wheel"; but if the user is not in
"wheel", then "tar" will fail to unpack archives that "wheel", then "tar" will fail to unpack archives that
have the setgid bit set on directories. */ have the setgid bit set on directories. */
if (chown(tmpDir.c_str(), (uid_t) -1, getegid()) != 0) if (chown(tmpDir.c_str(), (uid_t) -1, getegid()) != 0)
throw SysError(format("setting group of directory `%1%'") % tmpDir); throw SysError(format("setting group of directory `%1%'") % tmpDir);
return tmpDir; return tmpDir;
} }
if (errno != EEXIST) if (errno != EEXIST)
throw SysError(format("creating directory `%1%'") % tmpDir); throw SysError(format("creating directory `%1%'") % tmpDir);
} }
} }
@ -415,7 +415,7 @@ Paths createDirs(const Path & path)
} }
if (!S_ISDIR(st.st_mode)) throw Error(format("`%1%' is not a directory") % path); if (!S_ISDIR(st.st_mode)) throw Error(format("`%1%' is not a directory") % path);
return created; return created;
} }
@ -724,8 +724,8 @@ AutoCloseDir::operator DIR *()
void AutoCloseDir::close() void AutoCloseDir::close()
{ {
if (dir) { if (dir) {
closedir(dir); closedir(dir);
dir = 0; dir = 0;
} }
} }
@ -840,12 +840,12 @@ void killUser(uid_t uid)
if (setuid(uid) == -1) if (setuid(uid) == -1)
throw SysError("setting uid"); throw SysError("setting uid");
while (true) { while (true) {
if (kill(-1, SIGKILL) == 0) break; if (kill(-1, SIGKILL) == 0) break;
if (errno == ESRCH) break; /* no more processes */ if (errno == ESRCH) break; /* no more processes */
if (errno != EINTR) if (errno != EINTR)
throw SysError(format("cannot kill processes for uid `%1%'") % uid); throw SysError(format("cannot kill processes for uid `%1%'") % uid);
} }
} catch (std::exception & e) { } catch (std::exception & e) {
writeToStderr((format("killing processes belonging to uid `%1%': %2%\n") % uid % e.what()).str()); writeToStderr((format("killing processes belonging to uid `%1%': %2%\n") % uid % e.what()).str());
@ -853,7 +853,7 @@ void killUser(uid_t uid)
} }
_exit(0); _exit(0);
} }
/* parent */ /* parent */
int status = pid.wait(true); int status = pid.wait(true);
if (status != 0) if (status != 0)
@ -1040,14 +1040,14 @@ string statusToString(int status)
if (WIFEXITED(status)) if (WIFEXITED(status))
return (format("failed with exit code %1%") % WEXITSTATUS(status)).str(); return (format("failed with exit code %1%") % WEXITSTATUS(status)).str();
else if (WIFSIGNALED(status)) { else if (WIFSIGNALED(status)) {
int sig = WTERMSIG(status); int sig = WTERMSIG(status);
#if HAVE_STRSIGNAL #if HAVE_STRSIGNAL
const char * description = strsignal(sig); const char * description = strsignal(sig);
return (format("failed due to signal %1% (%2%)") % sig % description).str(); return (format("failed due to signal %1% (%2%)") % sig % description).str();
#else #else
return (format("failed due to signal %1%") % sig).str(); return (format("failed due to signal %1%") % sig).str();
#endif #endif
} }
else else
return "died abnormally"; return "died abnormally";
} else return "succeeded"; } else return "succeeded";

View File

@ -174,7 +174,7 @@ struct AutoDeleteArray
{ {
T * p; T * p;
AutoDeleteArray(T * p) : p(p) { } AutoDeleteArray(T * p) : p(p) { }
~AutoDeleteArray() ~AutoDeleteArray()
{ {
delete [] p; delete [] p;
} }
@ -185,7 +185,7 @@ class AutoDelete
{ {
Path path; Path path;
bool del; bool del;
bool recursive; bool recursive;
public: public:
AutoDelete(const Path & p, bool recursive = true); AutoDelete(const Path & p, bool recursive = true);
~AutoDelete(); ~AutoDelete();