Skip to content

Commit 16229e2

Browse files
committed
Support ruby 1.8 [GH-1]
1 parent 617922e commit 16229e2

File tree

5 files changed

+14
-5
lines changed

5 files changed

+14
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
*.gem
22
*.rbc
3+
*.swp
34
.bundle
45
.config
56
.yardoc

ext/iconv/depend

Lines changed: 0 additions & 2 deletions
This file was deleted.

ext/iconv/extconf.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
conf = File.exist?(File.join($srcdir, "config.charset"))
66
conf = with_config("config-charset", enable_config("config-charset", conf))
77

8+
have_func("rb_enc_get", "ruby/encoding.h")
9+
have_func("st_lookup", "ruby/st.h")
810
if have_func("iconv", "iconv.h") or
911
have_library("iconv", "iconv", "iconv.h")
10-
check_signedness("size_t")
12+
check_signedness("size_t") rescue nil
1113
if checking_for("const of iconv() 2nd argument") do
1214
create_tmpsrc(cpp_include("iconv.h") + "---> iconv(cd,0,0,0,0) <---")
1315
src = xpopen(cpp_command("")) {|f|f.read}

ext/iconv/iconv.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,18 @@
1313
1414
**********************************************************************/
1515

16-
#include "ruby/ruby.h"
16+
#include "ruby.h"
1717
#include <errno.h>
1818
#include <iconv.h>
1919
#include <assert.h>
20+
#ifdef HAVE_RUBY_ST_H
2021
#include "ruby/st.h"
22+
#else /* assume 1.8 */
23+
#include "st.h"
24+
#endif
25+
#ifdef HAVE_RUBY_ENCODING_H
2126
#include "ruby/encoding.h"
27+
#endif
2228

2329
/*
2430
* Document-class: Iconv
@@ -932,6 +938,7 @@ iconv_iconv(int argc, VALUE *argv, VALUE self)
932938
length = NIL_P(n2) ? -1 : NUM2LONG(n2);
933939
}
934940
}
941+
#ifdef HAVE_RUBY_ENCODING_H
935942
if (start > 0 || length > 0) {
936943
rb_encoding *enc = rb_enc_get(str);
937944
const char *s = RSTRING_PTR(str), *e = s + RSTRING_LEN(str);
@@ -943,6 +950,7 @@ iconv_iconv(int argc, VALUE *argv, VALUE self)
943950
length = rb_enc_nth(ps, e, length, enc) - ps;
944951
}
945952
}
953+
#endif
946954

947955
return iconv_convert(VALUE2ICONV(cd), str, start, length, ENCODING_GET(self), NULL);
948956
}

lib/iconv/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
class Iconv
2-
VERSION = "1.0.0"
2+
VERSION = "1.0.1"
33
end

0 commit comments

Comments
 (0)