diff options
author | Jörg Thalheim <joerg@thalheim.io> | 2017-07-30 12:27:57 +0100 |
---|---|---|
committer | Jörg Thalheim <joerg@thalheim.io> | 2017-07-30 12:32:45 +0100 |
commit | 2fd8f8bb99a2832b3684878c020ba47322e79332 (patch) | |
tree | 65a667fbc746f4ff8efcaca3c0a58565985f26a5 /src/libutil | |
parent | c7654bc491d9ce7c1fbadecd7769418fa79a2060 (diff) |
Replace Unicode quotes in user-facing strings by ASCII
Relevant RFC: NixOS/rfcs#4
$ ag -l | xargs sed -i -e "/\"/s/’/'/g;/\"/s/‘/'/g"
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/config.cc | 2 | ||||
-rw-r--r-- | src/libutil/hash.cc | 18 | ||||
-rw-r--r-- | src/libutil/hash.hh | 2 | ||||
-rw-r--r-- | src/libutil/serialise.hh | 2 | ||||
-rw-r--r-- | src/libutil/util.cc | 56 |
9 files changed, 57 insertions, 57 deletions
diff --git a/src/libutil/archive.cc b/src/libutil/archive.cc index e0e6f5dfd..be527450c 100644 --- a/src/libutil/archive.cc +++ b/src/libutil/archive.cc @@ -38,7 +38,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; @@ -58,7 +58,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 << "("; @@ -80,11 +80,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 @@ -101,7 +101,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 << ")"; } @@ -237,14 +237,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 @@ -293,14 +293,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 19a45d7e9..2b72079f2 100644 --- a/src/libutil/args.cc +++ b/src/libutil/args.cc @@ -47,7 +47,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++); @@ -103,7 +103,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++); } @@ -131,7 +131,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; } @@ -155,10 +155,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 37e780dd1..fd910b965 100644 --- a/src/libutil/args.hh +++ b/src/libutil/args.hh @@ -158,7 +158,7 @@ public: .handler([=](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 b0b1d709f..2b3dff3a5 100644 --- a/src/libutil/compression.cc +++ b/src/libutil/compression.cc @@ -118,7 +118,7 @@ ref<std::string> decompress(const std::string & method, const std::string & in) else if (method == "br") return decompressBrotli(in); else - throw UnknownCompressionMethod(format("unknown compression method ‘%s’") % method); + throw UnknownCompressionMethod(format("unknown compression method '%s'") % method); } struct NoneSink : CompressionSink @@ -309,7 +309,7 @@ ref<CompressionSink> makeCompressionSink(const std::string & method, Sink & next else if (method == "br") return make_ref<BrotliSink>(nextSink); else - throw UnknownCompressionMethod(format("unknown compression method ‘%s’") % method); + throw UnknownCompressionMethod(format("unknown compression method '%s'") % method); } } diff --git a/src/libutil/config.cc b/src/libutil/config.cc index 0682bcd5d..27157a831 100644 --- a/src/libutil/config.cc +++ b/src/libutil/config.cc @@ -81,7 +81,7 @@ void Config::applyConfigFile(const Path & path, bool fatal) if (tokens.empty()) continue; if (tokens.size() < 2 || tokens[1] != "=") - throw UsageError("illegal configuration line ‘%1%’ in ‘%2%’", line, path); + throw UsageError("illegal configuration line '%1%' in '%2%'", line, path); string name = tokens[0]; diff --git a/src/libutil/hash.cc b/src/libutil/hash.cc index e16c3b6ea..11e3c9dca 100644 --- a/src/libutil/hash.cc +++ b/src/libutil/hash.cc @@ -133,14 +133,14 @@ Hash::Hash(const std::string & s, HashType type) if (colon == string::npos) { if (type == htUnknown) - throw BadHash("hash ‘%s’ does not include a type", s); + throw BadHash("hash '%s' does not include a type", s); } else { string hts = string(s, 0, colon); this->type = parseHashType(hts); if (this->type == htUnknown) - throw BadHash("unknown hash type ‘%s’", hts); + throw BadHash("unknown hash type '%s'", hts); if (type != htUnknown && type != this->type) - throw BadHash("hash ‘%s’ should have type ‘%s’", s, printHashType(type)); + throw BadHash("hash '%s' should have type '%s'", s, printHashType(type)); pos = colon + 1; } @@ -154,7 +154,7 @@ Hash::Hash(const std::string & s, HashType type) if (c >= '0' && c <= '9') return c - '0'; if (c >= 'A' && c <= 'F') return c - 'A' + 10; if (c >= 'a' && c <= 'f') return c - 'a' + 10; - throw BadHash("invalid base-16 hash ‘%s’", s); + throw BadHash("invalid base-16 hash '%s'", s); }; for (unsigned int i = 0; i < hashSize; i++) { @@ -172,7 +172,7 @@ Hash::Hash(const std::string & s, HashType type) for (digit = 0; digit < base32Chars.size(); ++digit) /* !!! slow */ if (base32Chars[digit] == c) break; if (digit >= 32) - throw BadHash("invalid base-32 hash ‘%s’", s); + throw BadHash("invalid base-32 hash '%s'", s); unsigned int b = n * 5; unsigned int i = b / 8; unsigned int j = b % 8; @@ -182,7 +182,7 @@ Hash::Hash(const std::string & s, HashType type) hash[i + 1] |= digit >> (8 - j); } else { if (digit >> (8 - j)) - throw BadHash("invalid base-32 hash ‘%s’", s); + throw BadHash("invalid base-32 hash '%s'", s); } } } @@ -194,7 +194,7 @@ Hash::Hash(const std::string & s, HashType type) } else - throw BadHash("hash ‘%s’ has wrong length for hash type ‘%s’", s, printHashType(type)); + throw BadHash("hash '%s' has wrong length for hash type '%s'", s, printHashType(type)); } @@ -253,13 +253,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/hash.hh b/src/libutil/hash.hh index b8b432256..d83049b02 100644 --- a/src/libutil/hash.hh +++ b/src/libutil/hash.hh @@ -38,7 +38,7 @@ struct Hash Hash(HashType type) : type(type) { init(); }; /* Initialize the hash from a string representation, in the format - "[<type>:]<base16|base32|base64>". If the ‘type’ argument is + "[<type>:]<base16|base32|base64>". If the 'type' argument is htUnknown, then the hash type must be specified in the string. */ Hash(const std::string & s, HashType type = htUnknown); diff --git a/src/libutil/serialise.hh b/src/libutil/serialise.hh index 2bdee7080..70b193941 100644 --- a/src/libutil/serialise.hh +++ b/src/libutil/serialise.hh @@ -198,7 +198,7 @@ T readNum(Source & source) ((unsigned long long) buf[7] << 56); if (n > std::numeric_limits<T>::max()) - throw SerialisationError("serialised integer %d is too large for type ‘%s’", n, typeid(T).name()); + throw SerialisationError("serialised integer %d is too large for type '%s'", n, typeid(T).name()); return n; } diff --git a/src/libutil/util.cc b/src/libutil/util.cc index d9f8011b6..27f4fea18 100644 --- a/src/libutil/util.cc +++ b/src/libutil/util.cc @@ -104,7 +104,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; @@ -140,7 +140,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 */ @@ -158,7 +158,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); } @@ -195,7 +195,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; } @@ -217,13 +217,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); } @@ -242,7 +242,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.get())) { /* sic */ @@ -257,7 +257,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; } @@ -290,7 +290,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()); } @@ -299,7 +299,7 @@ void writeFile(const Path & path, const string & s, mode_t mode) { AutoCloseFD fd = open(path.c_str(), O_WRONLY | O_TRUNC | O_CREAT | O_CLOEXEC, mode); if (!fd) - throw SysError(format("opening file ‘%1%’") % path); + throw SysError(format("opening file '%1%'") % path); writeFull(fd.get(), s); } @@ -338,7 +338,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) @@ -349,7 +349,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)) @@ -358,7 +358,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); } } @@ -372,7 +372,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); } @@ -410,12 +410,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); } } @@ -473,15 +473,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; } @@ -490,7 +490,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); } @@ -507,7 +507,7 @@ void replaceSymlink(const Path & target, const Path & link) } 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); break; } @@ -589,7 +589,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 (...) { @@ -786,7 +786,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... */ @@ -815,7 +815,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); @@ -823,7 +823,7 @@ void killUser(uid_t uid) int status = pid.wait(); 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 @@ -917,7 +917,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; @@ -950,7 +950,7 @@ string runProgram(Path program, bool searchPath, const Strings & args, /* Wait for the child to finish. */ int status = pid.wait(); if (!statusOk(status)) - throw ExecError(status, format("program ‘%1%’ %2%") + throw ExecError(status, format("program '%1%' %2%") % program % statusToString(status)); /* Wait for the writer thread to finish. */ |