cmultibyte 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Cmultibyte
2
2
 
3
- TODO: Write a gem description
3
+ This reimplements `ActiveSupport::Multibyte::Unicode.tidy_bytes` in C.
4
4
 
5
5
  ## Installation
6
6
 
@@ -18,7 +18,7 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
21
+ Just require it. It monkeypatches AS.
22
22
 
23
23
  ## Contributing
24
24
 
@@ -27,3 +27,7 @@ TODO: Write usage instructions here
27
27
  3. Commit your changes (`git commit -am 'Add some feature'`)
28
28
  4. Push to the branch (`git push origin my-new-feature`)
29
29
  5. Create new Pull Request
30
+
31
+ To run the tests, cd into the activesupport source and run:
32
+
33
+ `cd /path/to/cmultibyte/ext ; make ; cd - ; bundle exec ruby -I./test -I./lib -r/path/to/cmultibyte/ext/cmultibyte.bundle test/multibyte_*`
data/ext/cmultibyte.c CHANGED
@@ -92,7 +92,7 @@ static VALUE tidy_bytes(VALUE string) {
92
92
  int i, j;
93
93
  uint8_t byte;
94
94
 
95
- uint8_t *arr = malloc(4 * sizeof(uint8_t) * RSTRING_LEN(string));
95
+ uint8_t *arr = ALLOCA_N(uint8_t, 4 * RSTRING_LEN(string));
96
96
  uint8_t *curr = arr;
97
97
  uint8_t *prev = curr;
98
98
  uint8_t *last_lead = curr;
@@ -155,7 +155,6 @@ static VALUE tidy_bytes(VALUE string) {
155
155
  }
156
156
  }
157
157
  VALUE str = rb_str_new((const char *)arr, curr-arr);
158
- free(arr);
159
158
  return str;
160
159
  }
161
160
 
@@ -1,3 +1,3 @@
1
1
  module Cmultibyte
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: cmultibyte
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.2
5
+ version: 0.0.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Burke Libbey