discount 1.2.6 → 1.2.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/Rakefile +1 -1
  2. data/ext/rbstrio.c +21 -4
  3. data/ext/rbstrio.h +0 -1
  4. metadata +1 -1
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'rake/gempackagetask'
5
5
  task :default => 'test:unit'
6
6
 
7
7
  DLEXT = Config::CONFIG['DLEXT']
8
- VERS = '1.2.6'
8
+ VERS = '1.2.6.1'
9
9
 
10
10
  spec =
11
11
  Gem::Specification.new do |s|
@@ -1,26 +1,43 @@
1
+ #define _GNU_SOURCE
2
+
3
+ #include <stdlib.h>
1
4
  #include "rbstrio.h"
2
- #include "ruby.h"
3
5
 
4
6
  #define INCREMENT 1024
5
7
 
6
8
  /* called when data is written to the stream. */
7
9
  static int rb_str_io_write(void *cookie, const char *data, int len) {
8
- VALUE buf = cookie;
10
+ VALUE buf = (VALUE)cookie;
9
11
  rb_str_cat(buf, data, len);
10
12
  return len;
11
13
  }
12
14
 
13
15
  /* called when the stream is closed */
14
16
  static int rb_str_io_close(void *cookie) {
15
- rb_gc_unregister_address(&cookie);
17
+ VALUE buf = (VALUE)cookie;
18
+ rb_gc_unregister_address(&buf);
16
19
  return 0;
17
20
  }
18
21
 
22
+ #ifdef __GLIBC__
23
+ cookie_io_functions_t rb_str_io_functions =
24
+ {
25
+ (cookie_read_function_t*)NULL,
26
+ (cookie_write_function_t*)rb_str_io_write,
27
+ (cookie_seek_function_t*)NULL,
28
+ (cookie_close_function_t*)rb_str_io_close
29
+ };
30
+ #endif
31
+
19
32
  /* create a stream backed by a Ruby string. */
20
33
  FILE *rb_str_io_new(VALUE buf) {
21
34
  FILE *rv;
22
35
  Check_Type(buf, T_STRING);
23
- rv = funopen(buf, NULL, rb_str_io_write, NULL, rb_str_io_close);
36
+ #ifdef __GLIBC__
37
+ rv = fopencookie((void*)buf, "w", rb_str_io_functions);
38
+ #else
39
+ rv = funopen((void*)buf, NULL, rb_str_io_write, NULL, rb_str_io_close);
40
+ #endif
24
41
  /* TODO if (rv == NULL) */
25
42
  rb_gc_register_address(&buf);
26
43
  return rv;
@@ -1,4 +1,3 @@
1
- #include <stdlib.h>
2
1
  #include <stdio.h>
3
2
  #include "ruby.h"
4
3
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: discount
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.6
4
+ version: 1.2.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Tomayko