diff options
author | Guillaume Maudoux <layus.on@gmail.com> | 2016-11-25T14·48+0100 |
---|---|---|
committer | Domen Kožar <domen@dev.si> | 2016-11-25T14·48+0100 |
commit | f78126bfd6b6c8477fcdbc09b2f98772dbe9a1e7 (patch) | |
tree | 23a76a33f21ce39184bcbdcd28cb937d15968ce7 /src/libutil | |
parent | 7ee43df8622cc0589d54248fb44cebe1c1d991d2 (diff) |
Get rid of unicode quotes (#1140)
Diffstat (limited to 'src/libutil')
-rw-r--r-- | src/libutil/archive.cc | 18 | ||||
-rw-r--r-- | src/libutil/args.cc | 10 | ||||
-rw-r--r-- | src/libutil/args.hh | 2 | ||||
-rw-r--r-- | src/libutil/compression.cc | 4 | ||||
-rw-r--r-- | src/libutil/hash.cc | 16 | ||||
-rw-r--r-- | src/libutil/pool.hh | 4 | ||||
-rw-r--r-- | src/libutil/serialise.hh | 4 | ||||
-rw-r--r-- | src/libutil/types.hh | 6 | ||||
-rw-r--r-- | src/libutil/util.cc | 56 | ||||
-rw-r--r-- | src/libutil/util.hh | 14 |
10 files changed, 67 insertions, 67 deletions
diff --git a/src/libutil/archive.cc b/src/libutil/archive.cc index fbba7f853f95..93e1ce20f933 100644 --- a/src/libutil/archive.cc +++ b/src/libutil/archive.cc @@ -40,7 +40,7 @@ static void dumpContents(const Path & path, size_t size, sink << "contents" << size; AutoCloseFD fd = open(path.c_str(), O_RDONLY | O_CLOEXEC); - if (!fd) throw SysError(format("opening file ‘%1%’") % path); + if (!fd) throw SysError(format("opening file '%1%'") % path); unsigned char buf[65536]; size_t left = size; @@ -60,7 +60,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); sink << "("; @@ -82,11 +82,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) { - debug(format("removing case hack suffix from ‘%1%’") % (path + "/" + i.name)); + debug(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 @@ -103,7 +103,7 @@ static void dump(const Path & path, Sink & sink, PathFilter & filter) else if (S_ISLNK(st.st_mode)) sink << "type" << "symlink" << "target" << readLink(path); - else throw Error(format("file ‘%1%’ has an unsupported type") % path); + else throw Error(format("file '%1%' has an unsupported type") % path); sink << ")"; } @@ -239,14 +239,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()) { - debug(format("case collision between ‘%1%’ and ‘%2%’") % i->first % name); + debug(format("case collision between '%1%' and '%2%'") % i->first % name); name += caseHackSuffix; name += std::to_string(++i->second); } else @@ -295,14 +295,14 @@ 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) { Path p = dstPath + path; fd = open(p.c_str(), O_CREAT | O_EXCL | O_WRONLY | O_CLOEXEC, 0666); - if (!fd) throw SysError(format("creating file ‘%1%’") % p); + if (!fd) throw SysError(format("creating file '%1%'") % p); } void isExecutable() diff --git a/src/libutil/args.cc b/src/libutil/args.cc index 115484f9e6c7..e381a299f027 100644 --- a/src/libutil/args.cc +++ b/src/libutil/args.cc @@ -35,7 +35,7 @@ void Args::parseCmdline(const Strings & _cmdline) } else if (!dashDash && std::string(arg, 0, 1) == "-") { if (!processFlag(pos, cmdline.end())) - throw UsageError(format("unrecognised flag ‘%1%’") % arg); + throw UsageError(format("unrecognised flag '%1%'") % arg); } else { pendingArgs.push_back(*pos++); @@ -88,7 +88,7 @@ bool Args::processFlag(Strings::iterator & pos, Strings::iterator end) Strings args; for (size_t n = 0 ; n < flag.arity; ++n) { if (pos == end) - throw UsageError(format("flag ‘%1%’ requires %2% argument(s)") + throw UsageError(format("flag '%1%' requires %2% argument(s)") % name % flag.arity); args.push_back(*pos++); } @@ -116,7 +116,7 @@ bool Args::processArgs(const Strings & args, bool finish) { if (expectedArgs.empty()) { if (!args.empty()) - throw UsageError(format("unexpected argument ‘%1%’") % args.front()); + throw UsageError(format("unexpected argument '%1%'") % args.front()); return true; } @@ -140,10 +140,10 @@ bool Args::processArgs(const Strings & args, bool finish) void Args::mkHashTypeFlag(const std::string & name, HashType * ht) { - mkFlag1(0, name, "TYPE", "hash algorithm (‘md5’, ‘sha1’, ‘sha256’, or ‘sha512’)", [=](std::string s) { + mkFlag1(0, name, "TYPE", "hash algorithm ('md5', 'sha1', 'sha256', or 'sha512')", [=](std::string s) { *ht = parseHashType(s); if (*ht == htUnknown) - throw UsageError(format("unknown hash type ‘%1%’") % s); + throw UsageError(format("unknown hash type '%1%'") % s); }); } diff --git a/src/libutil/args.hh b/src/libutil/args.hh index ac12f8be633a..aa0f45a653a8 100644 --- a/src/libutil/args.hh +++ b/src/libutil/args.hh @@ -126,7 +126,7 @@ public: mkFlag(shortName, longName, {"N"}, description, 1, [=](Strings ss) { I n; if (!string2Int(ss.front(), n)) - throw UsageError(format("flag ‘--%1%’ requires a integer argument") % longName); + throw UsageError(format("flag '--%1%' requires a integer argument") % longName); fun(n); }); } diff --git a/src/libutil/compression.cc b/src/libutil/compression.cc index a3bbb5170d9f..0532c9699d38 100644 --- a/src/libutil/compression.cc +++ b/src/libutil/compression.cc @@ -107,7 +107,7 @@ ref<std::string> decompress(const std::string & method, const std::string & in) else if (method == "bzip2") return decompressBzip2(in); else - throw UnknownCompressionMethod(format("unknown compression method ‘%s’") % method); + throw UnknownCompressionMethod(format("unknown compression method '%s'") % method); } struct NoneSink : CompressionSink @@ -270,7 +270,7 @@ ref<CompressionSink> makeCompressionSink(const std::string & method, Sink & next else if (method == "bzip2") return make_ref<BzipSink>(nextSink); else - throw UnknownCompressionMethod(format("unknown compression method ‘%s’") % method); + throw UnknownCompressionMethod(format("unknown compression method '%s'") % method); } } diff --git a/src/libutil/hash.cc b/src/libutil/hash.cc index 49e781980f3a..27bd010956b1 100644 --- a/src/libutil/hash.cc +++ b/src/libutil/hash.cc @@ -88,11 +88,11 @@ Hash parseHash(const string & s) { string::size_type colon = s.find(':'); if (colon == string::npos) - throw BadHash(format("invalid hash ‘%s’") % s); + throw BadHash(format("invalid hash '%s'") % s); string hts = string(s, 0, colon); HashType ht = parseHashType(hts); if (ht == htUnknown) - throw BadHash(format("unknown hash type ‘%s’") % hts); + throw BadHash(format("unknown hash type '%s'") % hts); return parseHash16or32(ht, string(s, colon + 1)); } @@ -101,11 +101,11 @@ Hash parseHash(HashType ht, const string & s) { Hash hash(ht); if (s.length() != hash.hashSize * 2) - throw BadHash(format("invalid hash ‘%1%’") % s); + throw BadHash(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 BadHash(format("invalid hash ‘%1%’") % s); + throw BadHash(format("invalid hash '%1%'") % s); istringstream_nocopy str(s2); int n; str >> std::hex >> n; @@ -160,7 +160,7 @@ Hash parseHash32(HashType ht, const string & s) for (digit = 0; digit < base32Chars.size(); ++digit) /* !!! slow */ if (base32Chars[digit] == c) break; if (digit >= 32) - throw BadHash(format("invalid base-32 hash ‘%1%’") % s); + throw BadHash(format("invalid base-32 hash '%1%'") % s); unsigned int b = n * 5; unsigned int i = b / 8; unsigned int j = b % 8; @@ -182,7 +182,7 @@ Hash parseHash16or32(HashType ht, const string & s) /* base-32 representation */ hash = parseHash32(ht, s); else - throw BadHash(format("hash ‘%1%’ has wrong length for hash type ‘%2%’") + throw BadHash(format("hash '%1%' has wrong length for hash type '%2%'") % s % printHashType(ht)); return hash; } @@ -256,13 +256,13 @@ Hash hashFile(HashType ht, const Path & path) start(ht, ctx); AutoCloseFD fd = open(path.c_str(), O_RDONLY | O_CLOEXEC); - if (!fd) throw SysError(format("opening file ‘%1%’") % path); + if (!fd) throw SysError(format("opening file '%1%'") % path); unsigned char buf[8192]; ssize_t n; while ((n = read(fd.get(), 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/pool.hh b/src/libutil/pool.hh index f291cd578388..c1cea5723627 100644 --- a/src/libutil/pool.hh +++ b/src/libutil/pool.hh @@ -24,8 +24,8 @@ namespace nix { conn->exec("select ..."); } - Here, the Connection object referenced by ‘conn’ is automatically - returned to the pool when ‘conn’ goes out of scope. + Here, the Connection object referenced by 'conn' is automatically + returned to the pool when 'conn' goes out of scope. */ template <class R> diff --git a/src/libutil/serialise.hh b/src/libutil/serialise.hh index f12f02543bc0..b229fc58c296 100644 --- a/src/libutil/serialise.hh +++ b/src/libutil/serialise.hh @@ -50,12 +50,12 @@ struct Source { virtual ~Source() { } - /* Store exactly ‘len’ bytes in the buffer pointed to by ‘data’. + /* Store exactly 'len' bytes in the buffer pointed to by 'data'. It blocks until all the requested data is available, or throws an error if it is not going to be available. */ void operator () (unsigned char * data, size_t len); - /* Store up to ‘len’ in the buffer pointed to by ‘data’, and + /* Store up to 'len' in the buffer pointed to by 'data', and return the number of bytes stored. If blocks until at least one byte is available. */ virtual size_t read(unsigned char * data, size_t len) = 0; diff --git a/src/libutil/types.hh b/src/libutil/types.hh index b9a93d27d2ad..6834257012d6 100644 --- a/src/libutil/types.hh +++ b/src/libutil/types.hh @@ -41,9 +41,9 @@ struct FormatOrString }; -/* A helper for formatting strings. ‘fmt(format, a_0, ..., a_n)’ is - equivalent to ‘boost::format(format) % a_0 % ... % - ... a_n’. However, ‘fmt(s)’ is equivalent to ‘s’ (so no %-expansion +/* A helper for formatting strings. 'fmt(format, a_0, ..., a_n)' is + equivalent to 'boost::format(format) % a_0 % ... % + ... a_n'. However, 'fmt(s)' is equivalent to 's' (so no %-expansion takes place). */ inline void formatHelper(boost::format & f) diff --git a/src/libutil/util.cc b/src/libutil/util.cc index ce16cc30a5c7..c4dfdd96ea2b 100644 --- a/src/libutil/util.cc +++ b/src/libutil/util.cc @@ -97,7 +97,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; @@ -133,7 +133,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 */ @@ -151,7 +151,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); } @@ -188,7 +188,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; } @@ -210,13 +210,13 @@ 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]; ssize_t rlsize = readlink(path.c_str(), buf, st.st_size); if (rlsize == -1) - throw SysError(format("reading symbolic link ‘%1%’") % path); + throw SysError(format("reading symbolic link '%1%'") % path); else if (rlsize > st.st_size) - throw Error(format("symbolic link ‘%1%’ size overflow %2% > %3%") + throw Error(format("symbolic link '%1%' size overflow %2% > %3%") % path % rlsize % st.st_size); return string(buf, rlsize); } @@ -235,7 +235,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 */ @@ -250,7 +250,7 @@ DirEntries readDirectory(const Path & path) #endif ); } - if (errno) throw SysError(format("reading directory ‘%1%’") % path); + if (errno) throw SysError(format("reading directory '%1%'") % path); return entries; } @@ -284,7 +284,7 @@ string readFile(const Path & path, bool drain) { AutoCloseFD fd = open(path.c_str(), O_RDONLY | O_CLOEXEC); if (!fd) - throw SysError(format("opening file ‘%1%’") % path); + throw SysError(format("opening file '%1%'") % path); return drain ? drainFD(fd.get()) : readFile(fd.get()); } @@ -293,7 +293,7 @@ void writeFile(const Path & path, const string & s) { AutoCloseFD fd = open(path.c_str(), O_WRONLY | O_TRUNC | O_CREAT | O_CLOEXEC, 0666); if (!fd) - throw SysError(format("opening file ‘%1%’") % path); + throw SysError(format("opening file '%1%'") % path); writeFull(fd.get(), s); } @@ -332,7 +332,7 @@ static void _deletePath(const Path & path, unsigned long long & bytesFreed) struct stat st; if (lstat(path.c_str(), &st) == -1) { if (errno == ENOENT) return; - throw SysError(format("getting status of ‘%1%’") % path); + throw SysError(format("getting status of '%1%'") % path); } if (!S_ISDIR(st.st_mode) && st.st_nlink == 1) @@ -343,7 +343,7 @@ static void _deletePath(const Path & path, unsigned long long & bytesFreed) const auto PERM_MASK = S_IRUSR | S_IWUSR | S_IXUSR; if ((st.st_mode & PERM_MASK) != PERM_MASK) { if (chmod(path.c_str(), st.st_mode | PERM_MASK) == -1) - throw SysError(format("chmod ‘%1%’") % path); + throw SysError(format("chmod '%1%'") % path); } for (auto & i : readDirectory(path)) @@ -352,7 +352,7 @@ static void _deletePath(const Path & path, unsigned long long & bytesFreed) if (remove(path.c_str()) == -1) { if (errno == ENOENT) return; - throw SysError(format("cannot unlink ‘%1%’") % path); + throw SysError(format("cannot unlink '%1%'") % path); } } @@ -366,7 +366,7 @@ void deletePath(const Path & path) void deletePath(const Path & path, unsigned long long & bytesFreed) { - Activity act(*logger, lvlDebug, format("recursively deleting path ‘%1%’") % path); + Activity act(*logger, lvlDebug, format("recursively deleting path '%1%'") % path); bytesFreed = 0; _deletePath(path, bytesFreed); } @@ -404,12 +404,12 @@ 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); #endif return tmpDir; } if (errno != EEXIST) - throw SysError(format("creating directory ‘%1%’") % tmpDir); + throw SysError(format("creating directory '%1%'") % tmpDir); } } @@ -435,15 +435,15 @@ 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_ISLNK(st.st_mode) && stat(path.c_str(), &st) == -1) - throw SysError(format("statting symlink ‘%1%’") % path); + throw SysError(format("statting symlink '%1%'") % 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; } @@ -452,7 +452,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); } @@ -463,7 +463,7 @@ void replaceSymlink(const Path & target, const Path & link) createSymlink(target, tmp); if (rename(tmp.c_str(), link.c_str()) != 0) - throw SysError(format("renaming ‘%1%’ to ‘%2%’") % tmp % link); + throw SysError(format("renaming '%1%' to '%2%'") % tmp % link); } @@ -542,7 +542,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 (...) { @@ -788,7 +788,7 @@ pid_t Pid::release() 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... */ @@ -817,7 +817,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); @@ -825,7 +825,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 @@ -919,7 +919,7 @@ string runProgram(Path program, bool searchPath, const Strings & args, else execv(program.c_str(), stringsToCharPtrs(args_).data()); - throw SysError(format("executing ‘%1%’") % program); + throw SysError(format("executing '%1%'") % program); }); out.writeSide = -1; @@ -936,7 +936,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(status, format("program ‘%1%’ %2%") + throw ExecError(status, format("program '%1%' %2%") % program % statusToString(status)); return result; diff --git a/src/libutil/util.hh b/src/libutil/util.hh index 1ede48a65ff2..5ffdbaa8869e 100644 --- a/src/libutil/util.hh +++ b/src/libutil/util.hh @@ -370,7 +370,7 @@ void ignoreException(); #define ANSI_RED "\e[31;1m" -/* Filter out ANSI escape codes from the given string. If ‘nixOnly’ is +/* Filter out ANSI escape codes from the given string. If 'nixOnly' is set, only filter escape codes generated by Nixpkgs' stdenv (used to denote nesting etc.). */ string filterANSIEscapes(const string & s, bool nixOnly = false); @@ -391,15 +391,15 @@ string get(const T & map, const string & key, const string & def = "") } -/* Call ‘failure’ with the current exception as argument. If ‘failure’ +/* Call 'failure' with the current exception as argument. If 'failure' throws an exception, abort the program. */ void callFailure(const std::function<void(std::exception_ptr exc)> & failure, std::exception_ptr exc = std::current_exception()); -/* Evaluate the function ‘f’. If it returns a value, call ‘success’ - with that value as its argument. If it or ‘success’ throws an - exception, call ‘failure’. If ‘failure’ throws an exception, abort +/* Evaluate the function 'f'. If it returns a value, call 'success' + with that value as its argument. If it or 'success' throws an + exception, call 'failure'. If 'failure' throws an exception, abort the program. */ template<class T> void sync2async( @@ -415,8 +415,8 @@ void sync2async( } -/* Call the function ‘success’. If it throws an exception, call - ‘failure’. If that throws an exception, abort the program. */ +/* Call the function 'success'. If it throws an exception, call + 'failure'. If that throws an exception, abort the program. */ template<class T> void callSuccess( const std::function<void(T)> & success, |