Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixup! src: remove calls to deprecated v8 functions (NewFromUtf8)
  • Loading branch information
ryzokuken committed Jul 21, 2018
commit 7bf4efec96bd26605cff5b34db7db7faf9e2f7ec
20 changes: 12 additions & 8 deletions src/exceptions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ Local<Value> ErrnoException(Isolate* isolate,
Local<String> path_string;
if (path != nullptr) {
// FIXME(bnoordhuis) It's questionable to interpret the file path as UTF-8.
path_string = String::NewFromUtf8(
env->isolate(), path, v8::NewStringType::kNormal).ToLocalChecked();
path_string = String::NewFromUtf8(env->isolate(), path,
v8::NewStringType::kNormal).ToLocalChecked();
}

if (path_string.IsEmpty() == false) {
Expand All @@ -66,17 +66,18 @@ Local<Value> ErrnoException(Isolate* isolate,
}

static Local<String> StringFromPath(Isolate* isolate, const char* path) {
v8::NewStringType type = v8::NewStringType::kNormal;
#ifdef _WIN32
if (strncmp(path, "\\\\?\\UNC\\", 8) == 0) {
v8::NewStringType type = v8::NewStringType::kNormal;
return String::Concat(FIXED_ONE_BYTE_STRING(isolate, "\\\\"),
String::NewFromUtf8(isolate, path + 8));
String::NewFromUtf8(isolate, path + 8, type)
.ToLocalChecked());
} else if (strncmp(path, "\\\\?\\", 4) == 0) {
return String::NewFromUtf8(isolate, path + 4);
return String::NewFromUtf8(isolate, path + 4, type).ToLocalChecked();
}
#endif

return String::NewFromUtf8(isolate, path, v8::NewStringType::kNormal).ToLocalChecked();
return String::NewFromUtf8(isolate, path, type).ToLocalChecked();
}


Expand Down Expand Up @@ -181,11 +182,13 @@ Local<Value> WinapiErrnoException(Isolate* isolate,
}
Local<String> message = OneByteString(env->isolate(), msg);

v8::NewStringType type = v8::NewStringType::kNormal;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you do decide to create new variables for these, can you name the more expressively (e.g. new_string_type or maybe string_type)?

if (path) {
Local<String> cons1 =
String::Concat(message, FIXED_ONE_BYTE_STRING(isolate, " '"));
Local<String> cons2 =
String::Concat(cons1, String::NewFromUtf8(isolate, path));
String::Concat(cons1,
String::NewFromUtf8(isolate, path, type).ToLocalChecked());
Local<String> cons3 =
String::Concat(cons2, FIXED_ONE_BYTE_STRING(isolate, "'"));
e = Exception::Error(cons3);
Expand All @@ -197,7 +200,8 @@ Local<Value> WinapiErrnoException(Isolate* isolate,
obj->Set(env->errno_string(), Integer::New(isolate, errorno));

if (path != nullptr) {
obj->Set(env->path_string(), String::NewFromUtf8(isolate, path));
obj->Set(env->path_string(),
String::NewFromUtf8(isolate, path, type).ToLocalChecked());
}

if (syscall != nullptr) {
Expand Down