Skip to content

Commit

Permalink
build fix: several missing symbols needed for backport
Browse files Browse the repository at this point in the history
  • Loading branch information
joekhoobyar committed Mar 17, 2011
1 parent 2401e25 commit ab56740
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -6,6 +6,8 @@ ripper.o
ripper.y
ripper.c
ripper.E
ripper.so
ripper.dll
ripper.bundle
ids1
ids2
Expand Down
6 changes: 5 additions & 1 deletion ext/backports/ruby/encoding.h
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand Down
16 changes: 15 additions & 1 deletion ext/parse.y
Expand Up @@ -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)
Expand All @@ -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"
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit ab56740

Please sign in to comment.