Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
joyeecheung committed Jul 19, 2023
1 parent 4ea784f commit 02f04a8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/node_snapshot_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct SnapshotData;
class NODE_EXTERN_PRIVATE SnapshotBuilder {
public:
static ExitCode GenerateAsSource(
std::string_view out_path,
const char* out_path,
const std::vector<std::string>& args,
const std::vector<std::string>& exec_args,
std::optional<std::string_view> main_script_path = std::nullopt,
Expand Down
18 changes: 8 additions & 10 deletions src/node_snapshotable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -737,27 +737,25 @@ static std::string FormatSize(size_t size) {
}

std::string ToOctalString(const uint8_t ch) {
std::string result;
// We can print most printable characters directly. The exceptions are '\'
// (escape characters), " (would end the string), and ? (trigraphs). The
// latter may be overly conservative: we compile with C++17 which doesn't
// support trigraphs.
if (ch >= ' ' && ch <= '~' && ch != '\\' && ch != '"' && ch != '?') {
return std::string(1, static_cast<char>(ch));
} else {
// All other characters are blindly output as octal.
const char c0 = '0' + ((ch >> 6) & 7);
const char c1 = '0' + ((ch >> 3) & 7);
const char c2 = '0' + (ch & 7);
return std::string("\\") + c0 + c1 + c2;
}
// All other characters are blindly output as octal.
const char c0 = '0' + ((ch >> 6) & 7);
const char c1 = '0' + ((ch >> 3) & 7);
const char c2 = '0' + (ch & 7);
return std::string("\\") + c0 + c1 + c2;
}

std::vector<std::string> GetOctalTable() {
size_t size = 1 << 8;
std::vector<std::string> code_table(size);
for (uint8_t i = 0; i < size; ++i) {
code_table[i] = ToOctalString(i);
for (size_t i = 0; i < size; ++i) {
code_table[i] = ToOctalString(static_cast<uint8_t>(i));
}
return code_table;
}
Expand Down Expand Up @@ -1083,7 +1081,7 @@ ExitCode SnapshotBuilder::CreateSnapshot(SnapshotData* out,
}

ExitCode SnapshotBuilder::GenerateAsSource(
std::string_view out_path,
const char* out_path,
const std::vector<std::string>& args,
const std::vector<std::string>& exec_args,
std::optional<std::string_view> main_script_path,
Expand Down
2 changes: 1 addition & 1 deletion tools/snapshot/node_mksnapshot.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ int BuildSnapshot(int argc, char* argv[]) {
#endif

node::ExitCode exit_code =
node::SnapshotBuilder::GenerateAsSource(out_path,
node::SnapshotBuilder::GenerateAsSource(out_path.c_str(),
result->args(),
result->exec_args(),
main_script_path,
Expand Down

0 comments on commit 02f04a8

Please sign in to comment.