bare-buffer 2.5.4 → 2.5.6

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.
Files changed (49) hide show
  1. package/CMakeLists.txt +2 -2
  2. package/package.json +2 -1
  3. package/prebuilds/android-arm/bare-buffer.bare +0 -0
  4. package/prebuilds/android-arm64/bare-buffer.bare +0 -0
  5. package/prebuilds/android-ia32/bare-buffer.bare +0 -0
  6. package/prebuilds/android-x64/bare-buffer.bare +0 -0
  7. package/prebuilds/darwin-arm64/bare-buffer.bare +0 -0
  8. package/prebuilds/darwin-x64/bare-buffer.bare +0 -0
  9. package/prebuilds/ios-arm64/bare-buffer.bare +0 -0
  10. package/prebuilds/ios-arm64-simulator/bare-buffer.bare +0 -0
  11. package/prebuilds/ios-x64-simulator/bare-buffer.bare +0 -0
  12. package/prebuilds/linux-arm64/bare-buffer.bare +0 -0
  13. package/prebuilds/linux-x64/bare-buffer.bare +0 -0
  14. package/prebuilds/win32-arm64/bare-buffer.bare +0 -0
  15. package/prebuilds/win32-x64/bare-buffer.bare +0 -0
  16. package/vendor/libutf/CMakeLists.txt +23 -6
  17. package/vendor/libutf/include/utf/string.h +46 -19
  18. package/vendor/libutf/include/utf.h +87 -0
  19. package/vendor/libutf/src/ascii/validate.c +47 -0
  20. package/vendor/libutf/src/endianness.c +1 -1
  21. package/vendor/libutf/src/latin1/convert-to-utf16.c +37 -0
  22. package/vendor/libutf/src/latin1/convert-to-utf32.c +34 -0
  23. package/vendor/libutf/src/latin1/convert-to-utf8.c +58 -0
  24. package/vendor/libutf/src/latin1/length-from-utf16.c +26 -0
  25. package/vendor/libutf/src/latin1/length-from-utf32.c +26 -0
  26. package/vendor/libutf/src/latin1/length-from-utf8.c +34 -0
  27. package/vendor/libutf/src/utf16/convert-to-latin1.c +41 -0
  28. package/vendor/libutf/src/utf16/convert-to-utf32.c +56 -0
  29. package/vendor/libutf/src/utf16/{utf8-convert.c → convert-to-utf8.c} +1 -3
  30. package/vendor/libutf/src/utf16/length-from-latin1.c +26 -0
  31. package/vendor/libutf/src/utf16/length-from-utf32.c +33 -0
  32. package/vendor/libutf/src/{utf8/utf16-length.c → utf16/length-from-utf8.c} +0 -1
  33. package/vendor/libutf/src/utf16/validate.c +1 -1
  34. package/vendor/libutf/src/utf32/convert-to-latin1.c +40 -0
  35. package/vendor/libutf/src/utf32/convert-to-utf16.c +56 -0
  36. package/vendor/libutf/src/utf32/convert-to-utf8.c +71 -0
  37. package/vendor/libutf/src/utf32/length-from-latin1.c +26 -0
  38. package/vendor/libutf/src/utf32/length-from-utf16.c +35 -0
  39. package/vendor/libutf/src/utf32/length-from-utf8.c +35 -0
  40. package/vendor/libutf/src/utf32/validate.c +39 -0
  41. package/vendor/libutf/src/utf8/convert-to-latin1.c +70 -0
  42. package/vendor/libutf/src/utf8/{utf16-convert.c → convert-to-utf16.c} +10 -5
  43. package/vendor/libutf/src/utf8/convert-to-utf32.c +110 -0
  44. package/vendor/libutf/src/utf8/length-from-latin1.c +32 -0
  45. package/vendor/libutf/src/{utf16/utf8-length.c → utf8/length-from-utf16.c} +1 -2
  46. package/vendor/libutf/src/utf8/length-from-utf32.c +35 -0
  47. package/vendor/libutf/src/utf8/string.c +2 -1
  48. package/vendor/libutf/src/utf8/validate.c +9 -9
  49. /package/vendor/libutf/{include/utf → src}/endianness.h +0 -0
@@ -0,0 +1,32 @@
1
+ #include <stddef.h>
2
+
3
+ #include "../../include/utf.h"
4
+
5
+ /**
6
+ * Modified from https://github.com/simdutf/simdutf
7
+ *
8
+ * Copyright 2020 The simdutf authors
9
+ *
10
+ * Licensed under the Apache License, Version 2.0 (the "License");
11
+ * you may not use this file except in compliance with the License.
12
+ * You may obtain a copy of the License at
13
+ *
14
+ * http://www.apache.org/licenses/LICENSE-2.0
15
+ *
16
+ * Unless required by applicable law or agreed to in writing, software
17
+ * distributed under the License is distributed on an "AS IS" BASIS,
18
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ * See the License for the specific language governing permissions and
20
+ * limitations under the License.
21
+ */
22
+
23
+ size_t
24
+ utf8_length_from_latin1 (const latin1_t *data, size_t len) {
25
+ size_t counter = len;
26
+
27
+ for (size_t i = 0; i < len; i++) {
28
+ counter += data[i] >> 7;
29
+ }
30
+
31
+ return counter;
32
+ }
@@ -1,9 +1,8 @@
1
- #include <stdbool.h>
2
1
  #include <stddef.h>
3
2
  #include <stdint.h>
4
3
 
5
4
  #include "../../include/utf.h"
6
- #include "../../include/utf/endianness.h"
5
+ #include "../endianness.h"
7
6
 
8
7
  /**
9
8
  * Modified from https://github.com/simdutf/simdutf
@@ -0,0 +1,35 @@
1
+ #include <stddef.h>
2
+
3
+ #include "../../include/utf.h"
4
+
5
+ /**
6
+ * Modified from https://github.com/simdutf/simdutf
7
+ *
8
+ * Copyright 2020 The simdutf authors
9
+ *
10
+ * Licensed under the Apache License, Version 2.0 (the "License");
11
+ * you may not use this file except in compliance with the License.
12
+ * You may obtain a copy of the License at
13
+ *
14
+ * http://www.apache.org/licenses/LICENSE-2.0
15
+ *
16
+ * Unless required by applicable law or agreed to in writing, software
17
+ * distributed under the License is distributed on an "AS IS" BASIS,
18
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ * See the License for the specific language governing permissions and
20
+ * limitations under the License.
21
+ */
22
+
23
+ size_t
24
+ utf8_length_from_utf32 (const utf32_t *data, size_t len) {
25
+ size_t counter = 0;
26
+
27
+ for (size_t i = 0; i < len; i++) {
28
+ counter++;
29
+ counter += data[i] > 0x7f;
30
+ counter += data[i] > 0x7ff;
31
+ counter += data[i] > 0xffff;
32
+ }
33
+
34
+ return counter;
35
+ }
@@ -1,3 +1,4 @@
1
+ #include <stdbool.h>
1
2
  #include <stddef.h>
2
3
 
3
4
  #include "../../include/utf.h"
@@ -25,7 +26,7 @@ extern void
25
26
  utf8_string_clear (utf8_string_t *string);
26
27
 
27
28
  extern bool
28
- utf8_string_empty (utf8_string_t *string);
29
+ utf8_string_empty (const utf8_string_t *string);
29
30
 
30
31
  extern bool
31
32
  utf8_string_view_empty (const utf8_string_view_t view);
@@ -26,7 +26,6 @@
26
26
  bool
27
27
  utf8_validate (const utf8_t *data, size_t len) {
28
28
  uint64_t pos = 0;
29
- uint32_t code_point;
30
29
  uint8_t word;
31
30
 
32
31
  while (pos < len) {
@@ -42,13 +41,11 @@ utf8_validate (const utf8_t *data, size_t len) {
42
41
  continue;
43
42
  }
44
43
  }
45
-
46
44
  word = data[pos];
47
45
  while (word < 0b10000000) {
48
46
  if (++pos == len) return true;
49
47
  word = data[pos];
50
48
  }
51
-
52
49
  if ((word & 0b11100000) == 0b11000000) {
53
50
  next_pos = pos + 2;
54
51
  if (next_pos > len) {
@@ -57,7 +54,8 @@ utf8_validate (const utf8_t *data, size_t len) {
57
54
  if ((data[pos + 1] & 0b11000000) != 0b10000000) {
58
55
  return false;
59
56
  }
60
- code_point = (word & 0b00011111) << 6 | (data[pos + 1] & 0b00111111);
57
+ uint32_t code_point = ((word & 0b00011111) << 6) |
58
+ (data[pos + 1] & 0b00111111);
61
59
  if ((code_point < 0x80) || (0x7ff < code_point)) {
62
60
  return false;
63
61
  }
@@ -72,9 +70,9 @@ utf8_validate (const utf8_t *data, size_t len) {
72
70
  if ((data[pos + 2] & 0b11000000) != 0b10000000) {
73
71
  return false;
74
72
  }
75
- code_point = (word & 0b00001111) << 12 |
76
- (data[pos + 1] & 0b00111111) << 6 |
77
- (data[pos + 2] & 0b00111111);
73
+ uint32_t code_point = ((word & 0b00001111) << 12) |
74
+ ((data[pos + 1] & 0b00111111) << 6) |
75
+ (data[pos + 2] & 0b00111111);
78
76
  if ((code_point < 0x800) || (0xffff < code_point) || (0xd7ff < code_point && code_point < 0xe000)) {
79
77
  return false;
80
78
  }
@@ -92,8 +90,10 @@ utf8_validate (const utf8_t *data, size_t len) {
92
90
  if ((data[pos + 3] & 0b11000000) != 0b10000000) {
93
91
  return false;
94
92
  }
95
- code_point = (word & 0b00000111) << 18 | (data[pos + 1] & 0b00111111) << 12 |
96
- (data[pos + 2] & 0b00111111) << 6 | (data[pos + 3] & 0b00111111);
93
+ uint32_t code_point = ((word & 0b00000111) << 18) |
94
+ ((data[pos + 1] & 0b00111111) << 12) |
95
+ ((data[pos + 2] & 0b00111111) << 6) |
96
+ (data[pos + 3] & 0b00111111);
97
97
  if (code_point <= 0xffff || 0x10ffff < code_point) {
98
98
  return false;
99
99
  }
File without changes