Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit da9bd2f

Browse filesBrowse files
bnoordhuisaddaleax
authored andcommitted
src: alias BINARY to LATIN1
Make BINARY an alias for LATIN1 rather than a distinct enum value. PR-URL: #7284 Refs: #7262 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
1 parent 7ba0f86 commit da9bd2f
Copy full SHA for da9bd2f

File tree

Expand file treeCollapse file tree

4 files changed

+8
-10
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

4 files changed

+8
-10
lines changed
Open diff view settings
Collapse file

‎src/node.cc‎

Copy file name to clipboardExpand all lines: src/node.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1454,7 +1454,7 @@ enum encoding ParseEncoding(const char* encoding,
14541454
} else if (StringEqualNoCase(encoding, "latin1")) {
14551455
return LATIN1;
14561456
} else if (StringEqualNoCase(encoding, "binary")) {
1457-
return BINARY;
1457+
return LATIN1; // BINARY is a deprecated alias of LATIN1.
14581458
} else if (StringEqualNoCase(encoding, "buffer")) {
14591459
return BUFFER;
14601460
} else if (StringEqualNoCase(encoding, "hex")) {
Collapse file

‎src/node.h‎

Copy file name to clipboardExpand all lines: src/node.h
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,9 @@ inline void NODE_SET_PROTOTYPE_METHOD(v8::Local<v8::FunctionTemplate> recv,
284284
}
285285
#define NODE_SET_PROTOTYPE_METHOD node::NODE_SET_PROTOTYPE_METHOD
286286

287-
enum encoding {ASCII, UTF8, BASE64, UCS2, LATIN1, BINARY, HEX, BUFFER};
287+
// BINARY is a deprecated alias of LATIN1.
288+
enum encoding {ASCII, UTF8, BASE64, UCS2, BINARY, HEX, BUFFER, LATIN1 = BINARY};
289+
288290
NODE_EXTERN enum encoding ParseEncoding(
289291
v8::Isolate* isolate,
290292
v8::Local<v8::Value> encoding_v,
Collapse file

‎src/string_bytes.cc‎

Copy file name to clipboardExpand all lines: src/string_bytes.cc
+2-8Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,6 @@ size_t StringBytes::Write(Isolate* isolate,
283283
switch (encoding) {
284284
case ASCII:
285285
case LATIN1:
286-
case BINARY:
287286
if (is_extern && str->IsOneByte()) {
288287
memcpy(buf, data, nbytes);
289288
} else {
@@ -388,8 +387,7 @@ size_t StringBytes::StorageSize(Isolate* isolate,
388387
size_t data_size = 0;
389388
bool is_buffer = Buffer::HasInstance(val);
390389

391-
if (is_buffer &&
392-
(encoding == BUFFER || encoding == BINARY || encoding == LATIN1)) {
390+
if (is_buffer && (encoding == BUFFER || encoding == LATIN1)) {
393391
return Buffer::Length(val);
394392
}
395393

@@ -398,7 +396,6 @@ size_t StringBytes::StorageSize(Isolate* isolate,
398396
switch (encoding) {
399397
case ASCII:
400398
case LATIN1:
401-
case BINARY:
402399
data_size = str->Length();
403400
break;
404401

@@ -439,8 +436,7 @@ size_t StringBytes::Size(Isolate* isolate,
439436
size_t data_size = 0;
440437
bool is_buffer = Buffer::HasInstance(val);
441438

442-
if (is_buffer &&
443-
(encoding == BUFFER || encoding == BINARY || encoding == LATIN1))
439+
if (is_buffer && (encoding == BUFFER || encoding == LATIN1))
444440
return Buffer::Length(val);
445441

446442
const char* data;
@@ -452,7 +448,6 @@ size_t StringBytes::Size(Isolate* isolate,
452448
switch (encoding) {
453449
case ASCII:
454450
case LATIN1:
455-
case BINARY:
456451
data_size = str->Length();
457452
break;
458453

@@ -656,7 +651,6 @@ Local<Value> StringBytes::Encode(Isolate* isolate,
656651
break;
657652

658653
case LATIN1:
659-
case BINARY:
660654
if (buflen < EXTERN_APEX)
661655
val = OneByteString(isolate, buf, buflen);
662656
else
Collapse file

‎test/addons/parse-encoding/binding.cc‎

Copy file name to clipboardExpand all lines: test/addons/parse-encoding/binding.cc
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ namespace {
1212
V(UCS2) \
1313
V(UTF8) \
1414

15+
static_assert(node::BINARY == node::LATIN1, "BINARY == LATIN1");
16+
1517
void ParseEncoding(const v8::FunctionCallbackInfo<v8::Value>& args) {
1618
const node::encoding encoding =
1719
node::ParseEncoding(args.GetIsolate(), args[0],

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.