msgpackr-extract 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -8
- package/src/extract.cpp +7 -7
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "msgpackr-extract",
|
|
3
3
|
"author": "Kris Zyp",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.2",
|
|
5
5
|
"description": "Node addon for string extraction for msgpackr",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -28,15 +28,15 @@
|
|
|
28
28
|
"/*.gyp"
|
|
29
29
|
],
|
|
30
30
|
"optionalDependencies": {
|
|
31
|
-
"@msgpackr-extract/msgpackr-extract-darwin-arm64": "2.0.
|
|
32
|
-
"@msgpackr-extract/msgpackr-extract-darwin-x64": "2.0.
|
|
33
|
-
"@msgpackr-extract/msgpackr-extract-linux-arm": "2.0.
|
|
34
|
-
"@msgpackr-extract/msgpackr-extract-linux-arm64": "2.0.
|
|
35
|
-
"@msgpackr-extract/msgpackr-extract-linux-x64": "2.0.
|
|
36
|
-
"@msgpackr-extract/msgpackr-extract-win32-x64": "2.0.
|
|
31
|
+
"@msgpackr-extract/msgpackr-extract-darwin-arm64": "2.0.2",
|
|
32
|
+
"@msgpackr-extract/msgpackr-extract-darwin-x64": "2.0.2",
|
|
33
|
+
"@msgpackr-extract/msgpackr-extract-linux-arm": "2.0.2",
|
|
34
|
+
"@msgpackr-extract/msgpackr-extract-linux-arm64": "2.0.2",
|
|
35
|
+
"@msgpackr-extract/msgpackr-extract-linux-x64": "2.0.2",
|
|
36
|
+
"@msgpackr-extract/msgpackr-extract-win32-x64": "2.0.2"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"prebuildify": "kriszyp/prebuildify#optional-packages",
|
|
40
40
|
"prebuildify-ci": "^1.0.5"
|
|
41
41
|
}
|
|
42
|
-
}
|
|
42
|
+
}
|
package/src/extract.cpp
CHANGED
|
@@ -34,7 +34,6 @@ napi_value unexpectedEnd(napi_env env) {
|
|
|
34
34
|
|
|
35
35
|
class Extractor {
|
|
36
36
|
public:
|
|
37
|
-
napi_value target[MAX_TARGET_SIZE + 1]; // leave one for the queued string
|
|
38
37
|
// napi_ref targetArray; // could consider reenabling this optimization for napi
|
|
39
38
|
bool hasTargetArray = false;
|
|
40
39
|
uint8_t* source;
|
|
@@ -43,7 +42,7 @@ public:
|
|
|
43
42
|
int stringStart = 0;
|
|
44
43
|
int lastStringEnd = 0;
|
|
45
44
|
|
|
46
|
-
void readString(napi_env env, int length, bool allowStringBlocks) {
|
|
45
|
+
void readString(napi_env env, int length, bool allowStringBlocks, napi_value* target) {
|
|
47
46
|
int start = position;
|
|
48
47
|
int end = position + length;
|
|
49
48
|
if (allowStringBlocks) { // for larger strings, we don't bother to check every character for being latin, and just go right to creating a new string
|
|
@@ -85,6 +84,7 @@ public:
|
|
|
85
84
|
}
|
|
86
85
|
|
|
87
86
|
napi_value extractStrings(napi_env env, int startingPosition, int size, uint8_t* inputSource) {
|
|
87
|
+
napi_value target[MAX_TARGET_SIZE + 1]; // leave one for the queued string
|
|
88
88
|
writePosition = 0;
|
|
89
89
|
lastStringEnd = 0;
|
|
90
90
|
position = startingPosition;
|
|
@@ -99,7 +99,7 @@ public:
|
|
|
99
99
|
if (token + position > size) {
|
|
100
100
|
return unexpectedEnd(env);
|
|
101
101
|
}
|
|
102
|
-
readString(env,token, true);
|
|
102
|
+
readString(env, token, true, target);
|
|
103
103
|
if (writePosition >= MAX_TARGET_SIZE)
|
|
104
104
|
break;
|
|
105
105
|
} else if (token <= 0xdb && token >= 0xd9) {
|
|
@@ -111,7 +111,7 @@ public:
|
|
|
111
111
|
if (length + position > size) {
|
|
112
112
|
return unexpectedEnd(env);
|
|
113
113
|
}
|
|
114
|
-
readString(env,length, true);
|
|
114
|
+
readString(env,length, true, target);
|
|
115
115
|
} else if (token == 0xda) { //str 16
|
|
116
116
|
if (2 + position > size) {
|
|
117
117
|
return unexpectedEnd(env);
|
|
@@ -121,7 +121,7 @@ public:
|
|
|
121
121
|
if (length + position > size) {
|
|
122
122
|
return unexpectedEnd(env);
|
|
123
123
|
}
|
|
124
|
-
readString(env,length, false);
|
|
124
|
+
readString(env,length, false, target);
|
|
125
125
|
} else { //str 32
|
|
126
126
|
if (4 + position > size) {
|
|
127
127
|
return unexpectedEnd(env);
|
|
@@ -133,7 +133,7 @@ public:
|
|
|
133
133
|
if (length + position > size) {
|
|
134
134
|
return unexpectedEnd(env);
|
|
135
135
|
}
|
|
136
|
-
readString(env, length, false);
|
|
136
|
+
readString(env, length, false, target);
|
|
137
137
|
}
|
|
138
138
|
if (writePosition >= MAX_TARGET_SIZE)
|
|
139
139
|
break;
|
|
@@ -269,4 +269,4 @@ NAPI_MODULE_INIT() {
|
|
|
269
269
|
setupTokenTable();
|
|
270
270
|
EXPORT_NAPI_FUNCTION("extractStrings", extractStrings);
|
|
271
271
|
return exports;
|
|
272
|
-
}
|
|
272
|
+
}
|