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 a92089b

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

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
@@ -1358,7 +1358,7 @@ enum encoding ParseEncoding(const char* encoding,
13581358
} else if (StringEqualNoCase(encoding, "latin1")) {
13591359
return LATIN1;
13601360
} else if (StringEqualNoCase(encoding, "binary")) {
1361-
return BINARY;
1361+
return LATIN1; // BINARY is a deprecated alias of LATIN1.
13621362
} else if (StringEqualNoCase(encoding, "buffer")) {
13631363
return BUFFER;
13641364
} 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
@@ -278,7 +278,9 @@ inline void NODE_SET_PROTOTYPE_METHOD(v8::Local<v8::FunctionTemplate> recv,
278278
}
279279
#define NODE_SET_PROTOTYPE_METHOD node::NODE_SET_PROTOTYPE_METHOD
280280

281-
enum encoding {ASCII, UTF8, BASE64, UCS2, LATIN1, BINARY, HEX, BUFFER};
281+
// BINARY is a deprecated alias of LATIN1.
282+
enum encoding {ASCII, UTF8, BASE64, UCS2, BINARY, HEX, BUFFER, LATIN1 = BINARY};
283+
282284
NODE_EXTERN enum encoding ParseEncoding(
283285
v8::Isolate* isolate,
284286
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
@@ -272,7 +272,6 @@ size_t StringBytes::Write(Isolate* isolate,
272272
switch (encoding) {
273273
case ASCII:
274274
case LATIN1:
275-
case BINARY:
276275
if (is_extern && str->IsOneByte()) {
277276
memcpy(buf, data, nbytes);
278277
} else {
@@ -377,8 +376,7 @@ size_t StringBytes::StorageSize(Isolate* isolate,
377376
size_t data_size = 0;
378377
bool is_buffer = Buffer::HasInstance(val);
379378

380-
if (is_buffer &&
381-
(encoding == BUFFER || encoding == BINARY || encoding == LATIN1)) {
379+
if (is_buffer && (encoding == BUFFER || encoding == LATIN1)) {
382380
return Buffer::Length(val);
383381
}
384382

@@ -387,7 +385,6 @@ size_t StringBytes::StorageSize(Isolate* isolate,
387385
switch (encoding) {
388386
case ASCII:
389387
case LATIN1:
390-
case BINARY:
391388
data_size = str->Length();
392389
break;
393390

@@ -428,8 +425,7 @@ size_t StringBytes::Size(Isolate* isolate,
428425
size_t data_size = 0;
429426
bool is_buffer = Buffer::HasInstance(val);
430427

431-
if (is_buffer &&
432-
(encoding == BUFFER || encoding == BINARY || encoding == LATIN1))
428+
if (is_buffer && (encoding == BUFFER || encoding == LATIN1))
433429
return Buffer::Length(val);
434430

435431
const char* data;
@@ -441,7 +437,6 @@ size_t StringBytes::Size(Isolate* isolate,
441437
switch (encoding) {
442438
case ASCII:
443439
case LATIN1:
444-
case BINARY:
445440
data_size = str->Length();
446441
break;
447442

@@ -645,7 +640,6 @@ Local<Value> StringBytes::Encode(Isolate* isolate,
645640
break;
646641

647642
case LATIN1:
648-
case BINARY:
649643
if (buflen < EXTERN_APEX)
650644
val = OneByteString(isolate, buf, buflen);
651645
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.