about summary refs log tree commit diff
path: root/src/libutil
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-08-20T15·00+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-08-20T16·03+0200
commit11849a320e4f522b97fcdf09ff0940496880475b (patch)
tree13548f1c1bb2e01590b31d66d9bb8f46534bc99f /src/libutil
parent373fad75e19a2f24db512621b8cedb627d03d49d (diff)
Use proper quotes everywhere
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/archive.cc18
-rw-r--r--src/libutil/hash.cc14
-rw-r--r--src/libutil/util.cc52
3 files changed, 42 insertions, 42 deletions
diff --git a/src/libutil/archive.cc b/src/libutil/archive.cc
index 6856ea0f2837..9e16e04ae4b5 100644
--- a/src/libutil/archive.cc
+++ b/src/libutil/archive.cc
@@ -43,7 +43,7 @@ static void dumpContents(const Path & path, size_t size,
     writeLongLong(size, sink);
 
     AutoCloseFD fd = open(path.c_str(), O_RDONLY);
-    if (fd == -1) throw SysError(format("opening file `%1%'") % path);
+    if (fd == -1) throw SysError(format("opening file ‘%1%’") % path);
 
     unsigned char buf[65536];
     size_t left = size;
@@ -63,7 +63,7 @@ static void dump(const Path & path, Sink & sink, PathFilter & filter)
 {
     struct stat st;
     if (lstat(path.c_str(), &st))
-        throw SysError(format("getting attributes of path `%1%'") % path);
+        throw SysError(format("getting attributes of path ‘%1%’") % path);
 
     writeString("(", sink);
 
@@ -89,11 +89,11 @@ static void dump(const Path & path, Sink & sink, PathFilter & filter)
                 string name(i.name);
                 size_t pos = i.name.find(caseHackSuffix);
                 if (pos != string::npos) {
-                    printMsg(lvlDebug, format("removing case hack suffix from `%1%'") % (path + "/" + i.name));
+                    printMsg(lvlDebug, format("removing case hack suffix from ‘%1%’") % (path + "/" + i.name));
                     name.erase(pos);
                 }
                 if (unhacked.find(name) != unhacked.end())
-                    throw Error(format("file name collision in between `%1%' and `%2%'")
+                    throw Error(format("file name collision in between ‘%1%’ and ‘%2%’")
                         % (path + "/" + unhacked[name]) % (path + "/" + i.name));
                 unhacked[name] = i.name;
             } else
@@ -118,7 +118,7 @@ static void dump(const Path & path, Sink & sink, PathFilter & filter)
         writeString(readLink(path), sink);
     }
 
-    else throw Error(format("file `%1%' has an unsupported type") % path);
+    else throw Error(format("file ‘%1%’ has an unsupported type") % path);
 
     writeString(")", sink);
 }
@@ -247,14 +247,14 @@ static void parse(ParseSink & sink, Source & source, const Path & path)
                 } else if (s == "name") {
                     name = readString(source);
                     if (name.empty() || name == "." || name == ".." || name.find('/') != string::npos || name.find((char) 0) != string::npos)
-                        throw Error(format("NAR contains invalid file name `%1%'") % name);
+                        throw Error(format("NAR contains invalid file name ‘%1%’") % name);
                     if (name <= prevName)
                         throw Error("NAR directory is not sorted");
                     prevName = name;
                     if (useCaseHack) {
                         auto i = names.find(name);
                         if (i != names.end()) {
-                            printMsg(lvlDebug, format("case collision between `%1%' and `%2%'") % i->first % name);
+                            printMsg(lvlDebug, format("case collision between ‘%1%’ and ‘%2%’") % i->first % name);
                             name += caseHackSuffix;
                             name += int2String(++i->second);
                         } else
@@ -303,7 +303,7 @@ struct RestoreSink : ParseSink
     {
         Path p = dstPath + path;
         if (mkdir(p.c_str(), 0777) == -1)
-            throw SysError(format("creating directory `%1%'") % p);
+            throw SysError(format("creating directory ‘%1%’") % p);
     };
 
     void createRegularFile(const Path & path)
@@ -311,7 +311,7 @@ struct RestoreSink : ParseSink
         Path p = dstPath + path;
         fd.close();
         fd = open(p.c_str(), O_CREAT | O_EXCL | O_WRONLY, 0666);
-        if (fd == -1) throw SysError(format("creating file `%1%'") % p);
+        if (fd == -1) throw SysError(format("creating file ‘%1%’") % p);
     }
 
     void isExecutable()
diff --git a/src/libutil/hash.cc b/src/libutil/hash.cc
index de2c1ebd724f..965f3ed47701 100644
--- a/src/libutil/hash.cc
+++ b/src/libutil/hash.cc
@@ -89,11 +89,11 @@ Hash parseHash(HashType ht, const string & s)
 {
     Hash hash(ht);
     if (s.length() != hash.hashSize * 2)
-        throw Error(format("invalid hash `%1%'") % s);
+        throw Error(format("invalid hash ‘%1%’") % s);
     for (unsigned int i = 0; i < hash.hashSize; i++) {
         string s2(s, i * 2, 2);
         if (!isxdigit(s2[0]) || !isxdigit(s2[1])) 
-            throw Error(format("invalid hash `%1%'") % s);
+            throw Error(format("invalid hash ‘%1%’") % s);
         std::istringstream str(s2);
         int n;
         str >> std::hex >> n;
@@ -200,10 +200,10 @@ Hash parseHash32(HashType ht, const string & s)
         for (digit = 0; digit < base32Chars.size(); ++digit) /* !!! slow */
             if (chars[digit] == c) break;
         if (digit >= 32)
-            throw Error(format("invalid base-32 hash `%1%'") % s);
+            throw Error(format("invalid base-32 hash ‘%1%’") % s);
         if (mul(hash.hash, 32, hash.hashSize) ||
             add(hash.hash, digit, hash.hashSize))
-            throw Error(format("base-32 hash `%1%' is too large") % s);
+            throw Error(format("base-32 hash ‘%1%’ is too large") % s);
     }
 
     return hash;
@@ -220,7 +220,7 @@ Hash parseHash16or32(HashType ht, const string & s)
         /* base-32 representation */
         hash = parseHash32(ht, s);
     else
-        throw Error(format("hash `%1%' has wrong length for hash type `%2%'")
+        throw Error(format("hash ‘%1%’ has wrong length for hash type ‘%2%’")
             % s % printHashType(ht));
     return hash;
 }
@@ -290,13 +290,13 @@ Hash hashFile(HashType ht, const Path & path)
     start(ht, ctx);
 
     AutoCloseFD fd = open(path.c_str(), O_RDONLY);
-    if (fd == -1) throw SysError(format("opening file `%1%'") % path);
+    if (fd == -1) throw SysError(format("opening file ‘%1%’") % path);
 
     unsigned char buf[8192];
     ssize_t n;
     while ((n = read(fd, buf, sizeof(buf)))) {
         checkInterrupt();
-        if (n == -1) throw SysError(format("reading file `%1%'") % path);
+        if (n == -1) throw SysError(format("reading file ‘%1%’") % path);
         update(ht, ctx, buf, n);
     }
     
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index 0600352ff537..825748792a9a 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -84,7 +84,7 @@ Path canonPath(const Path & path, bool resolveSymlinks)
     string s;
 
     if (path[0] != '/')
-        throw Error(format("not an absolute path: `%1%'") % path);
+        throw Error(format("not an absolute path: ‘%1%’") % path);
 
     string::const_iterator i = path.begin(), end = path.end();
     string temp;
@@ -120,7 +120,7 @@ Path canonPath(const Path & path, bool resolveSymlinks)
                the symlink target might contain new symlinks). */
             if (resolveSymlinks && isLink(s)) {
                 if (++followCount >= maxFollow)
-                    throw Error(format("infinite symlink recursion in path `%1%'") % path);
+                    throw Error(format("infinite symlink recursion in path ‘%1%’") % path);
                 temp = absPath(readLink(s), dirOf(s))
                     + string(i, end);
                 i = temp.begin(); /* restart */
@@ -139,7 +139,7 @@ Path dirOf(const Path & path)
 {
     Path::size_type pos = path.rfind('/');
     if (pos == string::npos)
-        throw Error(format("invalid file name `%1%'") % path);
+        throw Error(format("invalid file name ‘%1%’") % path);
     return pos == 0 ? "/" : Path(path, 0, pos);
 }
 
@@ -148,7 +148,7 @@ string baseNameOf(const Path & path)
 {
     Path::size_type pos = path.rfind('/');
     if (pos == string::npos)
-        throw Error(format("invalid file name `%1%'") % path);
+        throw Error(format("invalid file name ‘%1%’") % path);
     return string(path, pos + 1);
 }
 
@@ -166,7 +166,7 @@ struct stat lstat(const Path & path)
 {
     struct stat st;
     if (lstat(path.c_str(), &st))
-        throw SysError(format("getting status of `%1%'") % path);
+        throw SysError(format("getting status of ‘%1%’") % path);
     return st;
 }
 
@@ -188,10 +188,10 @@ Path readLink(const Path & path)
     checkInterrupt();
     struct stat st = lstat(path);
     if (!S_ISLNK(st.st_mode))
-        throw Error(format("`%1%' is not a symlink") % path);
+        throw Error(format("‘%1%’ is not a symlink") % path);
     char buf[st.st_size];
     if (readlink(path.c_str(), buf, st.st_size) != st.st_size)
-        throw SysError(format("reading symbolic link `%1%'") % path);
+        throw SysError(format("reading symbolic link ‘%1%’") % path);
     return string(buf, st.st_size);
 }
 
@@ -209,7 +209,7 @@ DirEntries readDirectory(const Path & path)
     entries.reserve(64);
 
     AutoCloseDir dir = opendir(path.c_str());
-    if (!dir) throw SysError(format("opening directory `%1%'") % path);
+    if (!dir) throw SysError(format("opening directory ‘%1%’") % path);
 
     struct dirent * dirent;
     while (errno = 0, dirent = readdir(dir)) { /* sic */
@@ -218,7 +218,7 @@ DirEntries readDirectory(const Path & path)
         if (name == "." || name == "..") continue;
         entries.emplace_back(name, dirent->d_ino, dirent->d_type);
     }
-    if (errno) throw SysError(format("reading directory `%1%'") % path);
+    if (errno) throw SysError(format("reading directory ‘%1%’") % path);
 
     return entries;
 }
@@ -242,7 +242,7 @@ string readFile(const Path & path, bool drain)
 {
     AutoCloseFD fd = open(path.c_str(), O_RDONLY);
     if (fd == -1)
-        throw SysError(format("opening file `%1%'") % path);
+        throw SysError(format("opening file ‘%1%’") % path);
     return drain ? drainFD(fd) : readFile(fd);
 }
 
@@ -251,7 +251,7 @@ void writeFile(const Path & path, const string & s)
 {
     AutoCloseFD fd = open(path.c_str(), O_WRONLY | O_TRUNC | O_CREAT, 0666);
     if (fd == -1)
-        throw SysError(format("opening file `%1%'") % path);
+        throw SysError(format("opening file ‘%1%’") % path);
     writeFull(fd, (unsigned char *) s.data(), s.size());
 }
 
@@ -298,7 +298,7 @@ static void _deletePath(const Path & path, unsigned long long & bytesFreed)
         /* Make the directory writable. */
         if (!(st.st_mode & S_IWUSR)) {
             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 (auto & i : readDirectory(path))
@@ -306,7 +306,7 @@ static void _deletePath(const Path & path, unsigned long long & bytesFreed)
     }
 
     if (remove(path.c_str()) == -1)
-        throw SysError(format("cannot unlink `%1%'") % path);
+        throw SysError(format("cannot unlink ‘%1%’") % path);
 }
 
 
@@ -320,7 +320,7 @@ void deletePath(const Path & path)
 void deletePath(const Path & path, unsigned long long & bytesFreed)
 {
     startNest(nest, lvlDebug,
-        format("recursively deleting path `%1%'") % path);
+        format("recursively deleting path ‘%1%’") % path);
     bytesFreed = 0;
     _deletePath(path, bytesFreed);
 }
@@ -357,11 +357,11 @@ Path createTempDir(const Path & tmpRoot, const Path & prefix,
                "wheel", then "tar" will fail to unpack archives that
                have the setgid bit set on directories. */
             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;
         }
         if (errno != EEXIST)
-            throw SysError(format("creating directory `%1%'") % tmpDir);
+            throw SysError(format("creating directory ‘%1%’") % tmpDir);
     }
 }
 
@@ -375,12 +375,12 @@ Paths createDirs(const Path & path)
     if (lstat(path.c_str(), &st) == -1) {
         created = createDirs(dirOf(path));
         if (mkdir(path.c_str(), 0777) == -1 && errno != EEXIST)
-            throw SysError(format("creating directory `%1%'") % path);
+            throw SysError(format("creating directory ‘%1%’") % path);
         st = lstat(path);
         created.push_back(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;
 }
@@ -389,7 +389,7 @@ Paths createDirs(const Path & path)
 void createSymlink(const Path & target, const Path & link)
 {
     if (symlink(target.c_str(), link.c_str()))
-        throw SysError(format("creating symlink from `%1%' to `%2%'") % link % target);
+        throw SysError(format("creating symlink from ‘%1%’ to ‘%2%’") % link % target);
 }
 
 
@@ -560,7 +560,7 @@ AutoDelete::~AutoDelete()
                 deletePath(path);
             else {
                 if (remove(path.c_str()) == -1)
-                    throw SysError(format("cannot unlink `%1%'") % path);
+                    throw SysError(format("cannot unlink ‘%1%’") % path);
             }
         }
     } catch (...) {
@@ -801,7 +801,7 @@ void Pid::setKillSignal(int signal)
 
 void killUser(uid_t uid)
 {
-    debug(format("killing all processes running under uid `%1%'") % uid);
+    debug(format("killing all processes running under uid ‘%1%’") % uid);
 
     assert(uid != 0); /* just to be safe... */
 
@@ -827,7 +827,7 @@ void killUser(uid_t uid)
 #endif
             if (errno == ESRCH) break; /* no more processes */
             if (errno != EINTR)
-                throw SysError(format("cannot kill processes for uid `%1%'") % uid);
+                throw SysError(format("cannot kill processes for uid ‘%1%’") % uid);
         }
 
         _exit(0);
@@ -835,7 +835,7 @@ void killUser(uid_t uid)
 
     int status = pid.wait(true);
     if (status != 0)
-        throw Error(format("cannot kill processes for uid `%1%': %2%") % uid % statusToString(status));
+        throw Error(format("cannot kill processes for uid ‘%1%’: %2%") % uid % statusToString(status));
 
     /* !!! We should really do some check to make sure that there are
        no processes left running under `uid', but there is no portable
@@ -893,7 +893,7 @@ string runProgram(Path program, bool searchPath, const Strings & args)
         else
             execv(program.c_str(), (char * *) &cargs[0]);
 
-        throw SysError(format("executing `%1%'") % program);
+        throw SysError(format("executing ‘%1%’") % program);
     });
 
     pipe.writeSide.close();
@@ -903,7 +903,7 @@ string runProgram(Path program, bool searchPath, const Strings & args)
     /* Wait for the child to finish. */
     int status = pid.wait(true);
     if (!statusOk(status))
-        throw ExecError(format("program `%1%' %2%")
+        throw ExecError(format("program ‘%1%’ %2%")
             % program % statusToString(status));
 
     return result;
@@ -1046,7 +1046,7 @@ void expect(std::istream & str, const string & s)
     char s2[s.size()];
     str.read(s2, s.size());
     if (string(s2, s.size()) != s)
-        throw FormatError(format("expected string `%1%'") % s);
+        throw FormatError(format("expected string ‘%1%’") % s);
 }