Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

build fix: several missing symbols needed for backport

  • Loading branch information...
commit ab56740f2911406cf609da30191f2c23b13121bd 1 parent 2401e25
@joekhoobyar joekhoobyar authored
Showing with 22 additions and 2 deletions.
  1. +2 −0  .gitignore
  2. +5 −1 ext/backports/ruby/encoding.h
  3. +15 −1 ext/parse.y
View
2  .gitignore
@@ -6,6 +6,8 @@ ripper.o
ripper.y
ripper.c
ripper.E
+ripper.so
+ripper.dll
ripper.bundle
ids1
ids2
View
6 ext/backports/ruby/encoding.h
@@ -22,7 +22,8 @@ typedef struct rb_encoding_s {
static rb_encoding __default_encoding_s = {1, 1, "default"};
static rb_encoding *__default_encoding = &__default_encoding_s;
-int rb_char_to_option_kcode(int c, int *option, int *kcode) { return 0; }
+int rb_char_to_option_kcode(int c, int *option, int *kcode) { *option=0; *kcode=-1; return 0; }
+int __default_rb_enc_mbcput(int c, char *p, rb_encoding *enc) { do *p++ = (char) (c & 0xff); while (c >> 8); return c; }
#define ENC_CODERANGE_7BIT 0
#define ENC_CODERANGE_UNKNOWN -1
@@ -38,6 +39,8 @@ int rb_char_to_option_kcode(int c, int *option, int *kcode) { return 0; }
#define rb_enc_mbminlen(enc) (enc)->min_enc_len
#define rb_enc_mbmaxlen(enc) (enc)->max_enc_len
#define rb_enc_mbclen(p,e,enc) 1
+#define rb_enc_codelen(c,enc) (((c) & 0xffffff00) ? ((c) & 0xffff0000) ? ((c) & 0xff000000) ? 4 : 3 : 2 : 1)
+#define rb_enc_mbcput(c,p,enc) __default_rb_enc_mbcput(c,(void*)p,enc)
#define rb_enc_fast_mbclen(p,e,enc) 1
#define rb_enc_isascii(c,enc) isascii(c)
#define rb_enc_isalpha(c,enc) isalpha(c)
@@ -54,6 +57,7 @@ int rb_char_to_option_kcode(int c, int *option, int *kcode) { return 0; }
#define rb_enc_from_encoding(e) Qnil
#define rb_enc_precise_mbclen(s,l,e) 1
#define rb_enc_unicode_p(e) 0
+#define rb_ascii8bit_encindex(e) 1
#define rb_ascii8bit_encoding() __default_encoding
#define rb_utf8_encoding() __default_encoding
#define rb_usascii_encoding() __default_encoding
View
16 ext/parse.y
@@ -28,6 +28,18 @@
#define numberof(array) (int)(sizeof(array) / sizeof((array)[0]))
+#ifdef RIPPER
+
+#define YYMALLOC(size) xmalloc(size)
+#define YYREALLOC(ptr, size) xrealloc(ptr, size)
+#define YYCALLOC(nelem, size) xcalloc(nelem, size)
+#define YYFREE(ptr) xfree(ptr)
+#define malloc YYMALLOC
+#define realloc YYREALLOC
+#define calloc YYCALLOC
+#define free YYFREE
+
+#else
#define YYMALLOC(size) rb_parser_malloc(parser, size)
#define YYREALLOC(ptr, size) rb_parser_realloc(parser, ptr, size)
#define YYCALLOC(nelem, size) rb_parser_calloc(parser, nelem, size)
@@ -37,7 +49,6 @@
#define calloc YYCALLOC
#define free YYFREE
-#ifndef RIPPER
static ID register_symid(ID, const char *, long, rb_encoding *);
#define REGISTER_SYMID(id, name) register_symid(id, name, strlen(name), enc)
#include "id.c"
@@ -270,6 +281,9 @@ struct parser_params {
#define STR_NEW3(p,n,e,func) parser_str_new((p),(n),(e),(func),parser->enc)
#define ENC_SINGLE(cr) ((cr)==ENC_CODERANGE_7BIT)
#define TOK_INTERN(mb) rb_intern3(tok(), toklen(), parser->enc)
+#ifdef RIPPER
+#define rb_str_new_cstr rb_str_new2
+#endif
#ifdef YYMALLOC
void *rb_parser_malloc(struct parser_params *, size_t);
Please sign in to comment.
Something went wrong with that request. Please try again.